mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
add substring test
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34864 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ecaf57e6ce
commit
fc5be9646b
1 changed files with 14 additions and 1 deletions
|
@ -252,8 +252,11 @@ static void testLineRange(char *s, NSRange range, NSRange want)
|
|||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *str;
|
||||
NSString *sub;
|
||||
char buf[10];
|
||||
|
||||
PASS_EXCEPTION([NSString stringWithUTF8String: 0],
|
||||
NSInvalidArgumentException,
|
||||
|
@ -355,6 +358,16 @@ int main()
|
|||
PASS([@"1.2e3" doubleValue] == 1.2e3, "Simple double conversion works");
|
||||
PASS([@"4.5E6" floatValue] == 4.5e6, "Simple float conversion works");
|
||||
|
||||
strcpy(buf, "xxaaaxx");
|
||||
str = [[NSString alloc] initWithBytesNoCopy: buf
|
||||
length: 7
|
||||
encoding: NSASCIIStringEncoding
|
||||
freeWhenDone: NO];
|
||||
sub = [str substringWithRange: NSMakeRange(2, 3)];
|
||||
strcpy(buf, "xxbbbxx");
|
||||
PASS_EQUAL(str, @"xxbbbxx", "a no-copy string uses the buffer");
|
||||
[str release];
|
||||
PASS_EQUAL(sub, @"aaa", "a substring uses its own buffer");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue