ObjFW  Diff

Differences From Artifact [bf4e4ccf3c]:

To Artifact [6ea1882c4f]:


29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43







-
+







@implementation TestsAppDelegate (OFSetTests)
- (void)setTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFSet *set1, *set2;
	OFMutableSet *mutableSet;
#ifdef OF_HAVE_FAST_ENUMERATION
	BOOL ok;
	bool ok;
	size_t i;
#endif

	TEST(@"+[setWithArray:]",
	    (set1 = [OFSet setWithArray: [OFArray arrayWithObjects: @"foo",
	    @"bar", @"baz", @"foo", @"x", nil]]))

88
89
90
91
92
93
94
95

96
97
98
99
100
101
102

103
104
105
106

107
108
109
110

111
112
113
114

115
116
117
118
119
120
121
122

123
124
125
126

127
128
129
130
131

132
133
134
135
136
137
138
139
88
89
90
91
92
93
94

95
96
97
98
99
100
101

102
103
104
105

106
107
108
109

110
111
112
113

114
115
116
117
118
119
120
121

122
123
124
125

126
127
128
129
130

131
132
133
134
135
136
137
138
139







-
+






-
+



-
+



-
+



-
+







-
+



-
+




-
+









	TEST(@"-[unionSet:]",
	    R([mutableSet unionSet: ([OFSet setWithObjects: @"x", @"bar",
	    nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz",
	    @"bar", @"x", nil])])

#ifdef OF_HAVE_FAST_ENUMERATION
	ok = YES;
	ok = true;
	i = 0;

	for (OFString *s in set1) {
		switch (i) {
		case 0:
			if (![s isEqual: @"x"])
				ok = NO;
				ok = false;
			break;
		case 1:
			if (![s isEqual: @"bar"])
				ok = NO;
				ok = false;
			break;
		case 2:
			if (![s isEqual: @"foo"])
				ok = NO;
				ok = false;
			break;
		case 3:
			if (![s isEqual: @"baz"])
				ok = NO;
				ok = false;
			break;
		}

		i++;
	}

	if (i != 4)
		ok = NO;
		ok = false;

	TEST(@"Fast enumeration", ok)

	ok = NO;
	ok = false;
	@try {
		for (OFString *s in mutableSet)
			[mutableSet removeObject: s];
	} @catch (OFEnumerationMutationException *e) {
		ok = YES;
		ok = true;
	}

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

	[pool drain];
}
@end