| 118 } |
118 } |
| 119 |
119 |
| 120 CX_TEST(test_json_escaped_strings) { |
120 CX_TEST(test_json_escaped_strings) { |
| 121 cxstring text = cx_str( |
121 cxstring text = cx_str( |
| 122 "{\n" |
122 "{\n" |
| 123 "\t\"object\":\"{\\n\\t\\\"object\\\":null\\n}\"}\"\n" |
123 "\t\"object\":\"{\\n\\t\\\"object\\\":null\\n}\",\n" |
| |
124 "\t\"ctrl-chars\":\"\\\\foo\\r\\nbar\\f*ring\\/ring*\\b\"\n" |
| 124 "}" |
125 "}" |
| 125 ); |
126 ); |
| 126 |
127 |
| 127 CxJson json; |
128 CxJson json; |
| 128 cxJsonInit(&json, NULL); |
129 cxJsonInit(&json, NULL); |
| 136 CX_TEST_ASSERT(cxJsonIsString(object)); |
137 CX_TEST_ASSERT(cxJsonIsString(object)); |
| 137 CX_TEST_ASSERT(0 == cx_strcmp( |
138 CX_TEST_ASSERT(0 == cx_strcmp( |
| 138 cxJsonAsCxString(object), |
139 cxJsonAsCxString(object), |
| 139 CX_STR("{\n\t\"object\":null\n}")) |
140 CX_STR("{\n\t\"object\":null\n}")) |
| 140 ); |
141 ); |
| 141 cxJsonValueFree(obj); |
142 CxJsonValue *ctrl = cxJsonObjGet(obj, "ctrl-chars"); |
| |
143 CX_TEST_ASSERT(cxJsonIsString(ctrl)); |
| |
144 CX_TEST_ASSERT(0 == cx_strcmp( |
| |
145 cxJsonAsCxString(ctrl), |
| |
146 CX_STR("\\foo\r\nbar\f*ring/ring*\b")) |
| |
147 ); |
| |
148 cxJsonValueFree(ctrl); |
| 142 } |
149 } |
| 143 cxJsonDestroy(&json); |
150 cxJsonDestroy(&json); |
| 144 } |
151 } |
| 145 |
152 |
| 146 CX_TEST(test_json_escaped_unicode_strings) { |
153 CX_TEST(test_json_escaped_unicode_strings) { |