Overview
Comment: | Migrate OFDateTests to ObjFWTest |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | objfwtest |
Files: | files | file ages | folders |
SHA3-256: |
109084deb003f1bcdf7f56d75784f071 |
User & Date: | js on 2024-02-11 17:39:14 |
Other Links: | branch diff | manifest | tags |
Context
2024-02-11
| ||
20:49 | Migrate OFArrayTests to ObjFWTest check-in: 7272d5b2cd user: js tags: objfwtest | |
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 | |
Changes
Modified new_tests/Makefile from [7cf57aad4f] to [fa0217345c].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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 \ | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} PROG_NOINST = tests${PROG_SUFFIX} SRCS = OFCharacterSetTests.m \ OFColorTests.m \ OFDateTests.m \ OFIRITests.m \ OFInvocationTests.m \ OFJSONTests.m \ OFMatrix4x4Tests.m \ OFMethodSignatureTests.m \ OFNumberTests.m \ OFPBKDF2Tests.m \ |
︙ | ︙ |
Renamed and modified tests/OFDateTests.m [a09d2c22e2] to new_tests/OFDateTests.m [94de181a0a].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #include "config.h" #include <time.h> | | > > > > | | > > | > > > > > > > | > > | > > | > | | | | | > | > > | > | < < | > > | > | > | > | | | > | > > | | | | | | > > | > | > | > > | | | | < > | | > | | | | > > | > < < > | > | | > > > | > > | | | > | > > | > | > > > > | > | > | | > | > > > | > > > > | | > | > > > > | > | > | | > | > > > | > | | > | | > | > > > | > | > > | > > > | 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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | * file. */ #include "config.h" #include <time.h> #import "ObjFW.h" #import "ObjFWTest.h" #import "OFStrPTime.h" @interface OFDateTests: OTTestCase { OFDate *_date[2]; } @end @implementation OFDateTests - (void)setUp { _date[0] = [[OFDate alloc] initWithTimeIntervalSince1970: 0]; _date[1] = [[OFDate alloc] initWithTimeIntervalSince1970: 3600 * 25 + 5.000002]; } - (void)dealloc { [_date[0] release]; [_date[1] release]; [super dealloc]; } - (void)testStrPTime { struct tm tm; int16_t timeZone; const char *dateString = "Wed, 09 Jun 2021 +0200x"; OTAssertEqual(OFStrPTime(dateString, "%a, %d %b %Y %z", &tm, &timeZone), dateString + 22); OTAssertEqual(tm.tm_wday, 3); OTAssertEqual(tm.tm_mday, 9); OTAssertEqual(tm.tm_mon, 5); OTAssertEqual(tm.tm_year, 2021 - 1900); OTAssertEqual(timeZone, 2 * 60); } - (void)testDateByAddingTimeInterval { OTAssertEqualObjects( [_date[0] dateByAddingTimeInterval: 3600 * 25 + 5.000002], _date[1]); } - (void)testDescription { OTAssertEqualObjects(_date[0].description, @"1970-01-01T00:00:00Z"); OTAssertEqualObjects(_date[1].description, @"1970-01-02T01:00:05Z"); } - (void)testDateWithDateStringFormat { OTAssertEqualObjects( [[OFDate dateWithDateString: @"2000-06-20T12:34:56+0200" format: @"%Y-%m-%dT%H:%M:%S%z"] description], @"2000-06-20T10:34:56Z"); } - (void)testDateWithDateStringFormatFailsWithTrailingCharacters { OTAssertThrowsSpecific( [OFDate dateWithDateString: @"2000-06-20T12:34:56+0200x" format: @"%Y-%m-%dT%H:%M:%S%z"], OFInvalidFormatException); } - (void)testDateWithLocalDateStringFormatFormat { OTAssertEqualObjects( [[OFDate dateWithLocalDateString: @"2000-06-20T12:34:56" format: @"%Y-%m-%dT%H:%M:%S"] localDateStringWithFormat: @"%Y-%m-%dT%H:%M:%S"], @"2000-06-20T12:34:56"); OTAssertEqualObjects( [[OFDate dateWithLocalDateString: @"2000-06-20T12:34:56-0200" format: @"%Y-%m-%dT%H:%M:%S%z"] description], @"2000-06-20T14:34:56Z"); } - (void)testDateWithLocalDateStringFormatFailsWithTrailingCharacters { OTAssertThrowsSpecific( [OFDate dateWithLocalDateString: @"2000-06-20T12:34:56x" format: @"%Y-%m-%dT%H:%M:%S"], OFInvalidFormatException); OTAssertThrowsSpecific( [OFDate dateWithLocalDateString: @"2000-06-20T12:34:56+0200x" format: @"%Y-%m-%dT%H:%M:%S%z"], OFInvalidFormatException); } - (void)testIsEqual { OTAssertEqualObjects(_date[0], [OFDate dateWithTimeIntervalSince1970: 0]); OTAssertNotEqualObjects(_date[0], [OFDate dateWithTimeIntervalSince1970: 0.0000001]); } - (void)testCompare { OTAssertEqual([_date[0] compare: _date[1]], OFOrderedAscending); } - (void)testSecond { OTAssertEqual(_date[0].second, 0); OTAssertEqual(_date[1].second, 5); } - (void)testMicrosecond { OTAssertEqual(_date[0].microsecond, 0); OTAssertEqual(_date[1].microsecond, 2); } - (void)testMinute { OTAssertEqual(_date[0].minute, 0); OTAssertEqual(_date[1].minute, 0); } - (void)testHour { OTAssertEqual(_date[0].hour, 0); OTAssertEqual(_date[1].hour, 1); } - (void)testDayOfMonth { OTAssertEqual(_date[0].dayOfMonth, 1); OTAssertEqual(_date[1].dayOfMonth, 2); } - (void)testMonthOfYear { OTAssertEqual(_date[0].monthOfYear, 1); OTAssertEqual(_date[1].monthOfYear, 1); } - (void)testYear { OTAssertEqual(_date[0].year, 1970); OTAssertEqual(_date[1].year, 1970); } - (void)testDayOfWeek { OTAssertEqual(_date[0].dayOfWeek, 4); OTAssertEqual(_date[1].dayOfWeek, 5); } - (void)testDayOfYear { OTAssertEqual(_date[0].dayOfYear, 1); OTAssertEqual(_date[1].dayOfYear, 2); } - (void)testEarlierDate { OTAssertEqualObjects([_date[0] earlierDate: _date[1]], _date[0]); } - (void)testLaterDate { OTAssertEqualObjects([_date[0] laterDate: _date[1]], _date[1]); } @end |
Modified tests/Makefile from [90e73866ce] to [2fdd12c29b].
︙ | ︙ | |||
16 17 18 19 20 21 22 | PROG_NOINST = tests${PROG_SUFFIX} STATIC_LIB_NOINST = ${TESTS_STATIC_LIB} SRCS = ForwardingTests.m \ OFArrayTests.m \ ${OF_BLOCK_TESTS_M} \ OFDataTests.m \ | < | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | PROG_NOINST = tests${PROG_SUFFIX} STATIC_LIB_NOINST = ${TESTS_STATIC_LIB} SRCS = ForwardingTests.m \ OFArrayTests.m \ ${OF_BLOCK_TESTS_M} \ OFDataTests.m \ OFDictionaryTests.m \ OFHMACTests.m \ OFINIFileTests.m \ OFListTests.m \ OFLocaleTests.m \ OFMD5HashTests.m \ OFMemoryStreamTests.m \ |
︙ | ︙ |
Modified tests/TestsAppDelegate.h from [f9070a2d4e] to [ea2aa8c078].
︙ | ︙ | |||
75 76 77 78 79 80 81 | - (void)DNSResolverTests; @end @interface TestsAppDelegate (OFDataTests) - (void)dataTests; @end | < < < < | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | - (void)DNSResolverTests; @end @interface TestsAppDelegate (OFDataTests) - (void)dataTests; @end @interface TestsAppDelegate (OFDictionaryTests) - (void)dictionaryTests; @end @interface TestsAppDelegate (ForwardingTests) - (void)forwardingTests; @end |
︙ | ︙ |
Modified tests/TestsAppDelegate.m from [bde6bc2f49] to [84819e96c0].
︙ | ︙ | |||
381 382 383 384 385 386 387 | #endif [self stringTests]; [self dataTests]; [self arrayTests]; [self dictionaryTests]; [self listTests]; [self setTests]; | < | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | #endif [self stringTests]; [self dataTests]; [self arrayTests]; [self dictionaryTests]; [self listTests]; [self setTests]; [self valueTests]; [self streamTests]; [self memoryStreamTests]; [self notificationCenterTests]; [self MD5HashTests]; [self RIPEMD160HashTests]; [self SHA1HashTests]; |
︙ | ︙ |