diff options
author | Mattias Wadman <mattias.wadman@gmail.com> | 2023-07-02 16:48:07 +0200 |
---|---|---|
committer | Nico Williams <nico@cryptonector.com> | 2023-07-25 13:38:41 -0500 |
commit | a949745059ee61366a5d880c3b18d5d4db6524eb (patch) | |
tree | 4fb0a93cf93e99d098eae5f8eff37ef6c92b049d /tests | |
parent | a29ac81de117a6bad625bc4ff75bbb395a58f7d6 (diff) |
implode: Better invalid input validation and handling
Error on non-number and nan codepoint, would asserd before
Replace negative codepoint and surrogate range with unicode replacement character, would assert before
Fixes #1160
Diffstat (limited to 'tests')
-rw-r--r-- | tests/jq.test | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/jq.test b/tests/jq.test index 466d1850..95b51366 100644 --- a/tests/jq.test +++ b/tests/jq.test @@ -1914,3 +1914,14 @@ any(keys[]|tostring?;true) {"a":"1","b":"2","c":"3"} true + +# explode/implode +# test replacement character (65533) for outside codepoint range and 0xd800 (55296) - 0xdfff (57343) utf16 surrogate pair range +# 1.1 and 1.9 to test round down of non-ints +implode|explode +[-1,0,1,2,3,1114111,1114112,55295,55296,57343,57344,1.1,1.9] +[65533,0,1,2,3,1114111,65533,55295,65533,65533,57344,1,1] + +map(try implode catch .) +[123,["a"],[nan]] +["implode input must be an array","string (\"a\") can't be imploded, unicode codepoint needs to be numeric","number (null) can't be imploded, unicode codepoint needs to be numeric"] |