@@ -218,29 +218,18 @@ [@"π„žΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆΓΆ"] == 1 && [@"π„žΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆ"] == 2 && [@"π„žΓΆΓΆ" indexOfLastOccurrenceOfString: @"π„ž"] == 0 && [@"π„žΓΆΓΆ" indexOfLastOccurrenceOfString: @"x"] == OF_INVALID_INDEX) - TEST(@"-[substringFromIndexToIndex:]", - [[@"π„žΓΆΓΆ" substringFromIndex: 1 - toIndex: 2] isEqual: @"ΓΆ"] && - [[@"π„žΓΆΓΆ" substringFromIndex: 3 - toIndex: 3] isEqual: @""]) - - EXPECT_EXCEPTION(@"Detect out of range in " - @"-[substringFromIndex:toIndex:] #1", OFOutOfRangeException, - [@"π„žΓΆΓΆ" substringFromIndex: 2 - toIndex: 4]) - EXPECT_EXCEPTION(@"Detect out of range in " - @"-[substringFromIndex:toIndex:] #2", OFOutOfRangeException, - [@"π„žΓΆΓΆ" substringFromIndex: 4 - toIndex: 4]) - - EXPECT_EXCEPTION(@"Detect start > end in " - @"-[substringFromIndex:toIndex:]", OFInvalidArgumentException, - [@"π„žΓΆΓΆ" substringFromIndex: 2 - toIndex: 0]) + TEST(@"-[substringWithRange:]", + [[@"π„žΓΆΓΆ" substringWithRange: of_range(1, 1)] isEqual: @"ΓΆ"] && + [[@"π„žΓΆΓΆ" substringWithRange: of_range(3, 0)] isEqual: @""]) + + EXPECT_EXCEPTION(@"Detect out of range in -[substringWithRange:] #1", + OFOutOfRangeException, [@"π„žΓΆΓΆ" substringWithRange: of_range(2, 2)]) + EXPECT_EXCEPTION(@"Detect out of range in -[substringWithRange:] #2", + OFOutOfRangeException, [@"π„žΓΆΓΆ" substringWithRange: of_range(4, 0)]) TEST(@"-[stringByAppendingString:]", [[@"foo" stringByAppendingString: @"bar"] isEqual: @"foobar"]) TEST(@"-[stringByPrependingString:]", @@ -412,67 +401,46 @@ @"#1", OFInvalidEncodingException, [@"foo%bar" stringByURLDecoding]) EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] " @"#2", OFInvalidEncodingException, [@"foo%FFbar" stringByURLDecoding]) - TEST(@"-[deleteCharactersFromIndex:toIndex:]", - (s[0] = [OFMutableString stringWithString: @"π„žΓΆΓΆΓΆbÀ€"]) && - R([s[0] deleteCharactersFromIndex: 1 - toIndex: 4]) && - [s[0] isEqual: @"π„žbÀ€"] && - R([s[0] deleteCharactersFromIndex: 0 - toIndex: 4]) && - [s[0] isEqual: @""]) - - TEST(@"-[replaceCharactersFromIndex:toIndex:withString:]", - (s[0] = [OFMutableString stringWithString: @"π„žΓΆΓΆΓΆbÀ€"]) && - R([s[0] replaceCharactersFromIndex: 1 - toIndex: 4 - withString: @"Àâü"]) && - [s[0] isEqual: @"π„žΓ€ΓΆΓΌbÀ€"] && - R([s[0] replaceCharactersFromIndex: 0 - toIndex: 7 - withString: @""]) && - [s[0] isEqual: @""]) - - EXPECT_EXCEPTION(@"Detect OoR in " - @"-[deleteCharactersFromIndex:toIndex:] #1", OFOutOfRangeException, - { - s[0] = [OFMutableString stringWithString: @"π„žΓΆΓΆ"]; - [s[0] deleteCharactersFromIndex: 2 - toIndex: 4]; + TEST(@"-[deleteCharactersInRange:]", + (s[0] = [OFMutableString stringWithString: @"π„žΓΆΓΆΓΆbÀ€"]) && + R([s[0] deleteCharactersInRange: of_range(1, 3)]) && + [s[0] isEqual: @"π„žbÀ€"] && + R([s[0] deleteCharactersInRange: of_range(0, 4)]) && + [s[0] isEqual: @""]) + + TEST(@"-[replaceCharactersInRange:withString:]", + (s[0] = [OFMutableString stringWithString: @"π„žΓΆΓΆΓΆbÀ€"]) && + R([s[0] replaceCharactersInRange: of_range(1, 3) + withString: @"Àâü"]) && + [s[0] isEqual: @"π„žΓ€ΓΆΓΌbÀ€"] && + R([s[0] replaceCharactersInRange: of_range(0, 7) + withString: @""]) && + [s[0] isEqual: @""]) + + EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #1", + OFOutOfRangeException, + { + s[0] = [OFMutableString stringWithString: @"π„žΓΆΓΆ"]; + [s[0] deleteCharactersInRange: of_range(2, 2)]; }) - EXPECT_EXCEPTION(@"Detect OoR in " - @"-[deleteCharactersFromIndex:toIndex:] #2", OFOutOfRangeException, - [s[0] deleteCharactersFromIndex: 4 - toIndex: 4]) - - EXPECT_EXCEPTION(@"Detect s > e in " - @"-[deleteCharactersFromIndex:toIndex:]", - OFInvalidArgumentException, - [s[0] deleteCharactersFromIndex: 2 - toIndex: 0]) - - EXPECT_EXCEPTION(@"OoR " - @"-[replaceCharactersFromIndex:toIndex:withString:] #1", - OFOutOfRangeException, [s[0] replaceCharactersFromIndex: 2 - toIndex: 4 - withString: @""]) - - EXPECT_EXCEPTION(@"OoR " - @"-[replaceCharactersFromIndex:toIndex:withString:] #2", + EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #2", + OFOutOfRangeException, + [s[0] deleteCharactersInRange: of_range(4, 0)]) + + 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", OFOutOfRangeException, - [s[0] replaceCharactersFromIndex: 4 - toIndex: 4 - withString: @""]) - - EXPECT_EXCEPTION(@"s>e in " - @"-[replaceCharactersFromIndex:toIndex:withString:]", - OFInvalidArgumentException, [s[0] replaceCharactersFromIndex: 2 - toIndex: 0 - withString: @""]) + [s[0] replaceCharactersInRange: of_range(4, 0) + withString: @""]) TEST(@"-[replaceOccurrencesOfString:withString:]", (s[0] = [OFMutableString stringWithString: @"asd fo asd fofo asd"]) && R([s[0] replaceOccurrencesOfString: @"fo"