diff options
Diffstat (limited to 'tests/encoding.test')
-rw-r--r-- | tests/encoding.test | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/tests/encoding.test b/tests/encoding.test index 05d9918..651dcfe 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -22,8 +22,6 @@ catch { package require -exact tcl::test [info patchlevel] } -source [file join [file dirname [info script]] tcltests.tcl] - proc toutf {args} { variable x lappend x "toutf $args" @@ -42,6 +40,9 @@ testConstraint testbytestring [llength [info commands testbytestring]] testConstraint teststringbytes [llength [info commands teststringbytes]] testConstraint exec [llength [info commands exec]] testConstraint testgetencpath [llength [info commands testgetencpath]] +testConstraint fullutf [expr {[format %c 0x010000] ne "\uFFFD"}] +testConstraint utf32 [expr {[testConstraint fullutf] + && [string length [format %c 0x10000]] == 1}] # TclInitEncodingSubsystem is tested by the rest of this file # TclFinalizeEncodingSubsystem is not currently tested @@ -338,20 +339,20 @@ test encoding-15.3 {UtfToUtfProc null character input} teststringbytes { } c080 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] + set y [encoding convertfrom -nocomplain utf-8 \xED\xA0\xBD\xED\xB8\x82] list [string length $x] $y -} -result "6 😂" +} -result "6 \uD83D\uDE02" test encoding-15.5 {UtfToUtfProc emoji character input} { set x \xF0\x9F\x98\x82 set y [encoding convertfrom utf-8 \xF0\x9F\x98\x82] list [string length $x] $y } "4 😂" -test encoding-15.6 {UtfToUtfProc emoji character output} { +test encoding-15.6 {UtfToUtfProc emoji character output} utf32 { set x \uDE02\uD83D\uDE02\uD83D set y [encoding convertto -nocomplain utf-8 \uDE02\uD83D\uDE02\uD83D] binary scan $y H* z list [string length $y] $z -} {10 edb882f09f9882eda0bd} +} {12 edb882eda0bdedb882eda0bd} test encoding-15.7 {UtfToUtfProc emoji character output} { set x \uDE02\uD83D\uD83D set y [encoding convertto -nocomplain utf-8 \uDE02\uD83D\uD83D] @@ -541,9 +542,9 @@ test encoding-17.10 {Utf32ToUtfProc} -body { encoding convertfrom -nocomplain utf-32 "\xFF\xFF\xFF\xFF" } -result \uFFFD -test encoding-18.1 {TableToUtfProc on invalid input} -constraints deprecated -body { +test encoding-18.1 {TableToUtfProc on invalid input} -body { list [catch {encoding convertto jis0208 \\} res] $res -} -result {0 !)} +} -result {1 {unexpected character at index 0: 'U+00005C'}} test encoding-18.2 {TableToUtfProc on invalid input with -strict} -body { list [catch {encoding convertto -strict jis0208 \\} res] $res } -result {1 {unexpected character at index 0: 'U+00005C'}} @@ -693,16 +694,16 @@ test encoding-24.10 {Parse valid or invalid utf-8} { test encoding-24.11 {Parse valid or invalid utf-8} { string length [encoding convertfrom -nocomplain utf-8 "\xEF\xBF\xBF"] } 1 -test encoding-24.12 {Parse valid or invalid utf-8} -constraints deprecated -body { - encoding convertfrom utf-8 "\xC0\x81" -} -result \xC0\x81 -test encoding-24.13 {Parse valid or invalid utf-8} -constraints deprecated -body { - encoding convertfrom utf-8 "\xC1\xBF" -} -result \xC1\xBF +test encoding-24.12 {Parse valid or invalid utf-8} -body { + encoding convertfrom -strict utf-8 "\xC0\x81" +} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC0'} +test encoding-24.13 {Parse valid or invalid utf-8} -body { + encoding convertfrom -strict utf-8 "\xC1\xBF" +} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC1'} test encoding-24.14 {Parse valid or invalid utf-8} { string length [encoding convertfrom utf-8 "\xC2\x80"] } 1 -test encoding-24.15 {Parse valid or invalid utf-8} -constraints deprecated -body { +test encoding-24.15 {Parse valid or invalid utf-8} -body { encoding convertfrom utf-8 "Z\xE0\x80" } -result Z\xE0\x80 test encoding-24.16 {Parse valid or invalid utf-8} -constraints testbytestring -body { @@ -714,9 +715,9 @@ test encoding-24.17 {Parse valid or invalid utf-8} -constraints testbytestring - test encoding-24.18 {Parse valid or invalid utf-8} -constraints testbytestring -body { encoding convertto utf-8 [testbytestring "Z\xE0\x80xxxxxx"] } -result "Z\xC3\xA0\xE2\x82\xACxxxxxx" -test encoding-24.19 {Parse valid or invalid utf-8} -constraints deprecated -body { +test encoding-24.19 {Parse valid or invalid utf-8} -body { encoding convertto utf-8 "ZX\uD800" -} -result ZX\xED\xA0\x80 +} -returnCodes 1 -match glob -result "unexpected character at index 2: 'U+00D800'" test encoding-24.20 {Parse with -nocomplain but without providing encoding} { string length [encoding convertfrom -nocomplain "\x20"] } 1 @@ -762,7 +763,7 @@ test encoding-24.33 {Try to generate noncharacter with -strict} -body { test encoding-24.34 {Try to generate invalid utf-8 with -nocomplain} -body { encoding convertto -nocomplain utf-8 \uFFFF } -result \xEF\xBF\xBF -test encoding-24.35 {Parse invalid utf-8} -constraints deprecated -body { +test encoding-24.35 {Parse invalid utf-8} -constraints utf32 -body { encoding convertfrom utf-8 \xED\xA0\x80 } -result \uD800 test encoding-24.36 {Parse invalid utf-8 with -strict} -body { @@ -771,9 +772,9 @@ test encoding-24.36 {Parse invalid utf-8 with -strict} -body { test encoding-24.37 {Parse invalid utf-8 with -nocomplain} -body { encoding convertfrom -nocomplain utf-8 \xED\xA0\x80 } -result \uD800 -test encoding-24.38 {Try to generate invalid utf-8} -constraints deprecated -body { +test encoding-24.38 {Try to generate invalid utf-8} -body { encoding convertto utf-8 \uD800 -} -result \xED\xA0\x80 +} -returnCodes 1 -result {unexpected character at index 0: 'U+00D800'} test encoding-24.39 {Try to generate invalid utf-8 with -strict} -body { encoding convertto -strict utf-8 \uD800 } -returnCodes 1 -result {unexpected character at index 0: 'U+00D800'} |