summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2024-06-20 07:42:38 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2024-06-20 07:42:38 (GMT)
commit2de684d18bf96b3de8c6e42f5aafbdb832096475 (patch)
tree7df83948e28a984896ea6d3839f489bcbe43a681
parentffc7a3702f13883ee95a09b3cd99138b70055c0f (diff)
downloadtcl-2de684d18bf96b3de8c6e42f5aafbdb832096475.zip
tcl-2de684d18bf96b3de8c6e42f5aafbdb832096475.tar.gz
tcl-2de684d18bf96b3de8c6e42f5aafbdb832096475.tar.bz2
Add basic tests
-rw-r--r--tests/icu.test51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/icu.test b/tests/icu.test
new file mode 100644
index 0000000..3f5ed0e
--- /dev/null
+++ b/tests/icu.test
@@ -0,0 +1,51 @@
+# Tests for tcl::unsupported::icu
+
+if {"::tcltest" ni [namespace children]} {
+ package require tcltest
+ namespace import -force ::tcltest::*
+}
+
+# Force late loading of ICU if present
+catch {::tcl::unsupported::icu}
+testConstraint icu [expr {[info commands ::tcl::unsupported::icu] ne ""}]
+
+namespace eval icu {
+ test icu-detect-0 {Return list of ICU encodings} -constraints icu -body {
+ set encoders [::tcl::unsupported::icu detect]
+ list [::tcl::mathop::in UTF-8 $encoders] [::tcl::mathop::in ISO-8859-1 $encoders]
+ } -result {1 1}
+
+ test icu-detect-1 {Guess encoding} -constraints icu -body {
+ ::tcl::unsupported::icu detect [readFile [info script]]
+ } -result ISO-8859-1
+
+ test icu-detect-2 {Get all possible encodings} -constraints icu -body {
+ set encodings [::tcl::unsupported::icu detect [readFile [info script]] -all]
+ list [::tcl::mathop::in UTF-8 $encodings] [::tcl::mathop::in ISO-8859-1 $encodings]
+ } -result {1 1}
+
+ test icu-tclToIcu-0 {Map Tcl encoding} -constraints icu -body {
+ # tis-620 because it is ambiguous in ICU on some platforms
+ # but should return the preferred encoding
+ list [::tcl::unsupported::icu tclToIcu utf-8] [::tcl::unsupported::icu tclToIcu tis-620] [::tcl::unsupported::icu tclToIcu shiftjis]
+ } -result {UTF-8 TIS-620 ibm-943_P15A-2003}
+
+ test icu-tclToIcu-1 {Map Tcl encoding - no map} -constraints icu -body {
+ # Should not raise an error
+ ::tcl::unsupported::icu tclToIcu dummy
+ } -result {}
+
+ test icu-icuToTcl-0 {Map ICU encoding} -constraints icu -body {
+ list [::tcl::unsupported::icu icuToTcl UTF-8] [::tcl::unsupported::icu icuToTcl TIS-620] [::tcl::unsupported::icu icuToTcl ibm-943_P15A-2003]
+ } -result {utf-8 tis-620 cp932}
+
+ test icu-icuToTcl-1 {Map ICU encoding - no map} -constraints icu -body {
+ # Should not raise an error
+ ::tcl::unsupported::icu icuToTcl dummy
+ } -result {}
+
+}
+
+
+namespace delete icu
+::tcltest::cleanupTests