blob: eabe3df0a6580a97b74d26d094da0578f6d8b042 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# 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 [llength [info commands ::tcl::unsupported::icu::detect]]
namespace eval icu {
namespace path {::tcl::unsupported ::tcl::mathop}
test icu-detect-0 {Return list of ICU encodings} -constraints icu -body {
set encoders [icu detect]
list [in UTF-8 $encoders] [in ISO-8859-1 $encoders]
} -result {1 1}
test icu-detect-1 {Guess encoding} -constraints icu -body {
icu detect [readFile [info script]]
} -result ISO-8859-1
test icu-detect-2 {Get all possible encodings} -constraints icu -body {
set encodings [icu detect [readFile [info script]] -all]
list [in UTF-8 $encodings] [in ISO-8859-1 $encodings]
} -result {1 1}
test icu-detect-3 {error case} -constraints icu -returnCodes error -body {
icu detect gorp gorp gorp
} -result {wrong # args: should be "icu detect ?bytes ?-all??"}
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
lmap enc {utf-8 tis-620 shiftjis} {
icu tclToIcu $enc
}
} -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
icu tclToIcu dummy
} -result {}
test icu-tclToIcu-2 {error case} -constraints icu -returnCodes error -body {
icu tclToIcu gorp gorp
} -result {wrong # args: should be "icu tclToIcu tclName"}
test icu-icuToTcl-0 {Map ICU encoding} -constraints icu -body {
lmap enc {UTF-8 TIS-620 ibm-943_P15A-2003} {
icu icuToTcl $enc
}
} -result {utf-8 tis-620 cp932}
test icu-icuToTcl-1 {Map ICU encoding - no map} -constraints icu -body {
# Should not raise an error
icu icuToTcl dummy
} -result {}
test icu-icuToTcl-2 {error case} -constraints icu -returnCodes error -body {
icu icuToTcl gorp gorp
} -result {wrong # args: should be "icu icuToTcl icuName"}
}
namespace delete icu
::tcltest::cleanupTests
|