30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
OFData *immutable;
void *raw[2];
OFRange range;
TEST(@"+[dataWithItemSize:]",
(mutable = [OFMutableData dataWithItemSize: 4096]))
raw[0] = of_alloc(1, 4096);
raw[1] = of_alloc(1, 4096);
memset(raw[0], 0xFF, 4096);
memset(raw[1], 0x42, 4096);
TEST(@"-[addItem:]", R([mutable addItem: raw[0]]) &&
R([mutable addItem: raw[1]]))
TEST(@"-[itemAtIndex:]",
|
|
|
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
OFData *immutable;
void *raw[2];
OFRange range;
TEST(@"+[dataWithItemSize:]",
(mutable = [OFMutableData dataWithItemSize: 4096]))
raw[0] = OFAllocMemory(1, 4096);
raw[1] = OFAllocMemory(1, 4096);
memset(raw[0], 0xFF, 4096);
memset(raw[1], 0x42, 4096);
TEST(@"-[addItem:]", R([mutable addItem: raw[0]]) &&
R([mutable addItem: raw[1]]))
TEST(@"-[itemAtIndex:]",
|
214
215
216
217
218
219
220
221
222
223
224
225
226
|
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: OFRangeMake(mutable.count, 1)])
free(raw[0]);
free(raw[1]);
objc_autoreleasePoolPop(pool);
}
@end
|
|
|
|
214
215
216
217
218
219
220
221
222
223
224
225
226
|
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: OFRangeMake(mutable.count, 1)])
OFFreeMemory(raw[0]);
OFFreeMemory(raw[1]);
objc_autoreleasePoolPop(pool);
}
@end
|