ObjFW  Check-in [f68b3b300d]

Overview
Comment:Remove useless checks.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f68b3b300d56937d5b723786a4019b325c7f1c67339fffcd20e943a3f7630766
User & Date: js on 2012-01-31 15:16:27
Other Links: manifest | tags
Context
2012-01-31
18:59
Add -[OFMutableString replaceOccurrencesOfString:withString:inRange:]. check-in: e5fe02de61 user: js tags: trunk
15:16
Remove useless checks. check-in: f68b3b300d user: js tags: trunk
14:32
Fix -[OFMutableString_UTF8 replaceCharactersInRange:withString:]. check-in: 607c862411 user: js tags: trunk
Changes

Modified src/OFMutableString_UTF8.m from [5552cd8f9b] to [8b0f05ccee].

473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
473
474
475
476
477
478
479




480
481
482
483
484
485
486







-
-
-
-







}

- (void)deleteCharactersInRange: (of_range_t)range
{
	size_t start = range.start;
	size_t end = range.start + range.length;

	if (start > end)
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	if (end > s->length)
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	s->hashed = NO;
	s->length -= end - start;

	if (s->UTF8) {
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
505
506
507
508
509
510
511




512
513
514
515
516
517
518







-
-
-
-







- (void)replaceCharactersInRange: (of_range_t)range
		      withString: (OFString*)replacement
{
	size_t start = range.start;
	size_t end = range.start + range.length;
	size_t newCStringLength, newLength;

	if (start > end)
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	if (end > s->length)
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	newLength = s->length - (end - start) + [replacement length];

	if (s->UTF8) {
		start = of_string_index_to_position(s->cString, start,

Modified tests/OFStringTests.m from [00960fc024] to [99e29fe6af].

453
454
455
456
457
458
459
460


461
462
463
464
465


466
467
468
469
470
471
472
453
454
455
456
457
458
459

460
461
462
463
464
465

466
467
468
469
470
471
472
473
474







-
+
+




-
+
+







		[s[0] deleteCharactersInRange: of_range(2, 2)];
	    })

	EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #2",
	    OFOutOfRangeException,
	    [s[0] deleteCharactersInRange: of_range(4, 0)])

	EXPECT_EXCEPTION(@"Detect OoR in -[replaceCharactersInRange:withString:] #1",
	EXPECT_EXCEPTION(@"Detect OoR in "
	    @"-[replaceCharactersInRange:withString:] #1",
	    OFOutOfRangeException,
	    [s[0] replaceCharactersInRange: of_range(2, 2)
				withString: @""])

	EXPECT_EXCEPTION(@"Detect OoR in -[replaceCharactersInRange:withString:] #2",
	EXPECT_EXCEPTION(@"Detect OoR in "
	    @"-[replaceCharactersInRange:withString:] #2",
	    OFOutOfRangeException,
	    [s[0] replaceCharactersInRange: of_range(4, 0)
				withString: @""])

	TEST(@"-[replaceOccurrencesOfString:withString:]",
	    (s[0] = [OFMutableString stringWithString:
	    @"asd fo asd fofo asd"]) &&