|
|
@ -349,47 +349,47 @@ int test_objects_arrays() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int test_unicode_characters() {
|
|
|
|
int test_unicode_characters() {
|
|
|
|
jsmn_parser p;
|
|
|
|
jsmn_parser p;
|
|
|
|
jsmntok_t tokens[10];
|
|
|
|
jsmntok_t tokens[10];
|
|
|
|
const char *js;
|
|
|
|
const char *js;
|
|
|
|
|
|
|
|
|
|
|
|
int r;
|
|
|
|
int r;
|
|
|
|
js = "{\"a\":\"\\uAbcD\"}";
|
|
|
|
js = "{\"a\":\"\\uAbcD\"}";
|
|
|
|
jsmn_init(&p);
|
|
|
|
jsmn_init(&p);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
check(r == JSMN_SUCCESS);
|
|
|
|
check(r == JSMN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
|
|
js = "{\"a\":\"str\\u0000\"}";
|
|
|
|
js = "{\"a\":\"str\\u0000\"}";
|
|
|
|
jsmn_init(&p);
|
|
|
|
jsmn_init(&p);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
check(r == JSMN_SUCCESS);
|
|
|
|
check(r == JSMN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
|
|
js = "{\"a\":\"\\uFFFFstr\"}";
|
|
|
|
js = "{\"a\":\"\\uFFFFstr\"}";
|
|
|
|
jsmn_init(&p);
|
|
|
|
jsmn_init(&p);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
check(r == JSMN_SUCCESS);
|
|
|
|
check(r == JSMN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
|
|
js = "{\"a\":\"str\\uFFGFstr\"}";
|
|
|
|
js = "{\"a\":\"str\\uFFGFstr\"}";
|
|
|
|
jsmn_init(&p);
|
|
|
|
jsmn_init(&p);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
check(r == JSMN_ERROR_INVAL);
|
|
|
|
check(r == JSMN_ERROR_INVAL);
|
|
|
|
|
|
|
|
|
|
|
|
js = "{\"a\":\"str\\u@FfF\"}";
|
|
|
|
js = "{\"a\":\"str\\u@FfF\"}";
|
|
|
|
jsmn_init(&p);
|
|
|
|
jsmn_init(&p);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
check(r == JSMN_ERROR_INVAL);
|
|
|
|
check(r == JSMN_ERROR_INVAL);
|
|
|
|
|
|
|
|
|
|
|
|
js = "{\"a\":[\"\\u028\"]}";
|
|
|
|
js = "{\"a\":[\"\\u028\"]}";
|
|
|
|
jsmn_init(&p);
|
|
|
|
jsmn_init(&p);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
check(r == JSMN_ERROR_INVAL);
|
|
|
|
check(r == JSMN_ERROR_INVAL);
|
|
|
|
|
|
|
|
|
|
|
|
js = "{\"a\":[\"\\u0280\"]}";
|
|
|
|
js = "{\"a\":[\"\\u0280\"]}";
|
|
|
|
jsmn_init(&p);
|
|
|
|
jsmn_init(&p);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
r = jsmn_parse(&p, js, tokens, 10);
|
|
|
|
check(r == JSMN_SUCCESS);
|
|
|
|
check(r == JSMN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
int main() {
|
|
|
@ -402,7 +402,7 @@ int main() {
|
|
|
|
test(test_array_nomem, "test array reading with a smaller number of tokens");
|
|
|
|
test(test_array_nomem, "test array reading with a smaller number of tokens");
|
|
|
|
test(test_unquoted_keys, "test unquoted keys (like in JavaScript)");
|
|
|
|
test(test_unquoted_keys, "test unquoted keys (like in JavaScript)");
|
|
|
|
test(test_objects_arrays, "test objects and arrays");
|
|
|
|
test(test_objects_arrays, "test objects and arrays");
|
|
|
|
test(test_unicode_characters, "test unicode characters");
|
|
|
|
test(test_unicode_characters, "test unicode characters");
|
|
|
|
printf("\nPASSED: %d\nFAILED: %d\n", test_passed, test_failed);
|
|
|
|
printf("\nPASSED: %d\nFAILED: %d\n", test_passed, test_failed);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|