Index: new_tests/OFArrayTests.h ================================================================== --- new_tests/OFArrayTests.h +++ new_tests/OFArrayTests.h @@ -19,7 +19,7 @@ @interface OFArrayTests: OTTestCase { OFArray *_array; } -- (Class)arrayClass; +@property (readonly, nonatomic) Class arrayClass; @end Index: new_tests/OFJSONTests.m ================================================================== --- new_tests/OFJSONTests.m +++ new_tests/OFJSONTests.m @@ -18,28 +18,22 @@ #import "ObjFW.h" #import "ObjFWTest.h" @interface OFJSONTests: OTTestCase { - unsigned long long _hashSeed; OFDictionary *_dictionary; } @end -extern unsigned long long OFHashSeed; - static OFString *string = @"{\"foo\"\t:'b\\na\\r', \"x\":/*foo*/ [.5\r,0xF," @"null//bar\n,\"foo\",false]}"; @implementation OFJSONTests - (void)setUp { [super setUp]; - _hashSeed = OFHashSeed; - OFHashSeed = 0; - _dictionary = [[OFDictionary alloc] initWithKeysAndObjects: @"foo", @"b\na\r", @"x", [OFArray arrayWithObjects: [OFNumber numberWithFloat: .5f], [OFNumber numberWithInt: 0xF], @@ -48,17 +42,10 @@ [OFNumber numberWithBool: false], nil], nil]; } -- (void)tearDown -{ - OFHashSeed = _hashSeed; - - [super tearDown]; -} - - (void)dealloc { [_dictionary release]; [super dealloc]; @@ -69,27 +56,43 @@ OTAssertEqualObjects(string.objectByParsingJSON, _dictionary); } - (void)testJSONRepresentation { - OTAssertEqualObjects(_dictionary.JSONRepresentation, - @"{\"x\":[0.5,15,null,\"foo\",false],\"foo\":\"b\\na\\r\"}"); + OFString *representation = _dictionary.JSONRepresentation; + + OTAssert( + [representation isEqual: + @"{\"x\":[0.5,15,null,\"foo\",false],\"foo\":\"b\\na\\r\"}"] || + [representation isEqual: + @"{\"foo\":\"b\\na\\r\",\"x\":[0.5,15,null,\"foo\",false]}"]); } - (void)testPrettyJSONRepresentation { - OTAssertEqualObjects([_dictionary JSONRepresentationWithOptions: - OFJSONRepresentationOptionPretty], + OFString *representation = [_dictionary JSONRepresentationWithOptions: + OFJSONRepresentationOptionPretty]; + + OTAssert( + [representation 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}"); + @"\"foo\",\n\t\tfalse\n\t],\n\t\"foo\": \"b\\na\\r\"\n}"] || + [representation isEqual: + @"{\n\t\"foo\": \"b\\na\\r\",\n\t\"x\": [\n\t\t0.5,\n\t\t15," + @"\n\t\tnull,\n\t\t\"foo\",\n\t\tfalse\n\t]\n}"]); } - (void)testJSON5Representation { - OTAssertEqualObjects([_dictionary JSONRepresentationWithOptions: - OFJSONRepresentationOptionJSON5], - @"{x:[0.5,15,null,\"foo\",false],foo:\"b\\\na\\r\"}"); + OFString *representation = [_dictionary JSONRepresentationWithOptions: + OFJSONRepresentationOptionJSON5]; + + OTAssert( + [representation isEqual: + @"{x:[0.5,15,null,\"foo\",false],foo:\"b\\\na\\r\"}"] || + [representation isEqual: + @"{foo:\"b\\\na\\r\",x:[0.5,15,null,\"foo\",false]}"]); } - (void)testObjectByParsingJSONFailsWithInvalidJSON { OTAssertThrowsSpecific([@"{" objectByParsingJSON], Index: new_tests/OFNumberTests.m ================================================================== --- new_tests/OFNumberTests.m +++ new_tests/OFNumberTests.m @@ -17,43 +17,49 @@ #import "ObjFW.h" #import "ObjFWTest.h" @interface OFNumberTests: OTTestCase +{ + OFNumber *_number; +} @end -extern unsigned long long OFHashSeed; - @implementation OFNumberTests +- (void)setUp +{ + [super setUp]; + + _number = [[OFNumber alloc] initWithLongLong: 123456789]; +} + +- (void)dealloc +{ + [_number release]; + + [super dealloc]; +} + - (void)testIsEqual { - OFNumber *number = [OFNumber numberWithLongLong: 123456789]; - OTAssertEqualObjects(number, [OFNumber numberWithLong: 123456789]); + OTAssertEqualObjects(_number, [OFNumber numberWithLong: 123456789]); } - (void)testHash { - unsigned long long hashSeed = OFHashSeed; - OFHashSeed = 0; - @try { - OFNumber *number = [OFNumber numberWithLongLong: 123456789]; - OTAssertEqual(number.hash, 0x82D8BC42); - } @finally { - OFHashSeed = hashSeed; - }; + OTAssertEqual(_number.hash, + [[OFNumber numberWithLong: 123456789] hash]); } - (void)testCharValue { - OFNumber *number = [OFNumber numberWithLongLong: 123456789]; - OTAssertEqual(number.charValue, 21); + OTAssertEqual(_number.charValue, 21); } - (void)testDoubleValue { - OFNumber *number = [OFNumber numberWithLongLong: 123456789]; - OTAssertEqual(number.doubleValue, 123456789.L); + OTAssertEqual(_number.doubleValue, 123456789.L); } - (void)testSignedCharMinAndMaxUnmodified { OTAssertEqual([[OFNumber numberWithChar: SCHAR_MIN] charValue],