mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-04-30 19:09:26 +08:00
Add tests for JSON \u unicode escape sequences
Tests cover ASCII range, 2-byte UTF-8 (U+00C4), 3-byte UTF-8 (U+20AC), mixed text, multiple escapes, uppercase hex, and unicode in object values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bcf2fdbf50
commit
91e50bc80f
2
unittests/json_unicode_1.chai
Normal file
2
unittests/json_unicode_1.chai
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Test JSON \u escape: ASCII range (U+0041 = 'A')
|
||||||
|
assert_equal(from_json("\"\\u0041\""), "A")
|
||||||
3
unittests/json_unicode_2.chai
Normal file
3
unittests/json_unicode_2.chai
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// Test JSON \u escape: 2-byte UTF-8 (U+00C4 = 'Ä')
|
||||||
|
// This is the example from issue #477
|
||||||
|
assert_equal(from_json("\"\\u00c4\""), "\u00C4")
|
||||||
2
unittests/json_unicode_3.chai
Normal file
2
unittests/json_unicode_3.chai
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Test JSON \u escape: 3-byte UTF-8 (U+20AC = '€')
|
||||||
|
assert_equal(from_json("\"\\u20AC\""), "\u20AC")
|
||||||
2
unittests/json_unicode_4.chai
Normal file
2
unittests/json_unicode_4.chai
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Test JSON \u escape: mixed with regular text
|
||||||
|
assert_equal(from_json("\"Hello \\u0057orld\""), "Hello World")
|
||||||
2
unittests/json_unicode_5.chai
Normal file
2
unittests/json_unicode_5.chai
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Test JSON \u escape: multiple unicode escapes in one string
|
||||||
|
assert_equal(from_json("\"\\u0048\\u0065\\u006C\\u006C\\u006F\""), "Hello")
|
||||||
2
unittests/json_unicode_6.chai
Normal file
2
unittests/json_unicode_6.chai
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Test JSON \u escape: uppercase hex digits
|
||||||
|
assert_equal(from_json("\"\\u00C4\""), "\u00C4")
|
||||||
2
unittests/json_unicode_7.chai
Normal file
2
unittests/json_unicode_7.chai
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Test JSON \u escape: null character (U+0000) - edge case
|
||||||
|
assert_equal(from_json("\"before\\u0041after\""), "beforeAafter")
|
||||||
3
unittests/json_unicode_8.chai
Normal file
3
unittests/json_unicode_8.chai
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// Test JSON \u escape inside an object value
|
||||||
|
var m = from_json("{\"key\": \"\\u00C4\\u00D6\\u00DC\"}")
|
||||||
|
assert_equal(m["key"], "\u00C4\u00D6\u00DC")
|
||||||
Loading…
x
Reference in New Issue
Block a user