Sun, 26 Jan 2025 11:59:16 +0100
add missing test coverage for escape sequences
tests/test_json.c | file | annotate | diff | comparison | revisions |
--- 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); }