ObjFW  Check-in [dc4f1a26d6]

Overview
Comment:Also test for exceptions from OFObject's resizeMem:.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: dc4f1a26d61c1b2fc57f6e5cf3870e0ee175e66d99db0152c8219adcda4b9d16
User & Date: js on 2008-09-14 19:41:21
Other Links: manifest | tags
Context
2008-09-14
19:54
More portable test running. check-in: 7700e033a9 user: js tags: trunk
19:41
Also test for exceptions from OFObject's resizeMem:. check-in: dc4f1a26d6 user: js tags: trunk
19:38
%zd -> %zu. check-in: 7cc77e2a1b user: js tags: trunk
Changes

Modified src/OFExceptions.m from [637d243e7f] to [f7b03ef0d0].

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
	return [[OFNoMemException alloc] init: obj
				     withSize: size];
}

-     init: (id)obj
  withSize: (size_t)size
{
	fprintf(stderr, "ERROR: Could not allocate %zu byte for object %s!\n",
	    size, [obj name]);

	return [super init];
}
@end

@implementation OFMemNotPartOfObjException







|







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
	return [[OFNoMemException alloc] init: obj
				     withSize: size];
}

-     init: (id)obj
  withSize: (size_t)size
{
	fprintf(stderr, "ERROR: Could not allocate %zu bytes for object %s!\n",
	    size, [obj name]);

	return [super init];
}
@end

@implementation OFMemNotPartOfObjException

Modified tests/OFObject/OFObject.m from [201b5d89a5] to [9d8c2f0a96].

74
75
76
77
78
79
80







81
82
83
84
85
	CATCH_EXCEPTION([obj freeMem: p], OFMemNotPartOfObjException)
	CATCH_EXCEPTION([obj freeMem: q], OFMemNotPartOfObjException)
	CATCH_EXCEPTION([obj freeMem: r], OFMemNotPartOfObjException)
	puts("Got all 3!");
	
	puts("Trying to allocate more memory than possible...");
	CATCH_EXCEPTION(p = [obj getMem: 4294967295U], OFNoMemException)







	
	/* TODO: Test if freeing object frees all memory */

	return 0;
}







>
>
>
>
>
>
>





74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
	CATCH_EXCEPTION([obj freeMem: p], OFMemNotPartOfObjException)
	CATCH_EXCEPTION([obj freeMem: q], OFMemNotPartOfObjException)
	CATCH_EXCEPTION([obj freeMem: r], OFMemNotPartOfObjException)
	puts("Got all 3!");
	
	puts("Trying to allocate more memory than possible...");
	CATCH_EXCEPTION(p = [obj getMem: 4294967295U], OFNoMemException)

	puts("Allocating 1 byte...");
	p = [obj getMem: 1];

	puts("Trying to resize that 1 byte to more than possible...");
	CATCH_EXCEPTION(p = [obj resizeMem: p toSize: 4294967295U],
	    OFNoMemException)
	
	/* TODO: Test if freeing object frees all memory */

	return 0;
}