summaryrefslogtreecommitdiffstats
path: root/tests/cluster.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cluster.test')
-rw-r--r--tests/cluster.test246
1 files changed, 246 insertions, 0 deletions
diff --git a/tests/cluster.test b/tests/cluster.test
new file mode 100644
index 0000000..be889c3
--- /dev/null
+++ b/tests/cluster.test
@@ -0,0 +1,246 @@
+# This file is a Tcl script to test the [::tk::startOf|endOf]* functions in
+# tk.tcl and tkIcu.c. It is organized in the standard fashion for Tcl tests.
+#
+# Copyright © 1994 The Regents of the University of California.
+# Copyright © 1994-1995 Sun Microsystems, Inc.
+# Copyright © 1998-1999 Scriptics Corporation.
+# All rights reserved.
+
+package require tcltest 2.2
+eval tcltest::configure $argv
+tcltest::loadTestedCommands
+namespace import -force tcltest::test
+
+testConstraint needsICU [expr {[catch {info body ::tk::startOfCluster}]}]
+
+
+test cluster-1.0 {::tk::startOfCluster} -body {
+ ::tk::startOfCluster é -1
+} -result {}
+test cluster-1.1 {::tk::startOfCluster} -body {
+ ::tk::startOfCluster é 0
+} -result 0
+test cluster-1.2 {::tk::startOfCluster} -constraints needsICU -body {
+ ::tk::startOfCluster é 1
+} -result 0
+test cluster-1.3 {::tk::startOfCluster} -constraints needsICU -body {
+ ::tk::startOfCluster é 2
+} -result 2
+test cluster-1.4 {::tk::startOfCluster} -constraints needsICU -body {
+ ::tk::startOfCluster é 3
+} -result 2
+test cluster-1.5 {::tk::startOfCluster} -constraints needsICU -body {
+ ::tk::startOfCluster é end
+} -result 0
+test cluster-1.6 {::tk::startOfCluster} -body {
+ ::tk::startOfCluster é {}
+} -result {}
+test cluster-1.7 {::tk::startOfCluster} -constraints needsICU -body {
+ ::tk::startOfCluster é end-1
+} -result 0
+
+test cluster-2.0 {::tk::endOfCluster} -body {
+ ::tk::endOfCluster é -1
+} -result 0
+test cluster-2.1 {::tk::endOfCluster} -constraints needsICU -body {
+ ::tk::endOfCluster é 0
+} -result 2
+test cluster-2.2 {::tk::endOfCluster} -constraints needsICU -body {
+ ::tk::endOfCluster é 1
+} -result 2
+test cluster-2.3 {::tk::endOfCluster} -body {
+ ::tk::endOfCluster é 2
+} -result {}
+test cluster-2.4 {::tk::endOfCluster} -body {
+ ::tk::endOfCluster é 3
+} -result {}
+test cluster-2.5 {::tk::endOfCluster} -constraints needsICU -body {
+ ::tk::endOfCluster é end
+} -result 2
+test cluster-2.6 {::tk::endOfCluster} -body {
+ ::tk::endOfCluster é {}
+} -result 0
+test cluster-2.7 {::tk::endOfCluster} -constraints needsICU -body {
+ ::tk::endOfCluster é end-1
+} -result 2
+
+test cluster-3.0 {::tk::endOfWord} -body {
+ ::tk::endOfWord "ab cd" -1
+} -result 2
+test cluster-3.1 {::tk::endOfWord} -body {
+ ::tk::endOfWord "ab cd" 0
+} -result 2
+test cluster-3.2 {::tk::endOfWord} -body {
+ ::tk::endOfWord "ab cd" 1
+} -result 2
+test cluster-3.3 {::tk::endOfWord} -body {
+ ::tk::endOfWord "ab cd" 2
+} -result {}
+test cluster-3.4 {::tk::endOfWord} -body {
+ ::tk::endOfWord "ab cd" 3
+} -result {}
+test cluster-3.5 {::tk::endOfWord} -body {
+ ::tk::endOfWord "ab cd" 4
+} -result {}
+test cluster-3.6 {::tk::endOfWord} -body {
+ ::tk::endOfWord "ab cd" 5
+} -result {}
+test cluster-3.7 {::tk::endOfWord} -body {
+ ::tk::endOfWord "ab cd" end
+} -result {}
+test cluster-3.8 {::tk::endOfWord} -body {
+ ::tk::endOfWord "ab cd" {}
+} -result 2
+test cluster-3.9 {::tk::endOfWord} -body {
+ ::tk::endOfWord "ab cd" end-1
+} -result {}
+
+test cluster-4.0 {::tk::startOfPreviousWord} -body {
+ ::tk::startOfPreviousWord "ab cd" -1
+} -result {}
+test cluster-4.1 {::tk::startOfPreviousWord} -body {
+ ::tk::startOfPreviousWord "ab cd" 0
+} -result {}
+test cluster-4.2 {::tk::startOfPreviousWord} -body {
+ ::tk::startOfPreviousWord "ab cd" 1
+} -result 0
+test cluster-4.3 {::tk::startOfPreviousWord} -body {
+ ::tk::startOfPreviousWord "ab cd" 2
+} -result 0
+test cluster-4.4 {::tk::startOfPreviousWord} -body {
+ ::tk::startOfPreviousWord "ab cd" 3
+} -result 0
+test cluster-4.5 {::tk::startOfPreviousWord} -body {
+ ::tk::startOfPreviousWord "ab cd" 4
+} -result 3
+test cluster-4.6 {::tk::startOfPreviousWord} -body {
+ ::tk::startOfPreviousWord "ab cd" 5
+} -result 3
+test cluster-4.7 {::tk::startOfPreviousWord} -body {
+ ::tk::startOfPreviousWord "ab cd" end
+} -result 3
+test cluster-4.8 {::tk::startOfPreviousWord} -body {
+ ::tk::startOfPreviousWord "ab cd" {}
+} -result {}
+test cluster-4.9 {::tk::startOfPreviousWord} -constraints needsTcl87 -body {
+ ::tk::startOfPreviousWord "ab cd" end-1
+} -result 0
+
+test cluster-5.0 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord "ab cd" -1
+} -result 3
+test cluster-5.1 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord "ab cd" 0
+} -result 3
+test cluster-5.2 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord "ab cd" 1
+} -result 3
+test cluster-5.3 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord "ab cd" 2
+} -result 3
+test cluster-5.4 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord "ab cd" 3
+} -result {}
+test cluster-5.5 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord "ab cd" 4
+} -result {}
+test cluster-5.6 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord "ab cd" 5
+} -result {}
+test cluster-5.7 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord "ab cd" end
+} -result {}
+test cluster-5.8 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord "ab cd" {}
+} -result 3
+test cluster-5.9 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord "ab cd" end-1
+} -result {}
+
+test cluster-6.0 {::tk::wordBreakBefore} -body {
+ ::tk::wordBreakBefore "ab cd" -1
+} -result {}
+test cluster-6.1 {::tk::wordBreakBefore} -body {
+ ::tk::wordBreakBefore "ab cd" 0
+} -result {}
+test cluster-6.2 {::tk::wordBreakBefore} -body {
+ ::tk::wordBreakBefore "ab cd" 1
+} -result {}
+test cluster-6.3 {::tk::wordBreakBefore} -body {
+ ::tk::wordBreakBefore "ab cd" 2
+} -result 2
+test cluster-6.4 {::tk::wordBreakBefore} -body {
+ ::tk::wordBreakBefore "ab cd" 3
+} -result 3
+test cluster-6.5 {::tk::wordBreakBefore} -body {
+ ::tk::wordBreakBefore "ab cd" 4
+} -result 3
+test cluster-6.6 {::tk::wordBreakBefore} -body {
+ ::tk::wordBreakBefore "ab cd" 5
+} -result 3
+test cluster-6.7 {::tk::wordBreakBefore} -body {
+ ::tk::wordBreakBefore "ab cd" end
+} -result 3
+test cluster-6.8 {::tk::wordBreakBefore} -body {
+ ::tk::wordBreakBefore "ab cd" {}
+} -result {}
+test cluster-6.9 {::tk::wordBreakBefore} -body {
+ ::tk::startOfNextWord "ab cd" end-1
+} -result {}
+
+test cluster-7.0 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter "ab cd" -1
+} -result 2
+test cluster-7.1 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter "ab cd" 0
+} -result 2
+test cluster-7.2 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter "ab cd" 1
+} -result 2
+test cluster-7.3 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter "ab cd" 2
+} -result 3
+test cluster-7.4 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter "ab cd" 3
+} -result {}
+test cluster-7.5 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter "ab cd" 4
+} -result {}
+test cluster-7.6 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter "ab cd" 5
+} -result {}
+test cluster-7.7 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter "ab cd" end
+} -result {}
+test cluster-7.8 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter "ab cd" {}
+} -result 2
+test cluster-7.9 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter "ab cd" end-1
+} -result {}
+
+
+test cluster-8.0 {::tk::startOfCluster} -body {
+ ::tk::startOfCluster a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::startOfCluster str start ?locale?"}
+test cluster-8.1 {::tk::endOfCluster} -body {
+ ::tk::endOfCluster a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::endOfCluster str start ?locale?"}
+test cluster-8.2 {::tk::startOfPreviousWord} -body {
+ ::tk::startOfPreviousWord a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::startOfPreviousWord str start ?locale?"}
+test cluster-8.3 {::tk::startOfNextWord} -body {
+ ::tk::startOfNextWord a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::startOfNextWord str start ?locale?"}
+test cluster-8.4 {::tk::endOfWord} -body {
+ ::tk::endOfWord a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::endOfWord str start ?locale?"}
+test cluster-8.5 {::tk::wordBreakBefore} -body {
+ ::tk::wordBreakBefore a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::wordBreakBefore str start ?locale?"}
+test cluster-8.6 {::tk::wordBreakAfter} -body {
+ ::tk::wordBreakAfter a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::wordBreakAfter str start ?locale?"}
+
+cleanupTests
+return