-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#import <Foundation/NSAutoreleasePool.h> | ||
#import <Foundation/NSString.h> | ||
#import "Testing.h" | ||
|
||
int main() | ||
{ | ||
NSAutoreleasePool *arp = [NSAutoreleasePool new]; | ||
NSString *result; | ||
|
||
result = [@"abc" commonPrefixWithString:nil options:0]; | ||
PASS_EQUAL(result, @"", "common prefix of some string with nil is empty string"); | ||
|
||
result = [@"abc" commonPrefixWithString:@"abc" options:0]; | ||
PASS_EQUAL(result, @"abc", "common prefix of identical strings is the entire string"); | ||
|
||
result = [@"abc" commonPrefixWithString:@"abx" options:0]; | ||
PASS_EQUAL(result, @"ab", "common prefix of 'abc' and 'abx' is 'ab'"); | ||
|
||
result = [@"abc" commonPrefixWithString:@"def" options:0]; | ||
PASS_EQUAL(result, @"", "common prefix of completely different strings is empty"); | ||
|
||
result = [@"abc" commonPrefixWithString:@"" options:0]; | ||
PASS_EQUAL(result, @"", "common prefix with an empty string is empty"); | ||
|
||
result = [@"abc" commonPrefixWithString:@"a" options:0]; | ||
PASS_EQUAL(result, @"a", "common prefix of 'abc' and 'a' is 'a'"); | ||
|
||
result = [@"abc" commonPrefixWithString:@"aöç" options:0]; | ||
PASS_EQUAL(result, @"a", "common prefix of 'abc' and 'aöç' is 'a'"); | ||
|
||
result = [@"" commonPrefixWithString:@"abc" options:0]; | ||
PASS_EQUAL(result, @"", "common prefix with an empty base string is empty"); | ||
|
||
result = [@"abc" commonPrefixWithString:@"abcx" options:0]; | ||
PASS_EQUAL(result, @"abc", "common prefix of 'abc' and 'abcx' is 'abc'"); | ||
|
||
[arp drain]; | ||
} | ||
|