Differences From Artifact [e8e782d6ff]:
- File
tests/OFJSONTests.m
— part of check-in
[54f80aba7a]
at
2012-06-04 22:32:38
on branch trunk
— Initial JSON5 support.
Supported so far:
* comments
* single quoted strings (user: js, size: 1857) [annotate] [blame] [check-ins using]
To Artifact [ae9d04304d]:
- File tests/OFJSONTests.m — part of check-in [3e028f7479] at 2012-06-04 23:36:38 on branch trunk — Allow numbers in JSON5 format. (user: js, size: 1894) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
29 30 31 32 33 34 35 | static OFString *module = @"OFJSON"; @implementation TestsAppDelegate (JSONTests) - (void)JSONTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; | | | > | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | static OFString *module = @"OFJSON"; @implementation TestsAppDelegate (JSONTests) - (void)JSONTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *s = @"{\"foo\"\t:'ba\\r', \"x\":/*foo*/ [.5\r,0xF,null//bar\n" @",\"foo\",false]}"; OFDictionary *d = [OFDictionary dictionaryWithKeysAndObjects: @"foo", @"ba\r", @"x", [OFArray arrayWithObjects: [OFNumber numberWithFloat: .5f], [OFNumber numberWithInt: 0xF], [OFNull null], @"foo", [OFNumber numberWithBool: NO], nil], nil]; TEST(@"-[JSONValue #1]", [[s JSONValue] isEqual: d]) TEST(@"-[JSONRepresentation]", [[d JSONRepresentation] isEqual: @"{\"foo\":\"ba\\r\",\"x\":[0.5,15,null,\"foo\",false]}"]) EXPECT_EXCEPTION(@"-[JSONValue #2]", OFInvalidEncodingException, [@"{" JSONValue]) EXPECT_EXCEPTION(@"-[JSONValue #3]", OFInvalidEncodingException, [@"]" JSONValue]) EXPECT_EXCEPTION(@"-[JSONValue #4]", OFInvalidEncodingException, [@"bar" JSONValue]) EXPECT_EXCEPTION(@"-[JSONValue #5]", OFInvalidEncodingException, [@"[\"a\" \"b\"]" JSONValue]) [pool drain]; } @end |