ObjFW  Check-in [28543f9fd0]

Overview
Comment:Improve Fast Enumeration test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 28543f9fd06c2faadb723a4ada5d536194457ed7c4478a3182700d2d3018a4f4
User & Date: js on 2010-01-03 20:59:29
Other Links: manifest | tags
Context
2010-01-03
21:03
OFMutableDictionary: Add mutations counter. check-in: 4f18e380bf user: js tags: trunk
20:59
Improve Fast Enumeration test. check-in: 28543f9fd0 user: js tags: trunk
19:38
Throw an exception when trying to use +[dealloc]. check-in: 5e88aed650 user: js tags: trunk
Changes

Modified tests/OFArray.m from [927bb4293a] to [b076133918].

69
70
71
72
73
74
75


76
77
78
79




















80
81
82
83
84
85
86
#ifdef OF_HAVE_FAST_ENUMERATION
	size_t i = 0;
	BOOL ok = YES;

	for (OFString *s in a[0]) {
		if (![s isEqual: c_ary[i]])
			ok = NO;


		i++;
	}

	TEST(@"Fast Enumeration", ok)




















#endif

	TEST(@"-[replaceObject:withObject:]",
	    [a[0] replaceObject: c_ary[1]
		     withObject: c_ary[0]] &&
	    [[a[0] objectAtIndex: 0] isEqual: c_ary[0]] &&
	    [[a[0] objectAtIndex: 1] isEqual: c_ary[0]] &&







>
>




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifdef OF_HAVE_FAST_ENUMERATION
	size_t i = 0;
	BOOL ok = YES;

	for (OFString *s in a[0]) {
		if (![s isEqual: c_ary[i]])
			ok = NO;
		[a[0] replaceObjectAtIndex: i
				withObject: @""];
		i++;
	}

	TEST(@"Fast Enumeration", ok)

	[a[0] replaceObjectAtIndex: 0
			withObject: c_ary[0]];
	[a[0] replaceObjectAtIndex: 1
			withObject: c_ary[1]];
	[a[0] replaceObjectAtIndex: 2
			withObject: c_ary[2]];

	ok = NO;
	@try {
		for (OFString *s in a[0])
			[a[0] addObject: @""];
	} @catch (OFEnumerationMutationException *e) {
		ok = YES;
		[e dealloc];
	}

	TEST(@"Detection of mutation during Fast Enumeration", ok)

	[a[0] removeNObjects: 1];
#endif

	TEST(@"-[replaceObject:withObject:]",
	    [a[0] replaceObject: c_ary[1]
		     withObject: c_ary[0]] &&
	    [[a[0] objectAtIndex: 0] isEqual: c_ary[0]] &&
	    [[a[0] objectAtIndex: 1] isEqual: c_ary[0]] &&