Overview
Comment: | Migrate OFObjectTests to ObjFWTest |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | objfwtest |
Files: | files | file ages | folders |
SHA3-256: |
f7d401609eacf954bba639a99cd80d71 |
User & Date: | js on 2024-02-13 01:17:06 |
Other Links: | branch diff | manifest | tags |
Context
2024-02-13
| ||
01:38 | Migrate ForwardingTests to ObjFWTest check-in: 8be0d57d8f user: js tags: objfwtest | |
01:17 | Migrate OFObjectTests to ObjFWTest check-in: f7d401609e user: js tags: objfwtest | |
2024-02-12
| ||
22:58 | ObjFWTest: Add OTAssert{Less,Greater}Than(OrEqual) check-in: eda31b70b6 user: js tags: objfwtest | |
Changes
Modified new_tests/Makefile from [bbc40dc3df] to [380066eff0].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | OFJSONTests.m \ OFLocaleTests.m \ OFMatrix4x4Tests.m \ OFMethodSignatureTests.m \ OFMutableArrayTests.m \ OFMutableSetTests.m \ OFNumberTests.m \ OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ OFSetTests.m \ OFSystemInfoTests.m \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ | > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | OFJSONTests.m \ OFLocaleTests.m \ OFMatrix4x4Tests.m \ OFMethodSignatureTests.m \ OFMutableArrayTests.m \ OFMutableSetTests.m \ OFNumberTests.m \ OFObjectTests.m \ OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ OFSetTests.m \ OFSystemInfoTests.m \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ |
︙ | ︙ |
Renamed and modified tests/OFObjectTests.m [39c729edc8] to new_tests/OFObjectTests.m [3cd60f32da].
︙ | ︙ | |||
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 | * 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" #if (defined(OF_DRAGONFLYBSD) && defined(__LP64__)) || defined(OF_NINTENDO_3DS) # define TOO_BIG (SIZE_MAX / 3) #else # define TOO_BIG (SIZE_MAX - 128) #endif @interface MyObject: OFObject { id _objectValue; Class _classValue; bool _boolValue; char _charValue; short _shortValue; |
︙ | ︙ | |||
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 | @property (nonatomic) unsigned short unsignedShortValue; @property (nonatomic) unsigned int unsignedIntValue; @property (nonatomic) unsigned long unsignedLongValue; @property (nonatomic) unsigned long long unsignedLongLongValue; @property (nonatomic) float floatValue; @property (nonatomic) double doubleValue; @end @implementation MyObject @synthesize objectValue = _objectValue, classValue = _classValue; @synthesize boolValue = _boolValue, charValue = _charValue; @synthesize shortValue = _shortValue, intValue = _intValue; @synthesize longValue = _longValue, longLongValue = _longLongValue; @synthesize unsignedCharValue = _unsignedCharValue; @synthesize unsignedShortValue = _unsignedShortValue; @synthesize unsignedIntValue = _unsignedIntValue; @synthesize unsignedLongValue = _unsignedLongValue; @synthesize unsignedLongLongValue = _unsignedLongLongValue; @synthesize floatValue = _floatValue, doubleValue = _doubleValue; - (void)dealloc { [_objectValue release]; [super dealloc]; } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | @property (nonatomic) unsigned short unsignedShortValue; @property (nonatomic) unsigned int unsignedIntValue; @property (nonatomic) unsigned long unsignedLongValue; @property (nonatomic) unsigned long long unsignedLongLongValue; @property (nonatomic) float floatValue; @property (nonatomic) double doubleValue; @end @interface OFObjectTests: OTTestCase { MyObject *_myObject; } @end @implementation OFObjectTests - (void)setUp { [super setUp]; _myObject = [[MyObject alloc] init]; } - (void)dealloc { [_myObject release]; [super dealloc]; } - (void)testClassDescription { OTAssertEqualObjects([OFObject description], @"OFObject"); OTAssertEqualObjects([MyObject description], @"MyObject"); } - (void)testInstanceDescription { OFObject *object = [[[OFObject alloc] init] autorelease]; OTAssertEqualObjects(object.description, @"<OFObject>"); OTAssertEqualObjects(_myObject.description, @"<MyObject>"); } - (void)testValueForKey { _myObject.objectValue = @"Hello"; _myObject.classValue = _myObject.class; OTAssertEqualObjects([_myObject valueForKey: @"objectValue"], @"Hello"); OTAssertEqualObjects([_myObject valueForKey: @"classValue"], _myObject.class); OTAssertEqualObjects([_myObject valueForKey: @"class"], _myObject.class); } - (void)testValueForKeyWithUndefinedKeyThrows { OTAssertThrowsSpecific([_myObject valueForKey: @"undefined"], OFUndefinedKeyException); } - (void)testSetValueForKey { [_myObject setValue: @"World" forKey: @"objectValue"]; [_myObject setValue: [OFObject class] forKey: @"classValue"]; OTAssertEqualObjects(_myObject.objectValue, @"World"); OTAssertEqualObjects(_myObject.classValue, [OFObject class]); } - (void)testSetValueWithUndefinedKeyThrows { OTAssertThrowsSpecific([_myObject setValue: @"x" forKey: @"undefined"], OFUndefinedKeyException); } - (void)testAutoWrappingOfValueForKey { _myObject.boolValue = 1; _myObject.charValue = 2; _myObject.shortValue = 3; _myObject.intValue = 4; _myObject.longValue = 5; _myObject.longLongValue = 6; _myObject.unsignedCharValue = 7; _myObject.unsignedShortValue = 8; _myObject.unsignedIntValue = 9; _myObject.unsignedLongValue = 10; _myObject.unsignedLongLongValue = 11; _myObject.floatValue = 12; _myObject.doubleValue = 13; OTAssertEqualObjects([_myObject valueForKey: @"boolValue"], [OFNumber numberWithBool: 1]); OTAssertEqualObjects([_myObject valueForKey: @"charValue"], [OFNumber numberWithChar: 2]); OTAssertEqualObjects([_myObject valueForKey: @"shortValue"], [OFNumber numberWithShort: 3]); OTAssertEqualObjects([_myObject valueForKey: @"intValue"], [OFNumber numberWithInt: 4]); OTAssertEqualObjects([_myObject valueForKey: @"longValue"], [OFNumber numberWithLong: 5]); OTAssertEqualObjects([_myObject valueForKey: @"longLongValue"], [OFNumber numberWithLongLong: 6]); OTAssertEqualObjects([_myObject valueForKey: @"unsignedCharValue"], [OFNumber numberWithUnsignedChar: 7]); OTAssertEqualObjects([_myObject valueForKey: @"unsignedShortValue"], [OFNumber numberWithUnsignedShort: 8]); OTAssertEqualObjects([_myObject valueForKey: @"unsignedIntValue"], [OFNumber numberWithUnsignedInt: 9]); OTAssertEqualObjects([_myObject valueForKey: @"unsignedLongValue"], [OFNumber numberWithUnsignedLong: 10]); OTAssertEqualObjects([_myObject valueForKey: @"unsignedLongLongValue"], [OFNumber numberWithUnsignedLongLong: 11]); OTAssertEqualObjects([_myObject valueForKey: @"floatValue"], [OFNumber numberWithFloat: 12]); OTAssertEqualObjects([_myObject valueForKey: @"doubleValue"], [OFNumber numberWithDouble: 13]); } - (void)testAutoWrappingOfSetValueForKey { [_myObject setValue: [OFNumber numberWithBool: 0] forKey: @"boolValue"]; [_myObject setValue: [OFNumber numberWithChar: 10] forKey: @"charValue"]; [_myObject setValue: [OFNumber numberWithShort: 20] forKey: @"shortValue"]; [_myObject setValue: [OFNumber numberWithInt: 30] forKey: @"intValue"]; [_myObject setValue: [OFNumber numberWithLong: 40] forKey: @"longValue"]; [_myObject setValue: [OFNumber numberWithLongLong: 50] forKey: @"longLongValue"]; [_myObject setValue: [OFNumber numberWithUnsignedChar: 60] forKey: @"unsignedCharValue"]; [_myObject setValue: [OFNumber numberWithUnsignedShort: 70] forKey: @"unsignedShortValue"]; [_myObject setValue: [OFNumber numberWithUnsignedInt: 80] forKey: @"unsignedIntValue"]; [_myObject setValue: [OFNumber numberWithUnsignedLong: 90] forKey: @"unsignedLongValue"]; [_myObject setValue: [OFNumber numberWithUnsignedLongLong: 100] forKey: @"unsignedLongLongValue"]; [_myObject setValue: [OFNumber numberWithFloat: 110] forKey: @"floatValue"]; [_myObject setValue: [OFNumber numberWithDouble: 120] forKey: @"doubleValue"]; OTAssertEqual(_myObject.isBoolValue, 0); OTAssertEqual(_myObject.charValue, 10); OTAssertEqual(_myObject.shortValue, 20); OTAssertEqual(_myObject.intValue, 30); OTAssertEqual(_myObject.longValue, 40); OTAssertEqual(_myObject.longLongValue, 50); OTAssertEqual(_myObject.unsignedCharValue, 60); OTAssertEqual(_myObject.unsignedShortValue, 70); OTAssertEqual(_myObject.unsignedIntValue, 80); OTAssertEqual(_myObject.unsignedLongValue, 90); OTAssertEqual(_myObject.unsignedLongLongValue, 100); OTAssertEqual(_myObject.floatValue, 110); OTAssertEqual(_myObject.doubleValue, 120); } - (void)testSetValueForKeyWithNilThrows { OTAssertThrowsSpecific( [_myObject setValue: (id _Nonnull)nil forKey: @"intValue"], OFInvalidArgumentException); } - (void)testValueForKeyPath { _myObject.objectValue = [[[MyObject alloc] init] autorelease]; [_myObject.objectValue setObjectValue: [[[MyObject alloc] init] autorelease]]; [[_myObject.objectValue objectValue] setDoubleValue: 0.5]; OTAssertEqual([[_myObject valueForKeyPath: @"objectValue.objectValue.doubleValue"] doubleValue], 0.5); } - (void)testSetValueForKeyPath { _myObject.objectValue = [[[MyObject alloc] init] autorelease]; [_myObject.objectValue setObjectValue: [[[MyObject alloc] init] autorelease]]; [_myObject setValue: [OFNumber numberWithDouble: 0.75] forKeyPath: @"objectValue.objectValue.doubleValue"]; OTAssertEqual([[_myObject.objectValue objectValue] doubleValue], 0.75); } @end @implementation MyObject @synthesize objectValue = _objectValue, classValue = _classValue; @synthesize boolValue = _boolValue, charValue = _charValue; @synthesize shortValue = _shortValue, intValue = _intValue; @synthesize longValue = _longValue, longLongValue = _longLongValue; @synthesize unsignedCharValue = _unsignedCharValue; @synthesize unsignedShortValue = _unsignedShortValue; @synthesize unsignedIntValue = _unsignedIntValue; @synthesize unsignedLongValue = _unsignedLongValue; @synthesize unsignedLongLongValue = _unsignedLongLongValue; @synthesize floatValue = _floatValue, doubleValue = _doubleValue; - (void)dealloc { [_objectValue release]; [super dealloc]; } @end |
Modified tests/Makefile from [dd6620f511] to [40ae959bc2].
︙ | ︙ | |||
16 17 18 19 20 21 22 | SRCS = ForwardingTests.m \ ${OF_BLOCK_TESTS_M} \ OFDataTests.m \ OFDictionaryTests.m \ OFListTests.m \ OFMemoryStreamTests.m \ OFNotificationCenterTests.m \ | < | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | SRCS = ForwardingTests.m \ ${OF_BLOCK_TESTS_M} \ OFDataTests.m \ OFDictionaryTests.m \ OFListTests.m \ OFMemoryStreamTests.m \ OFNotificationCenterTests.m \ OFStreamTests.m \ OFStringTests.m \ OFValueTests.m \ OFXMLElementBuilderTests.m \ OFXMLNodeTests.m \ OFXMLParserTests.m \ RuntimeTests.m \ |
︙ | ︙ |
Modified tests/TestsAppDelegate.h from [45f0814e2c] to [b2edbf002d].
︙ | ︙ | |||
107 108 109 110 111 112 113 | - (void)memoryStreamTests; @end @interface TestsAppDelegate (OFNotificationCenterTests) - (void)notificationCenterTests; @end | < < < < | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | - (void)memoryStreamTests; @end @interface TestsAppDelegate (OFNotificationCenterTests) - (void)notificationCenterTests; @end @interface TestsAppDelegate (RuntimeTests) - (void)runtimeTests; @end @interface TestsAppDelegate (RuntimeARCTests) - (void)runtimeARCTests; @end |
︙ | ︙ |
Modified tests/TestsAppDelegate.m from [a195ff8f10] to [a4d4d2a563].
︙ | ︙ | |||
370 371 372 373 374 375 376 | changeCurrentDirectoryPath: @"/apps/objfw-tests"]; #endif [self runtimeTests]; #ifdef COMPILER_SUPPORTS_ARC [self runtimeARCTests]; #endif | < | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | changeCurrentDirectoryPath: @"/apps/objfw-tests"]; #endif [self runtimeTests]; #ifdef COMPILER_SUPPORTS_ARC [self runtimeARCTests]; #endif [self forwardingTests]; #ifdef OF_HAVE_BLOCKS [self blockTests]; #endif [self stringTests]; [self dataTests]; [self dictionaryTests]; |
︙ | ︙ |