2016-09-26 10:59:02 +00:00
|
|
|
/* Test for unicode noncharacter codepoints
|
|
|
|
*/
|
|
|
|
#import "Testing.h"
|
|
|
|
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
NSString *str;
|
|
|
|
unichar u;
|
2016-10-11 12:35:29 +00:00
|
|
|
unichar u2[2];
|
2016-09-26 11:11:05 +00:00
|
|
|
u = (unichar)0xfdd0;
|
|
|
|
str = [[NSString alloc] initWithCharacters: &u length: 1];
|
2016-10-11 17:12:31 +00:00
|
|
|
PASS([str length] == 1, "fdd0 codepoint is permitted in string");
|
2016-09-26 11:11:05 +00:00
|
|
|
PASS([str characterAtIndex: 0] == 0xfdd0, "fdd0 is returned properly");
|
|
|
|
[str release];
|
|
|
|
|
|
|
|
u = (unichar)0xfdef;
|
|
|
|
str = [[NSString alloc] initWithCharacters: &u length: 1];
|
2016-10-11 17:12:31 +00:00
|
|
|
PASS([str length] == 1, "fdef codepoint is permitted in string");
|
2016-09-26 11:11:05 +00:00
|
|
|
PASS([str characterAtIndex: 0] == 0xfdef, "fdef is returned properly");
|
|
|
|
[str release];
|
|
|
|
|
2016-09-26 11:04:51 +00:00
|
|
|
u = (unichar)0xfffd;
|
|
|
|
str = [[NSString alloc] initWithCharacters: &u length: 1];
|
2016-10-11 17:12:31 +00:00
|
|
|
PASS([str length] == 1, "fffd codepoint is permitted in string");
|
2016-09-26 11:04:51 +00:00
|
|
|
PASS([str characterAtIndex: 0] == 0xfffd, "fffd is returned properly");
|
|
|
|
[str release];
|
2016-10-11 12:35:29 +00:00
|
|
|
/* eth, so that we don't have the BOM as the first character (it would be
|
|
|
|
* removed) */
|
|
|
|
u2[0] = (unichar)0x00f0;
|
|
|
|
/* BOM as second non-character codepoint should be allowed */
|
|
|
|
u2[1] = (unichar)0xfffe;
|
|
|
|
str = [[NSString alloc] initWithCharacters: u2 length: 2];
|
2016-10-11 17:12:31 +00:00
|
|
|
PASS([str length] == 2, "fffe codepoint is permitted in string");
|
2016-10-11 12:35:29 +00:00
|
|
|
PASS([str characterAtIndex: 1] == 0xfffe, "fffe is returned properly");
|
2016-09-26 11:04:51 +00:00
|
|
|
[str release];
|
|
|
|
|
2016-09-26 10:59:02 +00:00
|
|
|
u = (unichar)0xffff;
|
|
|
|
str = [[NSString alloc] initWithCharacters: &u length: 1];
|
2016-10-11 17:12:31 +00:00
|
|
|
PASS([str length] == 1, "ffff codepoint is permitted in string");
|
2016-09-26 10:59:02 +00:00
|
|
|
PASS([str characterAtIndex: 0] == 0xffff, "ffff is returned properly");
|
|
|
|
[str release];
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|