Differences From Artifact [bb5fb35102]:
- File tests/OFStringTests.m — part of check-in [ac51f5f0cf] at 2012-12-06 00:14:47 on branch trunk — Improve -[hash] of OFNumber and OFObject. (user: js, size: 22277) [annotate] [blame] [check-ins using]
To Artifact [e613d6ae06]:
- File
tests/OFStringTests.m
— part of check-in
[640b225ba7]
at
2012-12-29 17:56:05
on branch trunk
— OFString: Improve API for Unicode strings.
* Instead of Unicode "strings", it uses the term "Unicode character
array".
* No terminating 0 character anymore, as these are not C strings
anyway. (user: js, size: 22493) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
36 37 38 39 40 41 42 | static OFString *module = @"OFString"; static OFString* whitespace[] = { @" \r \t\n\t \tasd \t \t\t\r\n", @" \t\t \t\t \t \t" }; static of_unichar_t ucstr[] = { | | | | | < | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | static OFString *module = @"OFString"; static OFString* whitespace[] = { @" \r \t\n\t \tasd \t \t\t\r\n", @" \t\t \t\t \t \t" }; static of_unichar_t ucstr[] = { 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0x1F03A }; static of_unichar_t sucstr[] = { 0xFFFE0000, 0x66000000, 0xF6000000, 0xF6000000, 0x62000000, 0xE4000000, 0x72000000, 0x3AF00100 }; static uint16_t utf16str[] = { 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0xD83C, 0xDC3A }; static uint16_t sutf16str[] = { 0xFFFE, 0x6600, 0xF600, 0xF600, 0x6200, 0xE400, 0x7200, 0x3CD8, 0x3ADC }; @interface EntityHandler: OFObject <OFStringXMLUnescapingDelegate> @end @implementation EntityHandler - (OFString*)string: (OFString*)string |
︙ | ︙ | |||
153 154 155 156 157 158 159 | TEST(@"+[stringWithUTF8String:length:]", (s[0] = [OFMutableString stringWithUTF8String: "\xEF\xBB\xBF" "foobar" length: 6]) && [s[0] isEqual: @"foo"]) | | | > > | > > | | > > | > > | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | TEST(@"+[stringWithUTF8String:length:]", (s[0] = [OFMutableString stringWithUTF8String: "\xEF\xBB\xBF" "foobar" length: 6]) && [s[0] isEqual: @"foo"]) TEST(@"+[stringWithCharacters:length:]", (is = [OFString stringWithCharacters: ucstr length: sizeof(ucstr) / sizeof(*ucstr)]) && [is isEqual: @"fööbär🀺"] && (is = [OFString stringWithCharacters: sucstr length: sizeof(sucstr) / sizeof(*sucstr)]) && [is isEqual: @"fööbär🀺"]) TEST(@"+[stringWithUTF16String:length:]", (is = [OFString stringWithUTF16String: utf16str length: sizeof(utf16str) / sizeof(*utf16str)]) && [is isEqual: @"fööbär🀺"] && (is = [OFString stringWithUTF16String: sutf16str length: sizeof(sutf16str) / sizeof(*sutf16str)]) && [is isEqual: @"fööbär🀺"]) TEST(@"+[stringWithContentsOfFile:encoding]", (is = [OFString stringWithContentsOfFile: @"testfile.txt" encoding: OF_STRING_ENCODING_ISO_8859_1]) && [is isEqual: @"testäöü"]) |
︙ | ︙ | |||
399 400 401 402 403 404 405 | EXPECT_EXCEPTION(@"Detect out of range in -[hexadecimalValue]", OFOutOfRangeException, [@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" hexadecimalValue]) | | | | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | EXPECT_EXCEPTION(@"Detect out of range in -[hexadecimalValue]", OFOutOfRangeException, [@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" hexadecimalValue]) TEST(@"-[characters]", (ua = [@"fööbär🀺" characters]) && !memcmp(ua, ucstr + 1, sizeof(ucstr) / sizeof(*ucstr))) TEST(@"-[UTF16String]", (u16a = [@"fööbär🀺" UTF16String]) && #ifdef OF_BIG_ENDIAN !memcmp(u16a, utf16str + 1, sizeof(utf16str) - sizeof(uint16_t))) #else !memcmp(u16a, sutf16str + 1, sizeof(sutf16str) - sizeof(uint16_t))) #endif |
︙ | ︙ |