diff options
author | Steve Bennett <steveb@workware.net.au> | 2019-11-27 23:09:34 +1100 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2019-11-30 08:14:35 +1000 |
commit | 5802d3f5e49737b761c93fceba1d169e0a26b763 (patch) | |
tree | 977d6f6cd757108a71a67a3f887831f01fd15811 /tests | |
parent | 0aa0fb4e3a38d38a49de9eb585d93d63a370dcf6 (diff) | |
download | jimtcl-5802d3f5e49737b761c93fceba1d169e0a26b763.zip jimtcl-5802d3f5e49737b761c93fceba1d169e0a26b763.tar.gz jimtcl-5802d3f5e49737b761c93fceba1d169e0a26b763.tar.bz2 |
string map and string compare now support embedded nulls
Reported-by: dbohdan <dbohdan@dbohdan.com>
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/string.test | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/string.test b/tests/string.test index b095f60..48451e4 100644 --- a/tests/string.test +++ b/tests/string.test @@ -116,6 +116,15 @@ test string-2.28 {string equal with length, unequal strings} { test string-2.29 {string equal with length, unequal strings} { string compare -length 2 ab abde } 0 +test string-2.30 {string compare - bytes vs chars} { + string compare abcd\u1000\u1100\u1200x abcd\u1000\u1100\u1200y +} -1 +test string-2.31 {string compare - embedded nulls} { + string compare ab\0ghi0 ab\0ghi1 +} -1 +test string-2.31 {string compare - embedded nulls, nocase} { + string compare -nocase ab\0ghi0 AB\0GHi1 +} -1 # only need a few tests on equal, since it uses the same code as # string compare, but just modifies the return output test string-3.1 {string equal} { @@ -521,6 +530,18 @@ test string-10.16 {string map, one pair case} { test string-10.17 {string map, one pair case} { string map {Ab 4321} aAbCaBaAbAbcAb } {a4321CaBa43214321c4321} +test string-10.18 {string map, nulls in string} { + string map {a bc} ade\0ghia\0jkl +} "bcde\0ghibc\0jkl" +test string-10.19 {string map, nulls in map source} { + string map {\0 bc} ade\0ghia\0jkl +} "adebcghiabcjkl" +test string-10.20 {string map, nulls in map dest} { + string map {a A\0A} adeghiajkl +} "A\0AdeghiA\0Ajkl" +test string-10.21 {string map, null bytes} { + string map "\u0000afternull #" foo\u0000afternull\u0000123456789bar +} foo#\u0000123456789bar test string-11.1 {string match, too few args} { list [catch {string match a} msg] |