Differences From Artifact [4a5c2852b2]:
- File
tests/OFDataTests.m
— part of check-in
[dc0c6c34ab]
at
2019-02-17 22:44:23
on branch trunk
— tests: Only import ObjFW.h
This prevents forgetting to add an import to ObjFW.h, as the tests would
then not compile. (user: js, size: 6966) [annotate] [blame] [check-ins using]
To Artifact [cec219c44a]:
- File tests/OFDataTests.m — part of check-in [b045cbb9c7] at 2019-03-25 00:21:30 on branch trunk — tests: Use dot syntax (user: js, size: 6901) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
45 46 47 48 49 50 51 | TEST(@"-[addItem:]", R([mutable addItem: raw[0]]) && R([mutable addItem: raw[1]])) TEST(@"-[itemAtIndex:]", memcmp([mutable itemAtIndex: 0], raw[0], 4096) == 0 && memcmp([mutable itemAtIndex: 1], raw[1], 4096) == 0) | | | | | | | < | | | | | 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 | TEST(@"-[addItem:]", R([mutable addItem: raw[0]]) && R([mutable addItem: raw[1]])) TEST(@"-[itemAtIndex:]", memcmp([mutable itemAtIndex: 0], raw[0], 4096) == 0 && memcmp([mutable itemAtIndex: 1], raw[1], 4096) == 0) TEST(@"-[lastItem]", memcmp(mutable.lastItem, raw[1], 4096) == 0) TEST(@"-[count]", mutable.count == 2) TEST(@"-[isEqual:]", (immutable = [OFData dataWithItems: mutable.items itemSize: mutable.itemSize count: mutable.count]) && [immutable isEqual: mutable] && R([mutable removeLastItem]) && ![mutable isEqual: immutable]) TEST(@"-[mutableCopy]", (mutable = [[immutable mutableCopy] autorelease]) && [mutable isEqual: immutable]) TEST(@"-[compare]", [mutable compare: immutable] == 0 && R([mutable removeLastItem]) && [immutable compare: mutable] == OF_ORDERED_DESCENDING && [mutable compare: immutable] == OF_ORDERED_ASCENDING && [[OFData dataWithItems: "aa" count: 2] compare: [OFData dataWithItems: "z" count: 1]] == OF_ORDERED_ASCENDING) TEST(@"-[hash]", immutable.hash == 0x634A529F) mutable = [OFMutableData dataWithItems: "abcdef" count: 6]; TEST(@"-[removeLastItem]", R([mutable removeLastItem]) && mutable.count == 5 && memcmp(mutable.items, "abcde", 5) == 0) TEST(@"-[removeItemsInRange:]", R([mutable removeItemsInRange: of_range(1, 2)]) && mutable.count == 3 && memcmp(mutable.items, "ade", 3) == 0) TEST(@"-[insertItems:atIndex:count:]", R([mutable insertItems: "bc" atIndex: 1 count: 2]) && mutable.count == 5 && memcmp(mutable.items, "abcde", 5) == 0) immutable = [OFData dataWithItems: "aaabaccdacaabb" itemSize: 2 count: 7]; TEST(@"-[rangeOfString:options:range:]", R(range = [immutable rangeOfData: [OFData dataWithItems: "aa" itemSize: 2 |
︙ | ︙ | |||
162 163 164 165 166 167 168 | EXPECT_EXCEPTION(@"-[subdataWithRange:] failing on out of range #1", OFOutOfRangeException, [immutable subdataWithRange: of_range(7, 1)]) EXPECT_EXCEPTION(@"-[subdataWithRange:] failing on out of range #2", OFOutOfRangeException, [mutable subdataWithRange: of_range(6, 1)]) | | | | | | | | | | | | | | | | | | 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 | EXPECT_EXCEPTION(@"-[subdataWithRange:] failing on out of range #1", OFOutOfRangeException, [immutable subdataWithRange: of_range(7, 1)]) EXPECT_EXCEPTION(@"-[subdataWithRange:] failing on out of range #2", OFOutOfRangeException, [mutable subdataWithRange: of_range(6, 1)]) TEST(@"-[MD5Hash]", [mutable.MD5Hash isEqual: @"abcde".MD5Hash]) TEST(@"-[RIPEMD160Hash]", [mutable.RIPEMD160Hash isEqual: @"abcde".RIPEMD160Hash]) TEST(@"-[SHA1Hash]", [mutable.SHA1Hash isEqual: @"abcde".SHA1Hash]) TEST(@"-[SHA224Hash]", [mutable.SHA224Hash isEqual: @"abcde".SHA224Hash]) TEST(@"-[SHA256Hash]", [mutable.SHA256Hash isEqual: @"abcde".SHA256Hash]) TEST(@"-[SHA384Hash]", [mutable.SHA384Hash isEqual: @"abcde".SHA384Hash]) TEST(@"-[SHA512Hash]", [mutable.SHA512Hash isEqual: @"abcde".SHA512Hash]) TEST(@"-[stringByBase64Encoding]", [mutable.stringByBase64Encoding isEqual: @"YWJjZGU="]) TEST(@"+[dataWithBase64EncodedString:]", memcmp([[OFData dataWithBase64EncodedString: @"YWJjZGU="] items], "abcde", 5) == 0) TEST(@"Building strings", (mutable = [OFMutableData dataWithItems: str count: 6]) && R([mutable addItem: ""]) && strcmp(mutable.items, str) == 0) EXPECT_EXCEPTION(@"Detect out of range in -[itemAtIndex:]", OFOutOfRangeException, [mutable itemAtIndex: mutable.count]) EXPECT_EXCEPTION(@"Detect out of range in -[addItems:count:]", OFOutOfRangeException, [mutable addItems: raw[0] count: SIZE_MAX]) EXPECT_EXCEPTION(@"Detect out of range in -[removeItemsInRange:]", OFOutOfRangeException, [mutable removeItemsInRange: of_range(mutable.count, 1)]) [pool drain]; } @end |