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
|
#import <stdio.h>
#import <stdlib.h>
#import "OFObject.h"
#import "OFExceptions.h"
#define CATCH_EXCEPTION(code, exception) \
caught = NO; \
@try { \
code; \
} @catch (exception *e) { \
caught = YES; \
puts("CAUGHT! Error string was:"); \
puts([e cString]); \
puts("Resuming..."); \
} \
if (!caught) { \
puts("NOT CAUGHT!"); \
return 1; \
}
int
main()
{
OFObject *obj = [OFObject new];
BOOL caught;
void *p, *q, *r;
/* Test freeing memory not allocated by obj */
puts("Freeing memory not allocated by object (should throw an "
"exception)...");
CATCH_EXCEPTION([obj freeMem: NULL], OFMemNotPartOfObjException)
|
<
>
>
>
<
<
<
<
<
<
|
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
|
#import <stdio.h>
#import <stdlib.h>
#import "OFObject.h"
#import "OFExceptions.h"
#define CATCH_EXCEPTION(code, exception) \
@try { \
code; \
\
puts("NOT CAUGHT!"); \
return 1; \
} @catch (exception *e) { \
puts("CAUGHT! Error string was:"); \
puts([e cString]); \
puts("Resuming..."); \
}
int
main()
{
OFObject *obj = [OFObject new];
void *p, *q, *r;
/* Test freeing memory not allocated by obj */
puts("Freeing memory not allocated by object (should throw an "
"exception)...");
CATCH_EXCEPTION([obj freeMem: NULL], OFMemNotPartOfObjException)
|