Lines Matching refs:js
35 #define TOKEN_STRING(js, t, s) \ argument
36 (strncmp(js+(t).start, s, (t).end - (t).start) == 0 \
47 const char *js; in test_empty() local
52 js = "{}"; in test_empty()
54 r = jsmn_parse(&p, js, strlen(js), t, 10); in test_empty()
59 js = "[]"; in test_empty()
61 r = jsmn_parse(&p, js, strlen(js), t, 10); in test_empty()
66 js = "{\"a\":[]}"; in test_empty()
68 r = jsmn_parse(&p, js, strlen(js), t, 10); in test_empty()
74 js = "[{},{}]"; in test_empty()
76 r = jsmn_parse(&p, js, strlen(js), t, 10); in test_empty()
85 const char *js; in test_simple() local
90 js = "{\"a\": 0}"; in test_simple()
93 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_simple()
99 check(TOKEN_STRING(js, tokens[0], js)); in test_simple()
100 check(TOKEN_STRING(js, tokens[1], "a")); in test_simple()
101 check(TOKEN_STRING(js, tokens[2], "0")); in test_simple()
104 js = "[\"a\":{},\"b\":{}]"; in test_simple()
105 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_simple()
109 js = "{\n \"Day\": 26,\n \"Month\": 9,\n \"Year\": 12\n }"; in test_simple()
110 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_simple()
121 const char *js; in test_primitive() local
122 js = "\"boolVar\" : true"; in test_primitive()
124 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_primitive()
127 check(TOKEN_STRING(js, tok[0], "boolVar")); in test_primitive()
128 check(TOKEN_STRING(js, tok[1], "true")); in test_primitive()
130 js = "\"boolVar\" : false"; in test_primitive()
132 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_primitive()
135 check(TOKEN_STRING(js, tok[0], "boolVar")); in test_primitive()
136 check(TOKEN_STRING(js, tok[1], "false")); in test_primitive()
138 js = "\"intVar\" : 12345"; in test_primitive()
140 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_primitive()
143 check(TOKEN_STRING(js, tok[0], "intVar")); in test_primitive()
144 check(TOKEN_STRING(js, tok[1], "12345")); in test_primitive()
146 js = "\"floatVar\" : 12.345"; in test_primitive()
148 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_primitive()
151 check(TOKEN_STRING(js, tok[0], "floatVar")); in test_primitive()
152 check(TOKEN_STRING(js, tok[1], "12.345")); in test_primitive()
154 js = "\"nullVar\" : null"; in test_primitive()
156 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_primitive()
159 check(TOKEN_STRING(js, tok[0], "nullVar")); in test_primitive()
160 check(TOKEN_STRING(js, tok[1], "null")); in test_primitive()
169 const char *js; in test_string() local
171 js = "\"strVar\" : \"hello world\""; in test_string()
173 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_string()
176 check(TOKEN_STRING(js, tok[0], "strVar")); in test_string()
177 check(TOKEN_STRING(js, tok[1], "hello world")); in test_string()
179 js = "\"strVar\" : \"escapes: \\/\\r\\n\\t\\b\\f\\\"\\\\\""; in test_string()
181 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_string()
184 check(TOKEN_STRING(js, tok[0], "strVar")); in test_string()
185 check(TOKEN_STRING(js, tok[1], "escapes: \\/\\r\\n\\t\\b\\f\\\"\\\\")); in test_string()
187 js = "\"strVar\" : \"\""; in test_string()
189 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_string()
192 check(TOKEN_STRING(js, tok[0], "strVar")); in test_string()
193 check(TOKEN_STRING(js, tok[1], "")); in test_string()
202 const char *js; in test_partial_string() local
205 js = "\"x\": \"va"; in test_partial_string()
206 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_partial_string()
208 check(TOKEN_STRING(js, tok[0], "x")); in test_partial_string()
221 js = "\"x\": \"valu"; in test_partial_string()
222 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_partial_string()
224 check(TOKEN_STRING(js, tok[0], "x")); in test_partial_string()
227 js = "\"x\": \"value\""; in test_partial_string()
228 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_partial_string()
231 check(TOKEN_STRING(js, tok[0], "x")); in test_partial_string()
232 check(TOKEN_STRING(js, tok[1], "value")); in test_partial_string()
234 js = "\"x\": \"value\", \"y\": \"value y\""; in test_partial_string()
235 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_partial_string()
239 check(TOKEN_STRING(js, tok[0], "x")); in test_partial_string()
240 check(TOKEN_STRING(js, tok[1], "value")); in test_partial_string()
241 check(TOKEN_STRING(js, tok[2], "y")); in test_partial_string()
242 check(TOKEN_STRING(js, tok[3], "value y")); in test_partial_string()
252 const char *js; in test_unquoted_keys() local
255 js = "key1: \"value\"\nkey2 : 123"; in test_unquoted_keys()
257 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_unquoted_keys()
261 check(TOKEN_STRING(js, tok[0], "key1")); in test_unquoted_keys()
262 check(TOKEN_STRING(js, tok[1], "value")); in test_unquoted_keys()
263 check(TOKEN_STRING(js, tok[2], "key2")); in test_unquoted_keys()
264 check(TOKEN_STRING(js, tok[3], "123")); in test_unquoted_keys()
273 const char *js; in test_partial_array() local
276 js = " [ 1, true, "; in test_partial_array()
277 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_partial_array()
281 js = " [ 1, true, [123, \"hello"; in test_partial_array()
282 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_partial_array()
287 js = " [ 1, true, [123, \"hello\"]"; in test_partial_array()
288 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_partial_array()
296 js = " [ 1, true, [123, \"hello\"]]"; in test_partial_array()
297 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_partial_array()
312 const char *js; in test_array_nomem() local
314 js = " [ 1, true, [123, \"hello\"]]"; in test_array_nomem()
320 r = jsmn_parse(&p, js, strlen(js), toksmall, i); in test_array_nomem()
325 r = jsmn_parse(&p, js, strlen(js), toklarge, 10); in test_array_nomem()
338 const char *js; in test_objects_arrays() local
340 js = "[10}"; in test_objects_arrays()
342 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_objects_arrays()
345 js = "[10]"; in test_objects_arrays()
347 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_objects_arrays()
350 js = "{\"a\": 1]"; in test_objects_arrays()
352 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_objects_arrays()
355 js = "{\"a\": 1}"; in test_objects_arrays()
357 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_objects_arrays()
367 const char *js; in test_issue_22() local
369 js = "{ \"height\":10, \"layers\":[ { \"data\":[6,6], \"height\":10, " in test_issue_22()
378 r = jsmn_parse(&p, js, strlen(js), tokens, 128); in test_issue_22()
383 printf("%.*s\n", tokens[i].end - tokens[i].start, js + tokens[i].start); in test_issue_22()
399 const char *js; in test_unicode_characters() local
402 js = "{\"a\":\"\\uAbcD\"}"; in test_unicode_characters()
404 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_unicode_characters()
407 js = "{\"a\":\"str\\u0000\"}"; in test_unicode_characters()
409 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_unicode_characters()
412 js = "{\"a\":\"\\uFFFFstr\"}"; in test_unicode_characters()
414 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_unicode_characters()
417 js = "{\"a\":\"str\\uFFGFstr\"}"; in test_unicode_characters()
419 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_unicode_characters()
422 js = "{\"a\":\"str\\u@FfF\"}"; in test_unicode_characters()
424 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_unicode_characters()
427 js = "{\"a\":[\"\\u028\"]}"; in test_unicode_characters()
429 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_unicode_characters()
432 js = "{\"a\":[\"\\u0280\"]}"; in test_unicode_characters()
434 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_unicode_characters()
441 const char *js; in test_input_length() local
446 js = "{\"a\": 0}garbage"; in test_input_length()
449 r = jsmn_parse(&p, js, 8, tokens, 10); in test_input_length()
451 check(TOKEN_STRING(js, tokens[0], "{\"a\": 0}")); in test_input_length()
452 check(TOKEN_STRING(js, tokens[1], "a")); in test_input_length()
453 check(TOKEN_STRING(js, tokens[2], "0")); in test_input_length()
460 const char *js; in test_count() local
462 js = "{}"; in test_count()
464 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 1); in test_count()
466 js = "[]"; in test_count()
468 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 1); in test_count()
470 js = "[[]]"; in test_count()
472 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 2); in test_count()
474 js = "[[], []]"; in test_count()
476 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 3); in test_count()
478 js = "[[], []]"; in test_count()
480 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 3); in test_count()
482 js = "[[], [[]], [[], []]]"; in test_count()
484 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 7); in test_count()
486 js = "[\"a\", [[], []]]"; in test_count()
488 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 5); in test_count()
490 js = "[[], \"[], [[]]\", [[]]]"; in test_count()
492 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 5); in test_count()
494 js = "[1, 2, 3]"; in test_count()
496 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 4); in test_count()
498 js = "[1, 2, [3, \"a\"], null]"; in test_count()
500 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 7); in test_count()
506 const char *js; in test_keyvalue() local
511 js = "{\"a\": 0, \"b\": \"c\"}"; in test_keyvalue()
514 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_keyvalue()
520 js = "{\"a\"\n0}"; in test_keyvalue()
522 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_keyvalue()
525 js = "{\"a\", 0}"; in test_keyvalue()
527 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_keyvalue()
530 js = "{\"a\": {2}}"; in test_keyvalue()
532 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_keyvalue()
535 js = "{\"a\": {2: 3}}"; in test_keyvalue()
537 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_keyvalue()
541 js = "{\"a\": {\"a\": 2 3}}"; in test_keyvalue()
543 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_keyvalue()
571 const char *js; in test_nonstrict() local
576 js = "a: 0garbage"; in test_nonstrict()
579 r = jsmn_parse(&p, js, 4, tokens, 10); in test_nonstrict()
581 check(TOKEN_STRING(js, tokens[0], "a")); in test_nonstrict()
582 check(TOKEN_STRING(js, tokens[1], "0")); in test_nonstrict()
584 js = "Day : 26\nMonth : Sep\n\nYear: 12"; in test_nonstrict()
586 r = jsmn_parse(&p, js, strlen(js), tokens, 10); in test_nonstrict()