ObjFW  Check-in [8a14ad35aa]

Overview
Comment:OFArray: Fix bug introduced by refactorization

Also improves the test to prevent this from happening again.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8a14ad35aa96faba80ef9b98ed12e9c29034fde0710ca90e915091316dd32950
User & Date: js on 2016-02-21 11:59:44
Other Links: manifest | tags
Context
2016-02-21
12:04
Add +[OFURL fileURLWithPath:] check-in: 3eb411511e user: js tags: trunk
11:59
OFArray: Fix bug introduced by refactorization check-in: 8a14ad35aa user: js tags: trunk
10:52
OFURL.h: Add missing @brief to documentation check-in: 2a6c3df320 user: js tags: trunk
Changes

Modified src/OFArray.m from [20c7045513] to [a01924feba].

418
419
420
421
422
423
424


425
426
427
428


429

430
431
432
433
434
435
436
					[ret appendString: separator];
				[ret appendString: component];
			}

			objc_autoreleasePoolPop(pool);
		}
	} else {


		for (id object in self) {
			void *pool = objc_autoreleasePoolPush();

			if ([ret length] > 0)


				[ret appendString: separator];

			[ret appendString: [object performSelector: selector]];

			objc_autoreleasePoolPop(pool);
		}
	}

	[ret makeImmutable];







>
>



|
>
>

>







418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
					[ret appendString: separator];
				[ret appendString: component];
			}

			objc_autoreleasePoolPop(pool);
		}
	} else {
		bool first = true;

		for (id object in self) {
			void *pool = objc_autoreleasePoolPush();

			if OF_UNLIKELY (first)
				first = false;
			else
				[ret appendString: separator];

			[ret appendString: [object performSelector: selector]];

			objc_autoreleasePoolPop(pool);
		}
	}

	[ret makeImmutable];

Modified tests/OFArrayTests.m from [1c3890f806] to [ea65aa5e42].

160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	    OFOutOfRangeException, [a[0] objectAtIndex: [a[0] count]])

	EXPECT_EXCEPTION(@"Detect out of range in -[removeObjectsInRange:]",
	    OFOutOfRangeException, [m[0] removeObjectsInRange:
		of_range(0, [m[0] count] + 1)])

	TEST(@"-[componentsJoinedByString:]",
	    (a[1] = [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]) &&
	    [[a[1] componentsJoinedByString: @" "] isEqual: @"foo bar baz"] &&
	    (a[1] = [OFArray arrayWithObject: @"foo"]) &&
	    [[a[1] componentsJoinedByString: @" "] isEqual: @"foo"])

	TEST(@"-[componentsJoinedByString:options]",
	    (a[1] = [OFArray arrayWithObjects: @"", @"foo", @"", @"", @"bar",
	    @"", nil]) && [[a[1] componentsJoinedByString: @" "
						  options: OF_ARRAY_SKIP_EMPTY]







|
|







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	    OFOutOfRangeException, [a[0] objectAtIndex: [a[0] count]])

	EXPECT_EXCEPTION(@"Detect out of range in -[removeObjectsInRange:]",
	    OFOutOfRangeException, [m[0] removeObjectsInRange:
		of_range(0, [m[0] count] + 1)])

	TEST(@"-[componentsJoinedByString:]",
	    (a[1] = [OFArray arrayWithObjects: @"", @"a", @"b", @"c", nil]) &&
	    [[a[1] componentsJoinedByString: @" "] isEqual: @" a b c"] &&
	    (a[1] = [OFArray arrayWithObject: @"foo"]) &&
	    [[a[1] componentsJoinedByString: @" "] isEqual: @"foo"])

	TEST(@"-[componentsJoinedByString:options]",
	    (a[1] = [OFArray arrayWithObjects: @"", @"foo", @"", @"", @"bar",
	    @"", nil]) && [[a[1] componentsJoinedByString: @" "
						  options: OF_ARRAY_SKIP_EMPTY]