37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
nil];
TEST(@"-[objectByParsingJSON] #1", [s.objectByParsingJSON isEqual: d])
TEST(@"-[JSONRepresentation]", [[d JSONRepresentation] isEqual:
@"{\"x\":[0.5,15,null,\"foo\",false],\"foo\":\"b\\na\\r\"}"])
TEST(@"OF_JSON_REPRESENTATION_PRETTY",
[[d JSONRepresentationWithOptions: OF_JSON_REPRESENTATION_PRETTY]
isEqual: @"{\n\t\"x\": [\n\t\t0.5,\n\t\t15,\n\t\tnull,\n\t\t"
@"\"foo\",\n\t\tfalse\n\t],\n\t\"foo\": \"b\\na\\r\"\n}"])
TEST(@"OF_JSON_REPRESENTATION_JSON5",
[[d JSONRepresentationWithOptions: OF_JSON_REPRESENTATION_JSON5]
isEqual: @"{x:[0.5,15,null,\"foo\",false],foo:\"b\\\na\\r\"}"])
EXPECT_EXCEPTION(@"-[objectByParsingJSON] #2", OFInvalidJSONException,
[@"{" objectByParsingJSON])
EXPECT_EXCEPTION(@"-[objectByParsingJSON] #3", OFInvalidJSONException,
[@"]" objectByParsingJSON])
EXPECT_EXCEPTION(@"-[objectByParsingJSON] #4", OFInvalidJSONException,
|
|
|
|
|
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
nil];
TEST(@"-[objectByParsingJSON] #1", [s.objectByParsingJSON isEqual: d])
TEST(@"-[JSONRepresentation]", [[d JSONRepresentation] isEqual:
@"{\"x\":[0.5,15,null,\"foo\",false],\"foo\":\"b\\na\\r\"}"])
TEST(@"OFJSONRepresentationOptionPretty",
[[d JSONRepresentationWithOptions: OFJSONRepresentationOptionPretty]
isEqual: @"{\n\t\"x\": [\n\t\t0.5,\n\t\t15,\n\t\tnull,\n\t\t"
@"\"foo\",\n\t\tfalse\n\t],\n\t\"foo\": \"b\\na\\r\"\n}"])
TEST(@"OFJSONRepresentationOptionJSON5",
[[d JSONRepresentationWithOptions: OFJSONRepresentationOptionJSON5]
isEqual: @"{x:[0.5,15,null,\"foo\",false],foo:\"b\\\na\\r\"}"])
EXPECT_EXCEPTION(@"-[objectByParsingJSON] #2", OFInvalidJSONException,
[@"{" objectByParsingJSON])
EXPECT_EXCEPTION(@"-[objectByParsingJSON] #3", OFInvalidJSONException,
[@"]" objectByParsingJSON])
EXPECT_EXCEPTION(@"-[objectByParsingJSON] #4", OFInvalidJSONException,
|