mirror of
https://github.com/json-c/json-c.git
synced 2026-04-05 13:29:06 +08:00
update tsetcase for tokener_c
This commit is contained in:
@@ -85,6 +85,12 @@ static void test_basic_parse()
|
|||||||
single_basic_parse("True", 0);
|
single_basic_parse("True", 0);
|
||||||
single_basic_parse("False", 0);
|
single_basic_parse("False", 0);
|
||||||
|
|
||||||
|
/* not case sensitive */
|
||||||
|
single_basic_parse("tRue", 0);
|
||||||
|
single_basic_parse("fAlse", 0);
|
||||||
|
single_basic_parse("nAn", 0);
|
||||||
|
single_basic_parse("iNfinity", 0);
|
||||||
|
|
||||||
single_basic_parse("12", 0);
|
single_basic_parse("12", 0);
|
||||||
single_basic_parse("12.3", 0);
|
single_basic_parse("12.3", 0);
|
||||||
single_basic_parse("12.3.4", 0); /* non-sensical, returns null */
|
single_basic_parse("12.3.4", 0); /* non-sensical, returns null */
|
||||||
@@ -280,6 +286,7 @@ struct incremental_step {
|
|||||||
{ "1234", 5, 4, json_tokener_success, 1 },
|
{ "1234", 5, 4, json_tokener_success, 1 },
|
||||||
|
|
||||||
{ "Infinity9999", 8, 8, json_tokener_continue, 0 },
|
{ "Infinity9999", 8, 8, json_tokener_continue, 0 },
|
||||||
|
|
||||||
/* returns the Infinity loaded up by the previous call: */
|
/* returns the Infinity loaded up by the previous call: */
|
||||||
{ "1234", 5, 0, json_tokener_success, 0 },
|
{ "1234", 5, 0, json_tokener_success, 0 },
|
||||||
{ "1234", 5, 4, json_tokener_success, 1 },
|
{ "1234", 5, 4, json_tokener_success, 1 },
|
||||||
@@ -290,6 +297,7 @@ struct incremental_step {
|
|||||||
{ "naodle", 7, 2, json_tokener_error_parse_null, 1 },
|
{ "naodle", 7, 2, json_tokener_error_parse_null, 1 },
|
||||||
/* offset=2 because "tr" is the start of "true". hmm... */
|
/* offset=2 because "tr" is the start of "true". hmm... */
|
||||||
{ "track", 6, 2, json_tokener_error_parse_boolean, 1 },
|
{ "track", 6, 2, json_tokener_error_parse_boolean, 1 },
|
||||||
|
{ "fail", 5, 2, json_tokener_error_parse_boolean, 1 },
|
||||||
|
|
||||||
/* Although they may initially look like they should fail,
|
/* Although they may initially look like they should fail,
|
||||||
the next few tests check that parsing multiple sequential
|
the next few tests check that parsing multiple sequential
|
||||||
@@ -330,6 +338,13 @@ struct incremental_step {
|
|||||||
{ "[1,2,3}", -1, 6, json_tokener_error_parse_array, 1 },
|
{ "[1,2,3}", -1, 6, json_tokener_error_parse_array, 1 },
|
||||||
{ "{\"a\"}", -1, 4, json_tokener_error_parse_object_key_sep, 1 },
|
{ "{\"a\"}", -1, 4, json_tokener_error_parse_object_key_sep, 1 },
|
||||||
{ "{\"a\":1]", -1, 6, json_tokener_error_parse_object_value_sep, 1 },
|
{ "{\"a\":1]", -1, 6, json_tokener_error_parse_object_value_sep, 1 },
|
||||||
|
{ "{\"a\"::1}", -1, 5, json_tokener_error_parse_unexpected, 1 },
|
||||||
|
{ "{\"a\":}", -1, 5, json_tokener_error_parse_unexpected, 1 },
|
||||||
|
{ "{\"a\":1,\"a\":2}",-1, -1, json_tokener_success, 1 },
|
||||||
|
{ "\"a\":1}", -1, 3, json_tokener_success, 1 },
|
||||||
|
{ "{\"a\":1", -1, -1, json_tokener_continue, 1 },
|
||||||
|
{ "[,]", -1, 1, json_tokener_error_parse_unexpected, 1 },
|
||||||
|
{ "[,1]", -1, 1, json_tokener_error_parse_unexpected, 1 },
|
||||||
|
|
||||||
/* This behaviour doesn't entirely follow the json spec, but until we have
|
/* This behaviour doesn't entirely follow the json spec, but until we have
|
||||||
a way to specify how strict to be we follow Postel's Law and be liberal
|
a way to specify how strict to be we follow Postel's Law and be liberal
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ new_obj.to_string(-Infinoodle)=null
|
|||||||
new_obj.to_string(-InfinAAA)=null
|
new_obj.to_string(-InfinAAA)=null
|
||||||
new_obj.to_string(True)=true
|
new_obj.to_string(True)=true
|
||||||
new_obj.to_string(False)=false
|
new_obj.to_string(False)=false
|
||||||
|
new_obj.to_string(tRue)=true
|
||||||
|
new_obj.to_string(fAlse)=false
|
||||||
|
new_obj.to_string(nAn)=NaN
|
||||||
|
new_obj.to_string(iNfinity)=Infinity
|
||||||
new_obj.to_string(12)=12
|
new_obj.to_string(12)=12
|
||||||
new_obj.to_string(12.3)=12.3
|
new_obj.to_string(12.3)=12.3
|
||||||
new_obj.to_string(12.3.4)=null
|
new_obj.to_string(12.3.4)=null
|
||||||
@@ -144,6 +148,7 @@ json_tokener_parse_ex(tok, 1234 , 5) ... OK: got object of type [int]:
|
|||||||
json_tokener_parse_ex(tok, noodle , 7) ... OK: got correct error: null expected
|
json_tokener_parse_ex(tok, noodle , 7) ... OK: got correct error: null expected
|
||||||
json_tokener_parse_ex(tok, naodle , 7) ... OK: got correct error: null expected
|
json_tokener_parse_ex(tok, naodle , 7) ... OK: got correct error: null expected
|
||||||
json_tokener_parse_ex(tok, track , 6) ... OK: got correct error: boolean expected
|
json_tokener_parse_ex(tok, track , 6) ... OK: got correct error: boolean expected
|
||||||
|
json_tokener_parse_ex(tok, fail , 5) ... OK: got correct error: boolean expected
|
||||||
json_tokener_parse_ex(tok, null123 , 9) ... OK: got object of type [null]: null
|
json_tokener_parse_ex(tok, null123 , 9) ... OK: got object of type [null]: null
|
||||||
json_tokener_parse_ex(tok, 123 , 4) ... OK: got object of type [int]: 123
|
json_tokener_parse_ex(tok, 123 , 4) ... OK: got object of type [int]: 123
|
||||||
json_tokener_parse_ex(tok, nullx , 5) ... OK: got object of type [null]: null
|
json_tokener_parse_ex(tok, nullx , 5) ... OK: got object of type [null]: null
|
||||||
@@ -167,9 +172,16 @@ json_tokener_parse_ex(tok, [1,2,3] , 7) ... OK: got object of type [array]
|
|||||||
json_tokener_parse_ex(tok, [1,2,3} , 7) ... OK: got correct error: array value separator ',' expected
|
json_tokener_parse_ex(tok, [1,2,3} , 7) ... OK: got correct error: array value separator ',' expected
|
||||||
json_tokener_parse_ex(tok, {"a"} , 5) ... OK: got correct error: object property name separator ':' expected
|
json_tokener_parse_ex(tok, {"a"} , 5) ... OK: got correct error: object property name separator ':' expected
|
||||||
json_tokener_parse_ex(tok, {"a":1] , 7) ... OK: got correct error: object value separator ',' expected
|
json_tokener_parse_ex(tok, {"a":1] , 7) ... OK: got correct error: object value separator ',' expected
|
||||||
|
json_tokener_parse_ex(tok, {"a"::1} , 8) ... OK: got correct error: unexpected character
|
||||||
|
json_tokener_parse_ex(tok, {"a":} , 6) ... OK: got correct error: unexpected character
|
||||||
|
json_tokener_parse_ex(tok, {"a":1,"a":2}, 13) ... OK: got object of type [object]: { "a": 2 }
|
||||||
|
json_tokener_parse_ex(tok, "a":1} , 6) ... OK: got object of type [string]: "a"
|
||||||
|
json_tokener_parse_ex(tok, {"a":1 , 6) ... OK: got correct error: continue
|
||||||
|
json_tokener_parse_ex(tok, [,] , 3) ... OK: got correct error: unexpected character
|
||||||
|
json_tokener_parse_ex(tok, [,1] , 4) ... OK: got correct error: unexpected character
|
||||||
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,] , 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
|
json_tokener_parse_ex(tok, [1,2,,3,] , 9) ... OK: got correct error: unexpected character
|
||||||
json_tokener_parse_ex(tok, [1,2,3,] , 8) ... OK: got correct error: unexpected character
|
json_tokener_parse_ex(tok, [1,2,3,] , 8) ... OK: got correct error: unexpected character
|
||||||
json_tokener_parse_ex(tok, {"a":1,} , 8) ... OK: got correct error: unexpected character
|
json_tokener_parse_ex(tok, {"a":1,} , 8) ... OK: got correct error: unexpected character
|
||||||
End Incremental Tests OK=97 ERROR=0
|
End Incremental Tests OK=105 ERROR=0
|
||||||
==================================
|
==================================
|
||||||
|
|||||||
Reference in New Issue
Block a user