Overview
Comment: | Migrate OFJSONTests to ObjFWTest |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | objfwtest |
Files: | files | file ages | folders |
SHA3-256: |
ce1f7a4088d0857e9846e57244239beb |
User & Date: | js on 2024-02-11 17:13:48 |
Other Links: | branch diff | manifest | tags |
Context
2024-02-11
| ||
17:39 | Migrate OFDateTests to ObjFWTest check-in: 109084deb0 user: js tags: objfwtest | |
17:13 | Migrate OFJSONTests to ObjFWTest check-in: ce1f7a4088 user: js tags: objfwtest | |
16:23 | Migrate OFSocketTests to ObjFWTest check-in: 10ece67a08 user: js tags: objfwtest | |
Changes
Modified new_tests/Makefile from [d64542647f] to [7cf57aad4f].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} PROG_NOINST = tests${PROG_SUFFIX} SRCS = OFCharacterSetTests.m \ OFColorTests.m \ OFIRITests.m \ OFInvocationTests.m \ OFMatrix4x4Tests.m \ OFMethodSignatureTests.m \ OFNumberTests.m \ OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ ${USE_SRCS_PLUGINS} \ | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} PROG_NOINST = tests${PROG_SUFFIX} SRCS = OFCharacterSetTests.m \ OFColorTests.m \ OFIRITests.m \ OFInvocationTests.m \ OFJSONTests.m \ OFMatrix4x4Tests.m \ OFMethodSignatureTests.m \ OFNumberTests.m \ OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ ${USE_SRCS_PLUGINS} \ |
︙ | ︙ |
Renamed and modified tests/OFJSONTests.m [92f1f602a7] to new_tests/OFJSONTests.m [9843db101a].
︙ | ︙ | |||
11 12 13 14 15 16 17 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" | | > | | > | > | | > | | | | > > > > > > > | > > > > > > > > > > > > > | > | | > | > | | | > | > | | | | > | > | | | | | > > | | > | | > | | > | > | > | > > | | > | | | > > > | | < | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #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 { _hashSeed = OFHashSeed; OFHashSeed = 0; _dictionary = [[OFDictionary alloc] initWithKeysAndObjects: @"foo", @"b\na\r", @"x", [OFArray arrayWithObjects: [OFNumber numberWithFloat: .5f], [OFNumber numberWithInt: 0xF], [OFNull null], @"foo", [OFNumber numberWithBool: false], nil], nil]; } - (void)tearDown { OFHashSeed = _hashSeed; } - (void)dealloc { [_dictionary release]; [super dealloc]; } - (void)testObjectByParsingJSON { OTAssertEqualObjects(string.objectByParsingJSON, _dictionary); } - (void)testJSONRepresentation { OTAssertEqualObjects(_dictionary.JSONRepresentation, @"{\"x\":[0.5,15,null,\"foo\",false],\"foo\":\"b\\na\\r\"}"); } - (void)testPrettyJSONRepresentation { OTAssertEqualObjects([_dictionary JSONRepresentationWithOptions: OFJSONRepresentationOptionPretty], @"{\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}"); } - (void)testJSON5Representation { OTAssertEqualObjects([_dictionary JSONRepresentationWithOptions: OFJSONRepresentationOptionJSON5], @"{x:[0.5,15,null,\"foo\",false],foo:\"b\\\na\\r\"}"); } - (void)testObjectByParsingJSONFailsWithInvalidJSON { OTAssertThrowsSpecific([@"{" objectByParsingJSON], OFInvalidJSONException); OTAssertThrowsSpecific([@"]" objectByParsingJSON], OFInvalidJSONException); OTAssertThrowsSpecific([@"bar" objectByParsingJSON], OFInvalidJSONException); OTAssertThrowsSpecific([@"[\"a\" \"b\"]" objectByParsingJSON], OFInvalidJSONException); } - (void)testObjectByParsingJSONWithDeepNesting { OTAssertEqualObjects( @"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{}]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]" .objectByParsingJSON, [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFDictionary dictionary]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]); } - (void)testObjectByParsingJSONFailsWithTooDeepNesting { OTAssertThrowsSpecific( [@"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{}]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]" objectByParsingJSON], OFInvalidJSONException); } @end |
Modified tests/Makefile from [f5a669cb71] to [90e73866ce].
︙ | ︙ | |||
20 21 22 23 24 25 26 | OFArrayTests.m \ ${OF_BLOCK_TESTS_M} \ OFDataTests.m \ OFDateTests.m \ OFDictionaryTests.m \ OFHMACTests.m \ OFINIFileTests.m \ | < | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | OFArrayTests.m \ ${OF_BLOCK_TESTS_M} \ OFDataTests.m \ OFDateTests.m \ OFDictionaryTests.m \ OFHMACTests.m \ OFINIFileTests.m \ OFListTests.m \ OFLocaleTests.m \ OFMD5HashTests.m \ OFMemoryStreamTests.m \ OFNotificationCenterTests.m \ OFObjectTests.m \ OFRIPEMD160HashTests.m \ |
︙ | ︙ |
Modified tests/TestsAppDelegate.h from [05e2d95af6] to [f9070a2d4e].
︙ | ︙ | |||
107 108 109 110 111 112 113 | - (void)INIFileTests; @end @interface TestsAppDelegate (OFIPXSocketTests) - (void)IPXSocketTests; @end | < < < < | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | - (void)INIFileTests; @end @interface TestsAppDelegate (OFIPXSocketTests) - (void)IPXSocketTests; @end @interface TestsAppDelegate (OFHMACTests) - (void)HMACTests; @end @interface TestsAppDelegate (OFKernelEventObserverTests) - (void)kernelEventObserverTests; @end |
︙ | ︙ |
Modified tests/TestsAppDelegate.m from [632436b2c9] to [bde6bc2f49].
︙ | ︙ | |||
427 428 429 430 431 432 433 | #ifdef OF_HAVE_SOCKETS [self HTTPCookieTests]; [self HTTPCookieManagerTests]; #endif [self XMLParserTests]; [self XMLNodeTests]; [self XMLElementBuilderTests]; | < | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | #ifdef OF_HAVE_SOCKETS [self HTTPCookieTests]; [self HTTPCookieManagerTests]; #endif [self XMLParserTests]; [self XMLNodeTests]; [self XMLElementBuilderTests]; #ifdef OF_HAVE_SUBPROCESSES [self subprocessTests]; #endif #ifdef OF_WINDOWS [self windowsRegistryKeyTests]; #endif |
︙ | ︙ |