28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
EXPECT_EXCEPTION(@"Detect freeing of memory not allocated by object",
OFMemoryNotPartOfObjectException, [obj freeMemory: (void*)1])
TEST(@"Allocating 4096 bytes",
(p = [obj allocMemoryWithSize: 4096]) != NULL)
TEST(@"Freeing memory", [obj freeMemory: p])
EXPECT_EXCEPTION(@"Detect freeing of memory twice",
OFMemoryNotPartOfObjectException, [obj freeMemory: p])
TEST(@"Allocating and freeing 4096 bytes 3 times",
(p = [obj allocMemoryWithSize: 4096]) != NULL &&
(q = [obj allocMemoryWithSize: 4096]) != NULL &&
(r = [obj allocMemoryWithSize: 4096]) != NULL &&
[obj freeMemory: p] && [obj freeMemory: q] && [obj freeMemory: r])
EXPECT_EXCEPTION(@"Detect out of memory on alloc",
OFOutOfMemoryException, [obj allocMemoryWithSize: SIZE_MAX])
EXPECT_EXCEPTION(@"Detect out of memory on resize",
OFOutOfMemoryException,
{
|
|
>
|
|
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
|
EXPECT_EXCEPTION(@"Detect freeing of memory not allocated by object",
OFMemoryNotPartOfObjectException, [obj freeMemory: (void*)1])
TEST(@"Allocating 4096 bytes",
(p = [obj allocMemoryWithSize: 4096]) != NULL)
TEST(@"Freeing memory", R([obj freeMemory: p]))
EXPECT_EXCEPTION(@"Detect freeing of memory twice",
OFMemoryNotPartOfObjectException, [obj freeMemory: p])
TEST(@"Allocating and freeing 4096 bytes 3 times",
(p = [obj allocMemoryWithSize: 4096]) != NULL &&
(q = [obj allocMemoryWithSize: 4096]) != NULL &&
(r = [obj allocMemoryWithSize: 4096]) != NULL &&
R([obj freeMemory: p]) && R([obj freeMemory: q]) &&
R([obj freeMemory: r]))
EXPECT_EXCEPTION(@"Detect out of memory on alloc",
OFOutOfMemoryException, [obj allocMemoryWithSize: SIZE_MAX])
EXPECT_EXCEPTION(@"Detect out of memory on resize",
OFOutOfMemoryException,
{
|