#
# ctext.test --
#   Unit tests for the ctext package.
#
#
# Startup unit tests
#
package require tcltest
namespace import -force tcltest::test
tcltest::configure -verbose {body error pass start}
package require ctext
test ctext-1.1 {} {
    ctext .t -undo 1
    .t insert 1.0 "This is a sentence."
    set res [.t edit modified]
    destroy .t
    set res $res
} {1}
test ctext-1.2 {} {
    ctext .t -undo 1
    .t insert 1.0 "This is a sentence."
    .t edit undo
    set res [.t edit modified]
    destroy .t
    set res $res
} {0}
test ctext-1.3 {} {
    ctext .t -undo 1
    .t insert 1.0 "This is a sentence."
    .t edit modified 0
    set res [.t edit modified]
    destroy .t
    set res $res
} {0}
test ctext-1.4 {} {
    ctext .t -undo 1
    .t insert 1.0 "This is a sentence."
    .t edit modified 0
    .t edit reset
    set res [.t edit modified]
    destroy .t
    set res $res
} {0}
test ctext-1.5 {} {
    ctext .t -undo 1
    set res [catch {.t edit undo} msg]
    destroy .t
    set res $res
}{1}
test ctext-1.7 {} {
    ctext .t -undo 1
    .t insert 1.0 "This is a sentence."
    .t tag add sel 1.0 1.4
    .t delete sel.first sel.last
    set res [.t get 1.0 1.end]
    destroy .t
    set res $res
} { is a sentence.}
test ctext-1.8 {test destroy, then update} {
    ctext .t
    destroy .t
    update
} {}
#
# Shutdown unit tests
#
tcltest::cleanupTests

