add testcases of object and token

This commit is contained in:
chenguoping
2019-12-27 15:07:00 +08:00
parent d6b968dff7
commit 1446572997
6 changed files with 78 additions and 1 deletions

View File

@@ -3,7 +3,15 @@ new_obj.to_string(/* hello */"foo")="foo"
new_obj.to_string(// hello
"foo")="foo"
new_obj.to_string("foo"blue)="foo"
new_obj.to_string('foo')="foo"
new_obj.to_string("\u0041\u0042\u0043")="ABC"
new_obj.to_string("\u4e16\u754c\u00df")="世界ß"
new_obj.to_string("\u4E16")="世"
new_obj.to_string("\u4e1")=null
new_obj.to_string("\u4e1@")=null
new_obj.to_string("\ud840\u4e16")="<22>世"
new_obj.to_string("\ud840")="<22>"
new_obj.to_string("\udd27")="<22>"
new_obj.to_string([9,'\uDAD)=null
new_obj.to_string(null)=null
new_obj.to_string(NaN)=NaN
@@ -32,7 +40,9 @@ new_obj.to_string(12.3.4)=null
new_obj.to_string(2015-01-15)=null
new_obj.to_string(12.3xxx)=12.3
new_obj.to_string({"FoO" : -12.3E512})={ "FoO": -12.3E512 }
new_obj.to_string({"FoO" : -12.3e512})={ "FoO": -12.3e512 }
new_obj.to_string({"FoO" : -12.3E51.2})=null
new_obj.to_string({"FoO" : -12.3E512E12})=null
new_obj.to_string(["\n"])=[ "\n" ]
new_obj.to_string(["\nabc\n"])=[ "\nabc\n" ]
new_obj.to_string([null])=[ null ]
@@ -41,15 +51,19 @@ new_obj.to_string([false])=[ false ]
new_obj.to_string(["abc",null,"def",12])=[ "abc", null, "def", 12 ]
new_obj.to_string({})={ }
new_obj.to_string({ "foo": "bar" })={ "foo": "bar" }
new_obj.to_string({ 'foo': 'bar' })={ "foo": "bar" }
new_obj.to_string({ "foo": "bar", "baz": null, "bool0": true })={ "foo": "bar", "baz": null, "bool0": true }
new_obj.to_string({ "foo": [null, "foo"] })={ "foo": [ null, "foo" ] }
new_obj.to_string({ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "arr": [ 1, 2, 3, null, 5 ] })={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "arr": [ 1, 2, 3, null, 5 ] }
new_obj.to_string({ "abc": "blue
red\ngreen" })={ "abc": "blue\nred\ngreen" }
new_obj.to_string(null)=null
new_obj.to_string(false)=false
new_obj.to_string([0e])=[ 0.0 ]
new_obj.to_string([0e+])=[ 0.0 ]
new_obj.to_string([0e+-1])=null
new_obj.to_string([18446744073709551616])=[ 9223372036854775807 ]
new_obj.to_string("hello world!")="hello world!"
==================================
new_obj.to_string()=null
new_obj.to_string({})=null
@@ -63,6 +77,14 @@ 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, { "foo": 789 }, 14) ... OK: got object of type [object]: { "foo": 789 }
json_tokener_parse_ex(tok, /* hello */{ "foo", 18) ... OK: got correct error: continue
json_tokener_parse_ex(tok, /* hello */:/* hello */, 23) ... OK: got correct error: continue
json_tokener_parse_ex(tok, "bar"/* hello */, 16) ... OK: got correct error: continue
json_tokener_parse_ex(tok, }/* hello */, 12) ... OK: got object of type [object]: { "foo": "bar" }
json_tokener_parse_ex(tok, / hello , 8) ... OK: got correct error: expected comment
json_tokener_parse_ex(tok, /* hello"foo", 13) ... OK: got correct error: continue
json_tokener_parse_ex(tok, /* hello*"foo", 14) ... OK: got correct error: continue
json_tokener_parse_ex(tok, // hello"foo", 13) ... OK: got correct error: continue
json_tokener_parse_ex(tok, { "foo , 6) ... OK: got correct error: continue
json_tokener_parse_ex(tok, ": {"bar , 8) ... OK: got correct error: continue
json_tokener_parse_ex(tok, ":13}} , 6) ... OK: got object of type [object]: { "foo": { "bar": 13 } }
@@ -77,6 +99,7 @@ json_tokener_parse_ex(tok, "Y" , 3) ... OK: got object of type [string
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, 12{ , 3) ... OK: got object of type [int]: 12
json_tokener_parse_ex(tok, [02] , 4) ... OK: got correct error: number expected
json_tokener_parse_ex(tok, false , 5) ... OK: got correct error: continue
json_tokener_parse_ex(tok, false , 6) ... OK: got object of type [boolean]: false
json_tokener_parse_ex(tok, true , 4) ... OK: got correct error: continue
@@ -138,10 +161,15 @@ json_tokener_parse_ex(tok, "\r" , 4) ... OK: got object of type [string
json_tokener_parse_ex(tok, "\t" , 4) ... OK: got object of type [string]: "\t"
json_tokener_parse_ex(tok, "\/" , 4) ... OK: got object of type [string]: "\/"
json_tokener_parse_ex(tok, "/" , 3) ... OK: got object of type [string]: "\/"
json_tokener_parse_ex(tok, "\a" , 4) ... OK: got correct error: invalid string sequence
json_tokener_parse_ex(tok, 'foo' , 5) ... OK: got correct error: unexpected character
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} , 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":1] , 7) ... OK: got correct error: object value separator ',' expected
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,] , 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=83 ERROR=0
End Incremental Tests OK=97 ERROR=0
==================================