From 20fcf335945daf5dedf6f10f940026b681dd7f1b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 26 May 2021 14:10:30 +0000 Subject: More testcases regarding possible parse errors --- tests/encoding.test | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/encoding.test b/tests/encoding.test index 55ace7f..bdebad9 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -624,7 +624,7 @@ test encoding-24.18 {Parse valid or invalid utf-8} -constraints testbytestring - test encoding-24.19 {Parse valid or invalid utf-8} -constraints testbytestring -body { encoding convertto -stoponerror utf-8 [testbytestring "Z\xE0\x80xxxxxx"] } -result "Z\xC3\xA0\xE2\x82\xACxxxxxx" -test encoding-24.20 {Parse valid or invalid utf-8} -constraints testbytestring -body { +test encoding-24.20 {Parse valid or invalid utf-8} -body { encoding convertto -stoponerror utf-8 "ZX\uD800" } -returnCodes 1 -match glob -result "unexpected character at index 2: 'U+00D800'" test encoding-24.21 {Parse with -nothrow but without providing encoding} { @@ -633,6 +633,19 @@ test encoding-24.21 {Parse with -nothrow but without providing encoding} { test encoding-24.22 {Parse with -nothrow but without providing encoding} { string length [encoding convertto -nothrow "\x20"] } 1 +test encoding-24.23 {Syntax error, two encodings} -body { + encoding convertfrom iso8859-1 utf-8 "ZX\uD800" +} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nothrow|-stoponerror? ?encoding? data"} +test encoding-24.24 {Syntax error, two encodings} -body { + encoding convertto iso8859-1 utf-8 "ZX\uD800" +} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nothrow|-stoponerror? ?encoding? data"} +test encoding-24.25 {Syntax error, two options} -body { + encoding convertfrom -nothrow -stoponerror "ZX\uD800" +} -returnCodes 1 -result {unknown encoding "-stoponerror"} +test encoding-24.26 {Syntax error, two options} -body { + encoding convertto -nothrow -stoponerror "ZX\uD800" +} -returnCodes 1 -result {unknown encoding "-stoponerror"} + file delete [file join [temporaryDirectory] iso2022.txt] # -- cgit v0.12