aboutsummaryrefslogtreecommitdiff
path: root/tests/core/encoding
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2023-05-22 17:22:33 +0200
committerLaytan Laats <laytanlaats@hotmail.com>2023-05-22 17:22:33 +0200
commit5d54b710e7b90734ed352648c5c099b4e5d0701e (patch)
tree0f4e196b8f5502ac4e619928649529b79c3d0f36 /tests/core/encoding
parent118ab60588832904e6a980c712702f71b4f7ec15 (diff)
fix #2550 json encoding should use surrogate pairs per RFC7159
Diffstat (limited to 'tests/core/encoding')
-rw-r--r--tests/core/encoding/json/test_core_json.odin16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/core/encoding/json/test_core_json.odin b/tests/core/encoding/json/test_core_json.odin
index 0e6a6412f..937d1c738 100644
--- a/tests/core/encoding/json/test_core_json.odin
+++ b/tests/core/encoding/json/test_core_json.odin
@@ -32,6 +32,7 @@ main :: proc() {
parse_json(&t)
marshal_json(&t)
unmarshal_json(&t)
+ surrogate(&t)
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
if TEST_fail > 0 {
@@ -344,4 +345,17 @@ unmarshal_json :: proc(t: ^testing.T) {
for p, i in g.products {
expect(t, p == original_data.products[i], "Producted unmarshaled improperly")
}
-} \ No newline at end of file
+}
+
+@test
+surrogate :: proc(t: ^testing.T) {
+ input := `+ + * 😃 - /`
+
+ out, err := json.marshal(input)
+ expect(t, err == nil, fmt.tprintf("Expected `json.marshal(%q)` to return a nil error, got %v", input, err))
+
+ back: string
+ uerr := json.unmarshal(out, &back)
+ expect(t, uerr == nil, fmt.tprintf("Expected `json.unmarshal(%q)` to return a nil error, got %v", string(out), uerr))
+ expect(t, back == input, fmt.tprintf("Expected `json.unmarshal(%q)` to return %q, got %v", string(out), input, uerr))
+}