ObjFW  Check-in [83618d5a08]

Overview
Comment:Fix a test on DragonFlyBSD.

DragonFlyBSD has problems with too big values passed to malloc() or
realloc(), thus, make them smaller on DragonFlyBSD.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 83618d5a08f892b027e64711221c65fb148d955283a6e2e30c7e21b5acad04b6
User & Date: js on 2012-10-21 22:13:34
Other Links: manifest | tags
Context
2012-10-22
20:11
PLATFORMS.md: Add DragonFlyBSD. check-in: c2d05e0469 user: js tags: trunk
2012-10-21
22:13
Fix a test on DragonFlyBSD. check-in: 83618d5a08 user: js tags: trunk
22:12
Make GCC 4.4 happy. check-in: fcade8da38 user: js tags: trunk
Changes

Modified tests/OFObjectTests.m from [dd072d17db] to [f82008a12d].

19
20
21
22
23
24
25






26
27
28
29
30
31
32
#import "OFString.h"
#import "OFAutoreleasePool.h"

#import "OFMemoryNotPartOfObjectException.h"
#import "OFOutOfMemoryException.h"

#import "TestsAppDelegate.h"







static OFString *module = @"OFObject";

@interface MyObj: OFObject
@end

@implementation MyObj







>
>
>
>
>
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#import "OFString.h"
#import "OFAutoreleasePool.h"

#import "OFMemoryNotPartOfObjectException.h"
#import "OFOutOfMemoryException.h"

#import "TestsAppDelegate.h"

#if defined(__DragonFly__) && defined(__LP64__)
# define TOO_BIG (SIZE_MAX / 3)
#else
# define TOO_BIG (SIZE_MAX - 128)
#endif

static OFString *module = @"OFObject";

@interface MyObj: OFObject
@end

@implementation MyObj
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
	    R([obj freeMemory: r]))

	tmp = [self allocMemoryWithSize: 1024];
	EXPECT_EXCEPTION(@"Detect freeing of memory not allocated by object",
	    OFMemoryNotPartOfObjectException, [obj freeMemory: tmp])

	EXPECT_EXCEPTION(@"Detect out of memory on alloc",
	    OFOutOfMemoryException, [obj allocMemoryWithSize: SIZE_MAX - 128])

	EXPECT_EXCEPTION(@"Detect out of memory on resize",
	    OFOutOfMemoryException,
	    {
		p = [obj allocMemoryWithSize: 1];
		[obj resizeMemory: p
			     size: SIZE_MAX - 128];
	    })
	[obj freeMemory: p];

	TEST(@"Allocate when trying to resize NULL",
	    (p = [obj resizeMemory: NULL
			      size: 1024]) != NULL)
	[obj freeMemory: p];







|






|







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	    R([obj freeMemory: r]))

	tmp = [self allocMemoryWithSize: 1024];
	EXPECT_EXCEPTION(@"Detect freeing of memory not allocated by object",
	    OFMemoryNotPartOfObjectException, [obj freeMemory: tmp])

	EXPECT_EXCEPTION(@"Detect out of memory on alloc",
	    OFOutOfMemoryException, [obj allocMemoryWithSize: TOO_BIG])

	EXPECT_EXCEPTION(@"Detect out of memory on resize",
	    OFOutOfMemoryException,
	    {
		p = [obj allocMemoryWithSize: 1];
		[obj resizeMemory: p
			     size: TOO_BIG];
	    })
	[obj freeMemory: p];

	TEST(@"Allocate when trying to resize NULL",
	    (p = [obj resizeMemory: NULL
			      size: 1024]) != NULL)
	[obj freeMemory: p];