PageRenderTime 60ms CodeModel.GetById 40ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/google-toolbox-for-mac/Foundation/GTMNSString+ReplaceTest.m

http://macfuse.googlecode.com/
Objective C | 59 lines | 28 code | 14 blank | 17 comment | 0 complexity | a4673b7629c3185dc9f1df341c3a5980 MD5 | raw file
 1//
 2//  GTMNSString+ReplaceTest.m
 3//
 4//  Copyright 2006-2008 Google Inc.
 5//
 6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 7//  use this file except in compliance with the License.  You may obtain a copy
 8//  of the License at
 9// 
10//  http://www.apache.org/licenses/LICENSE-2.0
11// 
12//  Unless required by applicable law or agreed to in writing, software
13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15//  License for the specific language governing permissions and limitations under
16//  the License.
17//
18
19#import "GTMSenTestCase.h"
20#import "GTMNSString+Replace.h"
21
22@interface GTMNSString_ReplaceTest : GTMTestCase
23@end
24
25@implementation GTMNSString_ReplaceTest
26
27#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
28
29- (void)testStringByReplacingStringWithString {
30  NSString *testString = @"a bc debc gh";
31  NSString *result;
32  
33  result = [testString gtm_stringByReplacingString:@"bc" withString:@"BC"];
34  STAssertEqualObjects(@"a BC deBC gh", result,
35                       @"'bc' wasn't replaced with 'BC'");
36  
37  result = [testString gtm_stringByReplacingString:@"bc" withString:@""];
38  STAssertEqualObjects(@"a  de gh", result, @"'bc' wasn't replaced with ''");
39  
40  result = [testString gtm_stringByReplacingString:@"bc" withString:nil];
41  STAssertEqualObjects(@"a  de gh", result, @"'bc' wasn't replaced with (nil)");
42  
43  result = [testString gtm_stringByReplacingString:@" " withString:@"S"];
44  STAssertEqualObjects(@"aSbcSdebcSgh", result, @"' ' wasn't replaced with 'S'");
45 
46  result = [testString gtm_stringByReplacingString:nil withString:@"blah"];
47  STAssertEqualObjects(testString, result, @"(nil) wasn't replaced with 'blah'");
48  
49  result = [testString gtm_stringByReplacingString:nil withString:nil];
50  STAssertEqualObjects(testString, result, @"(nil) wasn't replaced with (nil)");
51  
52  result = [testString gtm_stringByReplacingString:@"" withString:@"X"];
53  STAssertEqualObjects(testString, result,
54                       @"replacing '' with anything should yield the original string");
55}
56
57#endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
58
59@end