add a few character encoding tests

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37064 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-09-10 15:54:30 +00:00
parent a319576293
commit 852b3ff8e5

View file

@ -5,12 +5,19 @@
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
uint8_t bytes[256];
unichar u0 = 'a';
unichar u1 = 0xfe66;
int i = 256;
char buf[32];
NSString *s;
NSString *testObj = [NSString stringWithCString: "Hello\n"];
while (i-- > 0)
{
bytes[i] = (uint8_t)i;
}
test_alloc(@"NSString");
test_NSObject(@"NSString",[NSArray arrayWithObject:testObj]);
test_NSCoding([NSArray arrayWithObject:testObj]);
@ -45,6 +52,25 @@ int main()
"buffer length+1 works");
PASS(strcmp(buf, "hell") == 0, "getCString:maxLength:encoding");
PASS([(s = [[NSString alloc] initWithBytes: bytes
length: 256
encoding: NSISOLatin1StringEncoding])
isKindOfClass: [NSString class]]
&& ![s isKindOfClass: [NSMutableString class]],
"can create latin1 string with 256 values");
PASS([(s = [[NSString alloc] initWithBytes: bytes
length: 128
encoding: NSASCIIStringEncoding])
isKindOfClass: [NSString class]]
&& ![s isKindOfClass: [NSMutableString class]],
"can create ascii string with 128 values");
PASS(nil == [[NSString alloc] initWithBytes: bytes
length: 256
encoding: NSASCIIStringEncoding],
"reject 8bit characters in ascii");
[arp release]; arp = nil;
return 0;
}