ObjFW  Diff

Differences From Artifact [fbc369ef09]:

  • File tests/OFStringTests.m — part of check-in [4d892e0db1] at 2013-07-04 20:49:52 on branch trunk — Fix -[replaceCharactersInRange:withString:].

    The resizing is now done before the memmove() if the new string is
    bigger and after the memmove() if the new string is shorter. The added
    comment explains why this is necessary.

    This also adds a test for -[replaceCharactersInRange:withString:] that
    makes the string bigger and another one that makes it smaller again. (user: js, size: 23140) [annotate] [blame] [check-ins using]

To Artifact [a5ba78df50]:


278
279
280
281
282
283
284
285

286
287
288
289
290
291
292

293
294
295
296
297
298
299
	    componentsSeparatedByString: @"XX"
				options: OF_STRING_SKIP_EMPTY]) &&
	    [a count] == 3 &&
	    [[a objectAtIndex: i++] isEqual: @"foo"] &&
	    [[a objectAtIndex: i++] isEqual: @"bar"] &&
	    [[a objectAtIndex: i++] isEqual: @"baz"])

	TEST(@"+[stringWithPath:]",

	    (is = [OFString stringWithPath: @"foo", @"bar", @"baz", nil]) &&
#ifndef _WIN32
	    [is isEqual: @"foo/bar/baz"] &&
#else
	    [is isEqual: @"foo\\bar\\baz"] &&
#endif
	    (is = [OFString stringWithPath: @"foo", nil]) &&

	    [is isEqual: @"foo"])

	TEST(@"-[pathComponents]",
	    /* /tmp */
	    (a = [@"/tmp" pathComponents]) && [a count] == 2 &&
	    [[a objectAtIndex: 0] isEqual: @""] &&
	    [[a objectAtIndex: 1] isEqual: @"tmp"] &&







|
>
|





|
>







278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
	    componentsSeparatedByString: @"XX"
				options: OF_STRING_SKIP_EMPTY]) &&
	    [a count] == 3 &&
	    [[a objectAtIndex: i++] isEqual: @"foo"] &&
	    [[a objectAtIndex: i++] isEqual: @"bar"] &&
	    [[a objectAtIndex: i++] isEqual: @"baz"])

	TEST(@"+[pathWithComponents:]",
	    (is = [OFString pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]]) &&
#ifndef _WIN32
	    [is isEqual: @"foo/bar/baz"] &&
#else
	    [is isEqual: @"foo\\bar\\baz"] &&
#endif
	    (is = [OFString pathWithComponents:
	    [OFArray arrayWithObjects: @"foo", nil]]) &&
	    [is isEqual: @"foo"])

	TEST(@"-[pathComponents]",
	    /* /tmp */
	    (a = [@"/tmp" pathComponents]) && [a count] == 2 &&
	    [[a objectAtIndex: 0] isEqual: @""] &&
	    [[a objectAtIndex: 1] isEqual: @"tmp"] &&