diff options
Diffstat (limited to 'tests/encoding.test')
| -rw-r--r-- | tests/encoding.test | 97 |
1 files changed, 80 insertions, 17 deletions
diff --git a/tests/encoding.test b/tests/encoding.test index 8a8f8c3..be504fb 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -321,11 +321,11 @@ test encoding-15.3 {UtfToUtfProc null character input} teststringbytes { binary scan [teststringbytes $y] H* z set z } c080 -test encoding-15.4 {UtfToUtfProc emoji character input} { +test encoding-15.4 {UtfToUtfProc emoji character input} -body { set x \xED\xA0\xBD\xED\xB8\x82 set y [encoding convertfrom utf-8 \xED\xA0\xBD\xED\xB8\x82] list [string length $x] $y -} "6 \U1F602" +} -result "6 \U1F602" test encoding-15.5 {UtfToUtfProc emoji character input} { set x \xF0\x9F\x98\x82 set y [encoding convertfrom utf-8 \xF0\x9F\x98\x82] @@ -335,8 +335,8 @@ test encoding-15.6 {UtfToUtfProc emoji character output} { set x \uDE02\uD83D\uDE02\uD83D set y [encoding convertto utf-8 \uDE02\uD83D\uDE02\uD83D] binary scan $y H* z - list [string length $x] [string length $y] $z -} {4 10 edb882f09f9882eda0bd} + list [string length $y] $z +} {10 edb882f09f9882eda0bd} test encoding-15.7 {UtfToUtfProc emoji character output} { set x \uDE02\uD83D\uD83D set y [encoding convertto utf-8 \uDE02\uD83D\uD83D] @@ -355,7 +355,43 @@ test encoding-15.9 {UtfToUtfProc emoji character output} { binary scan $y H* z list [string length $x] [string length $y] $z } {3 7 edb882eda0bd58} -test encoding-15.10 {UtfToUtfProc emoji character output} { +test encoding-15.10 {UtfToUtfProc high surrogate character output} { + set x \uDE02\xE9 + set y [encoding convertto utf-8 \uDE02\xE9] + binary scan $y H* z + list [string length $x] [string length $y] $z +} {2 5 edb882c3a9} +test encoding-15.11 {UtfToUtfProc low surrogate character output} { + set x \uDA02\xE9 + set y [encoding convertto utf-8 \uDA02\xE9] + binary scan $y H* z + list [string length $x] [string length $y] $z +} {2 5 eda882c3a9} +test encoding-15.12 {UtfToUtfProc high surrogate character output} { + set x \uDE02Y + set y [encoding convertto utf-8 \uDE02Y] + binary scan $y H* z + list [string length $x] [string length $y] $z +} {2 4 edb88259} +test encoding-15.13 {UtfToUtfProc low surrogate character output} { + set x \uDA02Y + set y [encoding convertto utf-8 \uDA02Y] + binary scan $y H* z + list [string length $x] [string length $y] $z +} {2 4 eda88259} +test encoding-15.14 {UtfToUtfProc high surrogate character output} { + set x \uDE02 + set y [encoding convertto utf-8 \uDE02] + binary scan $y H* z + list [string length $x] [string length $y] $z +} {1 3 edb882} +test encoding-15.15 {UtfToUtfProc low surrogate character output} { + set x \uDA02 + set y [encoding convertto utf-8 \uDA02] + binary scan $y H* z + list [string length $x] [string length $y] $z +} {1 3 eda882} +test encoding-15.16 {UtfToUtfProc emoji character output} { set x \U1F602 set y [encoding convertto utf-8 \U1F602] binary scan $y H* z @@ -365,26 +401,36 @@ test encoding-15.10 {UtfToUtfProc emoji character output} { test encoding-16.1 {Utf16ToUtfProc} -body { set val [encoding convertfrom utf-16 NN] list $val [format %x [scan $val %c]] -} -result "\u4e4e 4e4e" +} -result "\u4E4E 4e4e" test encoding-16.2 {Utf16ToUtfProc} -body { - set val [encoding convertfrom utf-16 "\xd8\xd8\xdc\xdc"] + set val [encoding convertfrom utf-16 "\xD8\xD8\xDC\xDC"] list $val [format %x [scan $val %c]] -} -result "\U460dc 460dc" -test encoding-16.3 {Ucs2ToUtfProc} -body { +} -result "\U460DC 460dc" +test encoding-16.3 {Utf16ToUtfProc} -body { + set val [encoding convertfrom utf-16 "\xDC\xDC"] + list $val [format %x [scan $val %c]] +} -result "\uDCDC dcdc" +test encoding-16.4 {Ucs2ToUtfProc} -body { set val [encoding convertfrom ucs-2 NN] list $val [format %x [scan $val %c]] -} -result "\u4e4e 4e4e" +} -result "\u4E4E 4e4e" test encoding-16.4 {Ucs2ToUtfProc} -body { - set val [encoding convertfrom ucs-2 "\xd8\xd8\xdc\xdc"] + set val [encoding convertfrom ucs-2 "\xD8\xD8\xDC\xDC"] list $val [format %x [scan $val %c]] -} -result "\U460dc 460dc" +} -result "\U460DC 460dc" test encoding-17.1 {UtfToUtf16Proc} -body { - encoding convertto utf-16 "\U460dc" -} -result "\xd8\xd8\xdc\xdc" -test encoding-17.2 {UtfToUcs2Proc} -body { - encoding convertfrom utf-16 [encoding convertto ucs-2 "\U460dc"] -} -result "\ufffd" + encoding convertto utf-16 "\U460DC" +} -result "\xD8\xD8\xDC\xDC" +test encoding-17.2 {UtfToUtf16Proc} -body { + encoding convertto utf-16 "\uDCDC" +} -result "\xDC\xDC" +test encoding-17.3 {UtfToUtf16Proc} -body { + encoding convertto utf-16 "\uD8D8" +} -result "\xD8\xD8" +test encoding-17.4 {UtfToUcs2Proc} -body { + encoding convertfrom utf-16 [encoding convertto ucs-2 "\U460DC"] +} -result "\uFFFD" test encoding-18.1 {TableToUtfProc} { } {} @@ -671,6 +717,23 @@ test encoding-27.2 {encoding dirs basic behavior} -returnCodes error -body { } -result "expected directory list but got \"\{not a list\"" } + + +test encoding-28.0 {all encodings load} -body { + set string hello + foreach name [encoding names] { + if {$name ne "unicode"} { + incr count + } + encoding convertto $name $string + + # discard the cached internal representation of Tcl_Encoding + # Unfortunately, without this, encoding 2-1 fails. + llength $name + } + return $count +} -result 85 + runtests } |
