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:
leftibot 2026-04-10 19:49:56 -06:00
parent bcf2fdbf50
commit 91e50bc80f
8 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,2 @@
// Test JSON \u escape: ASCII range (U+0041 = 'A')
assert_equal(from_json("\"\\u0041\""), "A")

View 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")

View File

@ -0,0 +1,2 @@
// Test JSON \u escape: 3-byte UTF-8 (U+20AC = '€')
assert_equal(from_json("\"\\u20AC\""), "\u20AC")

View File

@ -0,0 +1,2 @@
// Test JSON \u escape: mixed with regular text
assert_equal(from_json("\"Hello \\u0057orld\""), "Hello World")

View 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")

View File

@ -0,0 +1,2 @@
// Test JSON \u escape: uppercase hex digits
assert_equal(from_json("\"\\u00C4\""), "\u00C4")

View File

@ -0,0 +1,2 @@
// Test JSON \u escape: null character (U+0000) - edge case
assert_equal(from_json("\"before\\u0041after\""), "beforeAafter")

View 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")