Overview
Comment: | Migrate OFDataTests to ObjFWTest |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | objfwtest |
Files: | files | file ages | folders |
SHA3-256: |
f3bfdcf17a30d0f568fd4ef321409bde |
User & Date: | js on 2024-02-18 17:44:58 |
Other Links: | branch diff | manifest | tags |
Context
2024-02-18
| ||
17:56 | Migrate OFMemoryStreamTests to ObjFWTest check-in: 814d957cdc user: js tags: objfwtest | |
17:44 | Migrate OFDataTests to ObjFWTest check-in: f3bfdcf17a user: js tags: objfwtest | |
13:53 | Merge trunk into branch "objfwtest" check-in: 89869c188f user: js tags: objfwtest | |
Changes
Modified new_tests/Makefile from [6a27e20057] to [a32f707fdb].
︙ | ︙ | |||
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 | OFConcreteArrayTests.m \ OFConcreteDictionaryTests.m \ OFConcreteMutableArrayTests.m \ OFConcreteMutableDictionaryTests.m \ OFConcreteMutableSetTests.m \ OFConcreteSetTests.m \ OFCryptographicHashTests.m \ OFDateTests.m \ OFDictionaryTests.m \ OFHMACTests.m \ OFINIFileTests.m \ OFIRITests.m \ OFInvocationTests.m \ OFJSONTests.m \ OFListTests.m \ OFLocaleTests.m \ OFMatrix4x4Tests.m \ OFMethodSignatureTests.m \ OFMutableArrayTests.m \ OFMutableDictionaryTests.m \ OFMutableSetTests.m \ OFMutableStringTests.m \ OFMutableUTF8StringTests.m \ OFNotificationCenterTests.m \ OFNumberTests.m \ OFObjectTests.m \ | > > | 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 | OFConcreteArrayTests.m \ OFConcreteDictionaryTests.m \ OFConcreteMutableArrayTests.m \ OFConcreteMutableDictionaryTests.m \ OFConcreteMutableSetTests.m \ OFConcreteSetTests.m \ OFCryptographicHashTests.m \ OFDataTests.m \ OFDateTests.m \ OFDictionaryTests.m \ OFHMACTests.m \ OFINIFileTests.m \ OFIRITests.m \ OFInvocationTests.m \ OFJSONTests.m \ OFListTests.m \ OFLocaleTests.m \ OFMatrix4x4Tests.m \ OFMethodSignatureTests.m \ OFMutableArrayTests.m \ OFMutableDataTests.m \ OFMutableDictionaryTests.m \ OFMutableSetTests.m \ OFMutableStringTests.m \ OFMutableUTF8StringTests.m \ OFNotificationCenterTests.m \ OFNumberTests.m \ OFObjectTests.m \ |
︙ | ︙ |
Added new_tests/OFDataTests.h version [b0edcdb3e6].
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * 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. */ #import "ObjFW.h" #import "ObjFWTest.h" @interface OFDataTests: OTTestCase { OFData *_data; unsigned char _items[2][4096]; } @property (readonly, nonatomic) Class dataClass; @end |
Renamed and modified tests/OFDataTests.m [a8658a6bbf] to new_tests/OFDataTests.m [e445376d45].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #include "config.h" #include <string.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 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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | * file. */ #include "config.h" #include <string.h> #import "OFDataTests.h" @implementation OFDataTests - (Class)dataClass { return [OFData class]; } - (void)setUp { [super setUp]; memset(&_items[0], 0xFF, 4096); memset(&_items[1], 0x42, 4096); _data = [[self.dataClass alloc] initWithItems: _items count: 2 itemSize: 4096]; } - (void)dealloc { [_data release]; [super dealloc]; } - (void)testCount { OTAssertEqual(_data.count, 2); } - (void)testItemSize { OTAssertEqual(_data.itemSize, 4096); } - (void)testItems { OTAssertEqual(memcmp(_data.items, _items, 2 * _data.itemSize), 0); } - (void)testItemAtIndex { OTAssertEqual( memcmp([_data itemAtIndex: 1], &_items[1], _data.itemSize), 0); } - (void)testItemAtIndexThrowsOnOutOfRangeIndex { OTAssertThrowsSpecific([_data itemAtIndex: _data.count], OFOutOfRangeException); } - (void)testFirstItem { OTAssertEqual(memcmp(_data.firstItem, &_items[0], _data.itemSize), 0); } - (void)testLastItem { OTAssertEqual(memcmp(_data.lastItem, &_items[1], _data.itemSize), 0); } - (void)testIsEqual { OTAssertEqualObjects( _data, [OFData dataWithItems: _items count: 2 itemSize: 4096]); OTAssertNotEqualObjects( _data, [OFData dataWithItems: _items count: 1 itemSize: 4096]); } - (void)testHash { OTAssertEqual(_data.hash, [[OFData dataWithItems: _items count: 2 itemSize: 4096] hash]); OTAssertNotEqual(_data.hash, [[OFData dataWithItems: _items count: 1 itemSize: 4096] hash]); } - (void)testCompare { OFData *data1 = [self.dataClass dataWithItems: "aa" count: 2]; OFData *data2 = [self.dataClass dataWithItems: "ab" count: 2]; OFData *data3 = [self.dataClass dataWithItems: "aaa" count: 3]; OTAssertEqual([data1 compare: data2], OFOrderedAscending); OTAssertEqual([data2 compare: data1], OFOrderedDescending); OTAssertEqual([data1 compare: data1], OFOrderedSame); OTAssertEqual([data1 compare: data3], OFOrderedAscending); OTAssertEqual([data2 compare: data3], OFOrderedDescending); } - (void)testCopy { OTAssertEqualObjects([[_data copy] autorelease], _data); } - (void)testRangeOfDataOptionsRange { OFData *data = [self.dataClass dataWithItems: "aaabaccdacaabb" count: 7 itemSize: 2]; OFRange range; range = [data rangeOfData: [self.dataClass dataWithItems: "aa" count: 1 itemSize: 2] options: 0 range: OFMakeRange(0, 7)]; OTAssertEqual(range.location, 0); OTAssertEqual(range.length, 1); range = [data rangeOfData: [self.dataClass dataWithItems: "aa" count: 1 itemSize: 2] options: OFDataSearchBackwards range: OFMakeRange(0, 7)]; OTAssertEqual(range.location, 5); OTAssertEqual(range.length, 1); range = [data rangeOfData: [self.dataClass dataWithItems: "ac" count: 1 itemSize: 2] options: 0 range: OFMakeRange(0, 7)]; OTAssertEqual(range.location, 2); OTAssertEqual(range.length, 1); range = [data rangeOfData: [self.dataClass dataWithItems: "aabb" count: 2 itemSize: 2] options: 0 range: OFMakeRange(0, 7)]; OTAssertEqual(range.location, 5); OTAssertEqual(range.length, 2); range = [data rangeOfData: [self.dataClass dataWithItems: "aa" count: 1 itemSize: 2] options: 0 range: OFMakeRange(1, 6)]; OTAssertEqual(range.location, 5); OTAssertEqual(range.length, 1); range = [data rangeOfData: [self.dataClass dataWithItems: "aa" count: 1 itemSize: 2] options: OFDataSearchBackwards range: OFMakeRange(0, 5)]; OTAssertEqual(range.location, 0); OTAssertEqual(range.length, 1); } - (void)testRangeOfDataOptionsRangeThrowsOnDifferentItemSize { OTAssertThrowsSpecific( [_data rangeOfData: [OFData dataWithItems: "a" count: 1] options: 0 range: OFMakeRange(0, 1)], OFInvalidArgumentException); } - (void)testRangeOfDataOptionsRangeThrowsOnOutOfRangeRange { OTAssertThrowsSpecific( [_data rangeOfData: [OFData dataWithItemSize: 4096] options: 0 range: OFMakeRange(1, 2)], OFOutOfRangeException); OTAssertThrowsSpecific( [_data rangeOfData: [OFData dataWithItemSize: 4096] options: 0 range: OFMakeRange(2, 1)], OFOutOfRangeException); } - (void)testSubdataWithRange { OFData *data1 = [self.dataClass dataWithItems: "aaabaccdacaabb" count: 7 itemSize: 2]; OFData *data2 = [self.dataClass dataWithItems: "abcde" count: 5]; OTAssertEqualObjects( [data1 subdataWithRange: OFMakeRange(2, 4)], [OFData dataWithItems: "accdacaa" count: 4 itemSize: 2]); OTAssertEqualObjects( [data2 subdataWithRange: OFMakeRange(2, 3)], [OFData dataWithItems: "cde" count: 3]); } - (void)testSubdataWithRangeThrowsOnOutOfRangeRange { OFData *data1 = [self.dataClass dataWithItems: "aaabaccdacaabb" count: 7 itemSize: 2]; OFData *data2 = [self.dataClass dataWithItems: "abcde" count: 5]; OTAssertThrowsSpecific([data1 subdataWithRange: OFMakeRange(7, 1)], OFOutOfRangeException); OTAssertThrowsSpecific([data1 subdataWithRange: OFMakeRange(8, 0)], OFOutOfRangeException); OTAssertThrowsSpecific([data2 subdataWithRange: OFMakeRange(6, 1)], OFOutOfRangeException); } - (void)testStringByMD5Hashing { OTAssertEqualObjects(_data.stringByMD5Hashing, @"37d65c8816008d58175b1d71ee892de3"); } - (void)testStringByRIPEMD160Hashing { OTAssertEqualObjects(_data.stringByRIPEMD160Hashing, @"ab33a6a725f9fcec6299054dc604c0eb650cd889"); } - (void)testStringBySHA1Hashing { OTAssertEqualObjects(_data.stringBySHA1Hashing, @"eb50cfcc29d0bed96b3bafe03e99110bcf6663b3"); } - (void)testStringBySHA224Hashing { OTAssertEqualObjects(_data.stringBySHA224Hashing, @"204f8418a914a6828f8eb27871e01f74366f6d8fac8936029ebf0041"); } - (void)testStringBySHA256Hashing { OTAssertEqualObjects(_data.stringBySHA256Hashing, @"27c521859f6f5b10aeac4e210a6d005c" @"85e382c594e2622af9c46c6da8906821"); } - (void)testStringBySHA384Hashing { OTAssertEqualObjects(_data.stringBySHA384Hashing, @"af99a52c26c00f01fe649dcc53d7c7a0" @"a9ee0150b971955be2af395708966120" @"5f2634f70df083ef63b232d5b8549db4"); } - (void)testStringBySHA512Hashing { OTAssertEqualObjects(_data.stringBySHA512Hashing, @"1cbd53bf8bed9b45a63edda645ee1217" @"24d2f0323c865e1039ba13320bc6c66e" @"c79b6cdf6d08395c612b7decb1e59ad1" @"e72bfa007c2f76a823d10204d47d2e2d"); } - (void)testStringByBase64Encoding { OTAssertEqualObjects([[self.dataClass dataWithItems: "abcde" count: 5] stringByBase64Encoding], @"YWJjZGU="); } - (void)testDataWithBase64EncodedString { OTAssertEqualObjects( [self.dataClass dataWithBase64EncodedString: @"YWJjZGU="], [OFData dataWithItems: "abcde" count: 5]); } @end |
Added new_tests/OFMutableDataTests.m version [6267c8f315].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 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 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * 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" #include <string.h> #import "OFDataTests.h" @interface OFMutableDataTests: OFDataTests { OFMutableData *_mutableData; } @end @implementation OFMutableDataTests - (Class)dataClass { return [OFMutableData class]; } - (void)setUp { [super setUp]; _mutableData = [[OFMutableData alloc] initWithItems: "abcdef" count: 6]; } - (void)dealloc { [_mutableData release]; [super dealloc]; } - (void)testMutableCopy { OTAssertEqualObjects([[_data mutableCopy] autorelease], _data); OTAssertNotEqual([[_data mutableCopy] autorelease], _data); } - (void)testAddItem { [_mutableData addItem: "g"]; OTAssertEqualObjects(_mutableData, [OFData dataWithItems: "abcdefg" count: 7]); } - (void)testAddItemsCount { [_mutableData addItems: "gh" count: 2]; OTAssertEqualObjects(_mutableData, [OFData dataWithItems: "abcdefgh" count: 8]); } - (void)testAddItemsCountThrowsOnOutOfRange { OTAssertThrowsSpecific([_mutableData addItems: "" count: SIZE_MAX], OFOutOfRangeException); } - (void)testRemoveLastItem { [_mutableData removeLastItem]; OTAssertEqualObjects(_mutableData, [OFData dataWithItems: "abcde" count: 5]); } - (void)testRemoveItemsInRange { [_mutableData removeItemsInRange: OFMakeRange(1, 2)]; OTAssertEqualObjects(_mutableData, [OFData dataWithItems: "adef" count: 4]); } - (void)testRemoveItemsInRangeThrowsOnOutOfRangeRange { OTAssertThrowsSpecific( [_mutableData removeItemsInRange: OFMakeRange(6, 1)], OFOutOfRangeException); OTAssertThrowsSpecific( [_mutableData removeItemsInRange: OFMakeRange(7, 0)], OFOutOfRangeException); } - (void)testInsertItemsAtIndexCount { [_mutableData insertItems: "BC" atIndex: 1 count: 2]; OTAssertEqualObjects(_mutableData, [OFData dataWithItems: "aBCbcdef" count: 8]); } - (void)testInsertItemsAtIndexCountThrowsOnOutOfRangeIndex { OTAssertThrowsSpecific( [_mutableData insertItems: "a" atIndex: 7 count: 1], OFOutOfRangeException); } @end |
Modified tests/Makefile from [e0a5057840] to [6ddbfcb2e3].
︙ | ︙ | |||
9 10 11 12 13 14 15 | ${PROG_NOINST}.nds \ ${PROG_NOINST}.nro \ ${PROG_NOINST}.rpx DISTCLEAN = Info.plist PROG_NOINST = tests${PROG_SUFFIX} STATIC_LIB_NOINST = ${TESTS_STATIC_LIB} | < | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ${PROG_NOINST}.nds \ ${PROG_NOINST}.nro \ ${PROG_NOINST}.rpx DISTCLEAN = Info.plist PROG_NOINST = tests${PROG_SUFFIX} STATIC_LIB_NOINST = ${TESTS_STATIC_LIB} SRCS = OFMemoryStreamTests.m \ OFStreamTests.m \ OFValueTests.m \ OFXMLNodeTests.m \ OFXMLParserTests.m \ TestsAppDelegate.m IOS_USER ?= mobile |
︙ | ︙ |