William Bowling is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

wbowling / adium (fork of adium / adium)

Fork of Adium for patches/improvements

Clone this repository (size: 338.7 MB): HTTPS / SSH
hg clone https://bitbucket.org/wbowling/adium
hg clone ssh://hg@bitbucket.org/wbowling/adium

adium / UnitTests / TestMutableStringAdditions.m

#import "TestMutableStringAdditions.h"
#import "AIUnitTestUtilities.h"

#import <AIUtilities/AIMutableStringAdditions.h>

@implementation TestMutableStringAdditions

- (void)testReplaceOccurrencesOfString_withString_options
{
        NSMutableString *testString = [NSMutableString stringWithString:@"The quick brown fox jumped over the other quick brown fox"];
        
        //first make the string longer
        [testString replaceOccurrencesOfString:@"brown" withString:@"kinda lime-green with a bit of ecru" options:NSLiteralSearch];
        AISimplifiedAssertEqualObjects([NSMutableString stringWithString:@"The quick kinda lime-green with a bit of ecru fox jumped over the other quick kinda lime-green with a bit of ecru fox"], 
                                                                   testString, 
                                                                   @"Modified string wasn't equal to hand-made modified string");
        
        //next, try replacing something at the end; if the range didn't expand, this will fail
        [testString replaceOccurrencesOfString:@"fox" withString:@"aardvark" options:NSLiteralSearch];
        AISimplifiedAssertEqualObjects([NSMutableString stringWithString:@"The quick kinda lime-green with a bit of ecru aardvark jumped over the other quick kinda lime-green with a bit of ecru aardvark"], 
                                                                   testString, 
                                                                   @"After making the string longer, modifications no longer took into account the full length");
}

@end