28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
void
array_tests()
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFArray *a[2];
OFMutableArray *m[2];
TEST(@"+[array]", (m[0] = [OFMutableArray array]))
TEST(@"+[arrayWithObjects:]",
(a[0] = [OFArray arrayWithObjects: @"Foo", @"Bar", @"Baz", nil]))
TEST(@"+[arrayWithCArray:]", (a[1] = [OFArray arrayWithCArray: c_ary]))
|
>
>
>
>
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
void
array_tests()
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFArray *a[2];
OFMutableArray *m[2];
OFEnumerator *enumerator;
id obj;
BOOL ok;
size_t i;
TEST(@"+[array]", (m[0] = [OFMutableArray array]))
TEST(@"+[arrayWithObjects:]",
(a[0] = [OFArray arrayWithObjects: @"Foo", @"Bar", @"Baz", nil]))
TEST(@"+[arrayWithCArray:]", (a[1] = [OFArray arrayWithCArray: c_ary]))
|
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
EXPECT_EXCEPTION(@"Detect out of range in -[removeNItems:]",
OFOutOfRangeException, [m[0] removeNObjects: [m[0] count] + 1])
a[1] = [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil];
TEST(@"-[componentsJoinedByString:]",
[[a[1] componentsJoinedByString: @" "] isEqual: @"foo bar baz"])
#ifdef OF_HAVE_FAST_ENUMERATION
size_t i = 0;
BOOL ok = YES;
m[0] = [[a[0] mutableCopy] autorelease];
for (OFString *s in m[0]) {
if (![s isEqual: c_ary[i]])
ok = NO;
[m[0] replaceObjectAtIndex: i
withObject: @""];
i++;
|
|
>
|
>
>
>
>
>
|
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
EXPECT_EXCEPTION(@"Detect out of range in -[removeNItems:]",
OFOutOfRangeException, [m[0] removeNObjects: [m[0] count] + 1])
a[1] = [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil];
TEST(@"-[componentsJoinedByString:]",
[[a[1] componentsJoinedByString: @" "] isEqual: @"foo bar baz"])
m[0] = [[a[0] mutableCopy] autorelease];
ok = YES;
i = 0;
TEST(@"-[enumerator]", (enumerator = [m[0] enumerator]))
while ((obj = [enumerator nextObject]) != nil) {
if (![obj isEqual: c_ary[i]])
ok = NO;
[m[0] replaceObjectAtIndex: i
withObject: @""];
i++;
}
TEST(@"OFEnumerator's -[nextObject]", ok)
[enumerator reset];
[m[0] removeObjectAtIndex: 0];
EXPECT_EXCEPTION(@"Detection of mutation during enumeration",
OFEnumerationMutationException, [enumerator nextObject])
#ifdef OF_HAVE_FAST_ENUMERATION
m[0] = [[a[0] mutableCopy] autorelease];
ok = YES;
i = 0;
for (OFString *s in m[0]) {
if (![s isEqual: c_ary[i]])
ok = NO;
[m[0] replaceObjectAtIndex: i
withObject: @""];
i++;
|