32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
OFData *immutable;
void *raw[2];
of_range_t range;
TEST(@"+[dataWithItemSize:]",
(mutable = [OFMutableData dataWithItemSize: 4096]))
OFObject *tmp = [[[OFObject alloc] init] autorelease];
raw[0] = [tmp allocMemoryWithSize: 4096];
raw[1] = [tmp allocMemoryWithSize: 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:]",
|
<
|
|
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
OFData *immutable;
void *raw[2];
of_range_t range;
TEST(@"+[dataWithItemSize:]",
(mutable = [OFMutableData dataWithItemSize: 4096]))
raw[0] = of_malloc(1, 4096);
raw[1] = of_malloc(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:]",
|
203
204
205
206
207
208
209
210
211
212
213
|
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)])
objc_autoreleasePoolPop(pool);
}
@end
|
>
>
>
|
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
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)])
free(raw[0]);
free(raw[1]);
objc_autoreleasePoolPop(pool);
}
@end
|