Lines Matching full:js
104 const char *js = "{\"x\": \"va\\\\ue\", \"y\": \"value y\"}"; in test_partial_string() local
107 for (i = 1; i <= strlen(js); i++) { in test_partial_string()
108 r = jsmn_parse(&p, js, i, tok, sizeof(tok) / sizeof(tok[0])); in test_partial_string()
109 if (i == strlen(js)) { in test_partial_string()
111 check(tokeq(js, tok, 5, JSMN_OBJECT, -1, -1, 2, JSMN_STRING, "x", 1, in test_partial_string()
127 const char *js = "[ 1, true, [123, \"hello\"]]"; in test_partial_array() local
130 for (i = 1; i <= strlen(js); i++) { in test_partial_array()
131 r = jsmn_parse(&p, js, i, tok, sizeof(tok) / sizeof(tok[0])); in test_partial_array()
132 if (i == strlen(js)) { in test_partial_array()
134 check(tokeq(js, tok, 6, JSMN_ARRAY, -1, -1, 3, JSMN_PRIMITIVE, "1", in test_partial_array()
150 const char *js; in test_array_nomem() local
152 js = " [ 1, true, [123, \"hello\"]]"; in test_array_nomem()
158 r = jsmn_parse(&p, js, strlen(js), toksmall, i); in test_array_nomem()
163 r = jsmn_parse(&p, js, strlen(js), toklarge, 10); in test_array_nomem()
165 check(tokeq(js, toklarge, 4, JSMN_ARRAY, -1, -1, 3, JSMN_PRIMITIVE, "1", in test_array_nomem()
177 const char *js; in test_unquoted_keys() local
180 js = "key1: \"value\"\nkey2 : 123"; in test_unquoted_keys()
182 r = jsmn_parse(&p, js, strlen(js), tok, 10); in test_unquoted_keys()
184 check(tokeq(js, tok, 4, JSMN_PRIMITIVE, "key1", JSMN_STRING, "value", 0, in test_unquoted_keys()
194 const char *js; in test_issue_22() local
196 js = in test_issue_22()
208 r = jsmn_parse(&p, js, strlen(js), tokens, 128); in test_issue_22()
214 const char *js = in test_issue_27() local
216 check(parse(js, JSMN_ERROR_PART, 8)); in test_issue_27()
221 const char *js; in test_input_length() local
226 js = "{\"a\": 0}garbage"; in test_input_length()
229 r = jsmn_parse(&p, js, 8, tokens, 10); in test_input_length()
231 check(tokeq(js, tokens, 3, JSMN_OBJECT, -1, -1, 1, JSMN_STRING, "a", 1, in test_input_length()
238 const char *js; in test_count() local
240 js = "{}"; in test_count()
242 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 1); in test_count()
244 js = "[]"; in test_count()
246 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 1); in test_count()
248 js = "[[]]"; in test_count()
250 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 2); in test_count()
252 js = "[[], []]"; in test_count()
254 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 3); in test_count()
256 js = "[[], []]"; in test_count()
258 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 3); in test_count()
260 js = "[[], [[]], [[], []]]"; in test_count()
262 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 7); in test_count()
264 js = "[\"a\", [[], []]]"; in test_count()
266 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 5); in test_count()
268 js = "[[], \"[], [[]]\", [[]]]"; in test_count()
270 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 5); in test_count()
272 js = "[1, 2, 3]"; in test_count()
274 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 4); in test_count()
276 js = "[1, 2, [3, \"a\"], null]"; in test_count()
278 check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 7); in test_count()
285 const char *js; in test_nonstrict() local
286 js = "a: 0garbage"; in test_nonstrict()
287 check(parse(js, 2, 2, JSMN_PRIMITIVE, "a", JSMN_PRIMITIVE, "0garbage")); in test_nonstrict()
289 js = "Day : 26\nMonth : Sep\n\nYear: 12"; in test_nonstrict()
290 check(parse(js, 6, 6, JSMN_PRIMITIVE, "Day", JSMN_PRIMITIVE, "26", in test_nonstrict()
295 js = "\"key {1\": 1234"; in test_nonstrict()
296 check(parse(js, 2, 2, JSMN_STRING, "key {1", 1, JSMN_PRIMITIVE, "1234")); in test_nonstrict()
303 const char *js; in test_unmatched_brackets() local
304 js = "\"key 1\": 1234}"; in test_unmatched_brackets()
305 check(parse(js, JSMN_ERROR_INVAL, 2)); in test_unmatched_brackets()
306 js = "{\"key 1\": 1234"; in test_unmatched_brackets()
307 check(parse(js, JSMN_ERROR_PART, 3)); in test_unmatched_brackets()
308 js = "{\"key 1\": 1234}}"; in test_unmatched_brackets()
309 check(parse(js, JSMN_ERROR_INVAL, 3)); in test_unmatched_brackets()
310 js = "\"key 1\"}: 1234"; in test_unmatched_brackets()
311 check(parse(js, JSMN_ERROR_INVAL, 3)); in test_unmatched_brackets()
312 js = "{\"key {1\": 1234}"; in test_unmatched_brackets()
313 check(parse(js, 3, 3, JSMN_OBJECT, 0, 16, 1, JSMN_STRING, "key {1", 1, in test_unmatched_brackets()
315 js = "{\"key 1\":{\"key 2\": 1234}"; in test_unmatched_brackets()
316 check(parse(js, JSMN_ERROR_PART, 5)); in test_unmatched_brackets()
321 const char *js; in test_object_key() local
323 js = "{\"key\": 1}"; in test_object_key()
324 check(parse(js, 3, 3, JSMN_OBJECT, 0, 10, 1, JSMN_STRING, "key", 1, in test_object_key()
327 js = "{true: 1}"; in test_object_key()
328 check(parse(js, JSMN_ERROR_INVAL, 3)); in test_object_key()
329 js = "{1: 1}"; in test_object_key()
330 check(parse(js, JSMN_ERROR_INVAL, 3)); in test_object_key()
331 js = "{{\"key\": 1}: 2}"; in test_object_key()
332 check(parse(js, JSMN_ERROR_INVAL, 5)); in test_object_key()
333 js = "{[1,2]: 2}"; in test_object_key()
334 check(parse(js, JSMN_ERROR_INVAL, 5)); in test_object_key()