# HG changeset patch # User Mike Becker # Date 1737889156 -3600 # Node ID afd12f31d28ae68799ea9f0521ba754f72ae744e # Parent 8e4f46349e238bb205e87df3b6b954f78a9fa94c add missing test coverage for escape sequences diff -r 8e4f46349e23 -r afd12f31d28a tests/test_json.c --- a/tests/test_json.c Sun Jan 26 11:28:50 2025 +0100 +++ b/tests/test_json.c Sun Jan 26 11:59:16 2025 +0100 @@ -120,7 +120,8 @@ CX_TEST(test_json_escaped_strings) { cxstring text = cx_str( "{\n" - "\t\"object\":\"{\\n\\t\\\"object\\\":null\\n}\"}\"\n" + "\t\"object\":\"{\\n\\t\\\"object\\\":null\\n}\",\n" + "\t\"ctrl-chars\":\"\\\\foo\\r\\nbar\\f*ring\\/ring*\\b\"\n" "}" ); @@ -138,7 +139,13 @@ cxJsonAsCxString(object), CX_STR("{\n\t\"object\":null\n}")) ); - cxJsonValueFree(obj); + CxJsonValue *ctrl = cxJsonObjGet(obj, "ctrl-chars"); + CX_TEST_ASSERT(cxJsonIsString(ctrl)); + CX_TEST_ASSERT(0 == cx_strcmp( + cxJsonAsCxString(ctrl), + CX_STR("\\foo\r\nbar\f*ring/ring*\b")) + ); + cxJsonValueFree(ctrl); } cxJsonDestroy(&json); }