139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
TEST(@"+[stringWithContentsOfURL:encoding]", (s[1] = [OFString
stringWithContentsOfURL: [OFURL URLWithString:
@"file://testfile.txt"]
encoding: OF_STRING_ENCODING_ISO_8859_1]) &&
[s[1] isEqual: @"testäöü"])
TEST(@"-[appendCStringWithLength:]",
R([s[0] appendCString: "foobarqux" + 3
withLength: 3]) && [s[0] isEqual: @"foobar"])
EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #1",
OFInvalidEncodingException,
[OFString stringWithCString: "\xE0\x80"])
EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #2",
OFInvalidEncodingException,
[OFString stringWithCString: "\xF0\x80\x80\xC0"])
|
|
|
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
TEST(@"+[stringWithContentsOfURL:encoding]", (s[1] = [OFString
stringWithContentsOfURL: [OFURL URLWithString:
@"file://testfile.txt"]
encoding: OF_STRING_ENCODING_ISO_8859_1]) &&
[s[1] isEqual: @"testäöü"])
TEST(@"-[appendCStringWithLength:]",
R([s[0] appendCString: "foo\xEF\xBB\xBF" "barqux" + 3
withLength: 6]) && [s[0] isEqual: @"foobar"])
EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #1",
OFInvalidEncodingException,
[OFString stringWithCString: "\xE0\x80"])
EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #2",
OFInvalidEncodingException,
[OFString stringWithCString: "\xF0\x80\x80\xC0"])
|