tests/test_json.c

changeset 1130
5bcb725119b6
parent 1123
2b83302d595a
equal deleted inserted replaced
1129:cc60b7d07912 1130:5bcb725119b6
959 CxBuffer buf; 959 CxBuffer buf;
960 cxBufferInit(&buf, NULL, 128, NULL, 0); 960 cxBufferInit(&buf, NULL, 128, NULL, 0);
961 CX_TEST_DO { 961 CX_TEST_DO {
962 cxJsonWrite(&buf, str, cxBufferWriteFunc, &writer); 962 cxJsonWrite(&buf, str, cxBufferWriteFunc, &writer);
963 CX_TEST_ASSERT(0 == cx_strcmp(cx_strn(buf.space, buf.size), 963 CX_TEST_ASSERT(0 == cx_strcmp(cx_strn(buf.space, buf.size),
964 CX_STR("\"hello\\tw\\u00c3\\u00b6rld\\r\\nthis is\\\\a \\\"string\\\"\\b in \\u0007 string\\f\""))); 964 CX_STR("\"hello\\twörld\\r\\nthis is\\\\a \\\"string\\\"\\b in \\u0007 string\\f\"")));
965 } 965 }
966 cxBufferDestroy(&buf); 966 cxBufferDestroy(&buf);
967 cxJsonValueFree(str); 967 cxJsonValueFree(str);
968 } 968 }
969 969
975 CxBuffer buf; 975 CxBuffer buf;
976 cxBufferInit(&buf, NULL, 128, NULL, 0); 976 cxBufferInit(&buf, NULL, 128, NULL, 0);
977 CX_TEST_DO { 977 CX_TEST_DO {
978 cxJsonWrite(&buf, obj, cxBufferWriteFunc, &writer); 978 cxJsonWrite(&buf, obj, cxBufferWriteFunc, &writer);
979 CX_TEST_ASSERT(0 == cx_strcmp(cx_strn(buf.space, buf.size), 979 CX_TEST_ASSERT(0 == cx_strcmp(cx_strn(buf.space, buf.size),
980 CX_STR("{\"hello\\tw\\u00c3\\u00b6rld\\r\\nthis is\\\\a \\\"string\\\"\\b in \\u0007 string\\f\":true}"))); 980 CX_STR("{\"hello\\twörld\\r\\nthis is\\\\a \\\"string\\\"\\b in \\u0007 string\\f\":true}")));
981 } 981 }
982 cxBufferDestroy(&buf); 982 cxBufferDestroy(&buf);
983 cxJsonValueFree(obj); 983 cxJsonValueFree(obj);
984 } 984 }
985 985

mercurial