1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
| ︙ | | |
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
-
-
+
+
|
#ifdef OF_HAVE_FILES
TEST(@"+[stringWithContentsOfFile:encoding]", (string = [stringClass
stringWithContentsOfFile: @"testfile.txt"
encoding: OFStringEncodingISO8859_1]) &&
[string isEqual: @"testäöü"])
TEST(@"+[stringWithContentsOfURI:encoding]", (string = [stringClass
stringWithContentsOfURI: [OFURI fileURIWithPath: @"testfile.txt"]
TEST(@"+[stringWithContentsOfIRI:encoding]", (string = [stringClass
stringWithContentsOfIRI: [OFIRI fileIRIWithPath: @"testfile.txt"]
encoding: OFStringEncodingISO8859_1]) &&
[string isEqual: @"testäöü"])
#endif
TEST(@"-[appendUTFString:length:]",
R([mutableString1 appendUTF8String: "\xEF\xBB\xBF" "barqux"
length: 6]) &&
|
| ︙ | | |
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
|
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
|
-
+
|
#else
/* Android, Solaris, HP-UX, DJGPP and AmigaOS 3 do not accept 0x for strtod() */
# if (!defined(OF_SOLARIS) || !defined(OF_X86)) && !defined(OF_AMIGAOS_M68K)
# define INPUT @"\t-0.123456789 "
# define EXPECTED -0.123456789
# else
/*
* Solaris' strtod() has weird rounding on x86, but not on x86_64.
* Solaris' strtod() has weird rounding on x86, but not on AMD64.
* AmigaOS 3 with libnix has weird rounding as well.
*/
# define INPUT @"\t-0.125 "
# define EXPECTED -0.125
# endif
#endif
TEST(@"-[doubleValue]",
|
| ︙ | | |
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
|
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
|
-
-
-
-
-
-
-
-
-
-
|
R([mutableString1 deleteEnclosingWhitespaces]) &&
[mutableString1 isEqual: @"asd"] &&
(mutableString1 = [mutableStringClass
stringWithString: whitespace[1]]) &&
R([mutableString1 deleteEnclosingWhitespaces]) &&
[mutableString1 isEqual: @""])
#ifdef OF_HAVE_UNICODE_TABLES
TEST(@"-[decomposedStringWithCanonicalMapping]",
[C(@"H\xC3\xA4llj\xC3\xB6").decomposedStringWithCanonicalMapping
isEqual: @"H\x61\xCC\x88llj\x6F\xCC\x88"]);
TEST(@"-[decomposedStringWithCompatibilityMapping]",
[C(@"H\xC3\xA4llj\xC3\xB6").decomposedStringWithCompatibilityMapping
isEqual: @"H\x61\xCC\x88llj\x6F\xCC\x88"]);
#endif
TEST(@"-[stringByXMLEscaping]",
(string = C(@"<hello> &world'\"!&").stringByXMLEscaping) &&
[string isEqual: @"<hello> &world'"!&"])
TEST(@"-[stringByXMLUnescaping]",
[string.stringByXMLUnescaping isEqual: @"<hello> &world'\"!&"] &&
[C(@"y").stringByXMLUnescaping isEqual: @"y"] &&
|
| ︙ | | |