--- a/tests/test_json.c Sat Jan 25 16:27:48 2025 +0100 +++ b/tests/test_json.c Sun Jan 26 10:23:32 2025 +0100 @@ -149,7 +149,10 @@ "\"ascii\":\"\\u0041\\u0053\\u0043\\u0049\\u0049\",\n" "\"unicode\":\"\\u00df\\u00DF\",\n" "\"mixed\":\"mixed ä ö \\u00e4 \\u00f6\",\n" - "\"wide\":\"\\u03a3\\u29b0\"" + "\"wide\":\"\\u03a3\\u29b0\",\n" + "\"surrogatepair1\":\"\\ud83e\\udff5\",\n" + "\"surrogatepair2\":\"test\\ud83e\\udff1AA\"\n," + "\"mixed2\":\"123\\u03a3\\ud83e\\udfc5\\u00df\"" "}" ); @@ -190,6 +193,27 @@ CX_STR("\u03a3\u29b0")) ); + CxJsonValue *surrogatepair1 = cxJsonObjGet(obj, "surrogatepair1"); + CX_TEST_ASSERT(cxJsonIsString(surrogatepair1)); + CX_TEST_ASSERT(0 == cx_strcmp( + cxJsonAsCxString(surrogatepair1), + CX_STR("\xf0\x9f\xaf\xb5")) + ); + + CxJsonValue *surrogatepair2 = cxJsonObjGet(obj, "surrogatepair2"); + CX_TEST_ASSERT(cxJsonIsString(surrogatepair2)); + CX_TEST_ASSERT(0 == cx_strcmp( + cxJsonAsCxString(surrogatepair2), + CX_STR("test\xf0\x9f\xaf\xb1" "AA")) + ); + + CxJsonValue *mixed2 = cxJsonObjGet(obj, "mixed2"); + CX_TEST_ASSERT(cxJsonIsString(mixed2)); + CX_TEST_ASSERT(0 == cx_strcmp( + cxJsonAsCxString(mixed2), + CX_STR("123\u03a3\xf0\x9f\xaf\x85ß")) + ); + cxJsonValueFree(obj); } cxJsonDestroy(&json);