case 'n':
case 'r':
case 't':
+ case 'f':
if(c == 'b') printbuf_memappend_fast(tok->pb, "\b", 1);
else if(c == 'n') printbuf_memappend_fast(tok->pb, "\n", 1);
else if(c == 'r') printbuf_memappend_fast(tok->pb, "\r", 1);
else if(c == 't') printbuf_memappend_fast(tok->pb, "\t", 1);
+ else if(c == 'f') printbuf_memappend_fast(tok->pb, "\f", 1);
state = saved_state;
break;
case 'u':
/* Strings have a well defined end point, so we can stop at the quote */
{ "\"blue\"", -1, -1, json_tokener_success, 0 },
+ /* Check each of the escape sequences defined by the spec */
+ { "\"\\\"\"", -1, -1, json_tokener_success, 0 },
+ { "\"\\\\\"", -1, -1, json_tokener_success, 0 },
+ { "\"\\b\"", -1, -1, json_tokener_success, 0 },
+ { "\"\\f\"", -1, -1, json_tokener_success, 0 },
+ { "\"\\n\"", -1, -1, json_tokener_success, 0 },
+ { "\"\\r\"", -1, -1, json_tokener_success, 0 },
+ { "\"\\t\"", -1, -1, json_tokener_success, 0 },
+
{ "[1,2,3]", -1, -1, json_tokener_success, 0 },
/* This behaviour doesn't entirely follow the json spec, but until we have
num_error = 0;
printf("Starting incremental tests.\n");
+ printf("Note: quotes and backslashes seen in the output here are literal values passed\n");
+ printf(" to the parse functions. e.g. this is 4 characters: \"\\f\"\n");
string_to_parse = "{ \"foo"; /* } */
printf("json_tokener_parse(%s) ... ", string_to_parse);
json_tokener_parse_versbose() OK
==================================
Starting incremental tests.
+Note: quotes and backslashes seen in the output here are literal values passed
+ to the parse functions. e.g. this is 4 characters: "\f"
json_tokener_parse({ "foo) ... got error as expected
json_tokener_parse_ex(tok, { "foo": 123 }, 14) ... OK: got object of type [object]: { "foo": 123 }
json_tokener_parse_ex(tok, { "foo": 456 }, 14) ... OK: got object of type [object]: { "foo": 456 }
json_tokener_parse_ex(tok, 1 , 1) ... OK: got correct error: continue
json_tokener_parse_ex(tok, 2 , 2) ... OK: got object of type [int]: 12
json_tokener_parse_ex(tok, "blue" , 6) ... OK: got object of type [string]: "blue"
+json_tokener_parse_ex(tok, "\"" , 4) ... OK: got object of type [string]: "\""
+json_tokener_parse_ex(tok, "\\" , 4) ... OK: got object of type [string]: "\\"
+json_tokener_parse_ex(tok, "\b" , 4) ... OK: got object of type [string]: "\b"
+json_tokener_parse_ex(tok, "\f" , 4) ... OK: got object of type [string]: "\u000c"
+json_tokener_parse_ex(tok, "\n" , 4) ... OK: got object of type [string]: "\n"
+json_tokener_parse_ex(tok, "\r" , 4) ... OK: got object of type [string]: "\r"
+json_tokener_parse_ex(tok, "\t" , 4) ... OK: got object of type [string]: "\t"
json_tokener_parse_ex(tok, [1,2,3] , 7) ... OK: got object of type [array]: [ 1, 2, 3 ]
json_tokener_parse_ex(tok, [1,2,3,] , 8) ... OK: got object of type [array]: [ 1, 2, 3 ]
json_tokener_parse_ex(tok, [1,2,,3,] , 9) ... OK: got correct error: unexpected character
-End Incremental Tests OK=20 ERROR=0
+End Incremental Tests OK=27 ERROR=0
==================================