ObjFW  Check-in [823cff099d]

Overview
Comment:Migrate OFStringTests to ObjFWTest
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | objfwtest
Files: files | file ages | folders
SHA3-256: 823cff099de4c50137c927fae71f5adf81ec05278292a32e6cacc80c04d256b7
User & Date: js on 2024-02-17 18:07:33
Other Links: branch diff | manifest | tags
Context
2024-02-17
18:19
ObjFWTest: Improve format for redirected output check-in: 5e89084e60 user: js tags: objfwtest
18:07
Migrate OFStringTests to ObjFWTest check-in: 823cff099d user: js tags: objfwtest
2024-02-15
22:34
ObjFWTest: Implement output on Nintendo Switch check-in: dd7079d092 user: js tags: objfwtest
Changes

Modified new_tests/Makefile from [18f60fc107] to [6cd451cc4e].

29
30
31
32
33
34
35


36
37
38
39
40
41

42

43
44
45
46
47
48
49
       OFInvocationTests.m		\
       OFJSONTests.m			\
       OFLocaleTests.m			\
       OFMatrix4x4Tests.m		\
       OFMethodSignatureTests.m		\
       OFMutableArrayTests.m		\
       OFMutableSetTests.m		\


       OFNumberTests.m			\
       OFObjectTests.m			\
       OFPBKDF2Tests.m			\
       OFPropertyListTests.m		\
       OFScryptTests.m			\
       OFSetTests.m			\

       OFSystemInfoTests.m		\

       ${USE_SRCS_PLUGINS}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_SUBPROCESSES}		\
       ${USE_SRCS_THREADS}		\
       testfile_bin.m			\
       testfile_ini.m
SRCS_PLUGINS = OFPluginTests.m







>
>






>

>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
       OFInvocationTests.m		\
       OFJSONTests.m			\
       OFLocaleTests.m			\
       OFMatrix4x4Tests.m		\
       OFMethodSignatureTests.m		\
       OFMutableArrayTests.m		\
       OFMutableSetTests.m		\
       OFMutableStringTests.m		\
       OFMutableUTF8StringTests.m	\
       OFNumberTests.m			\
       OFObjectTests.m			\
       OFPBKDF2Tests.m			\
       OFPropertyListTests.m		\
       OFScryptTests.m			\
       OFSetTests.m			\
       OFStringTests.m			\
       OFSystemInfoTests.m		\
       OFUTF8StringTests.m		\
       ${USE_SRCS_PLUGINS}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_SUBPROCESSES}		\
       ${USE_SRCS_THREADS}		\
       testfile_bin.m			\
       testfile_ini.m
SRCS_PLUGINS = OFPluginTests.m

Added new_tests/OFMutableStringTests.h version [206d9c71b6].



















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * 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.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "ObjFW.h"
#import "ObjFWTest.h"

#import "OFStringTests.h"

@interface OFMutableStringTests: OFStringTests
{
	OFMutableString *_mutableString;
}
@end

Added new_tests/OFMutableStringTests.m version [9349febbaa].

















































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
/*
 * 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.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <string.h>

#import "OFMutableStringTests.h"

@interface CustomMutableString: OFMutableString
{
	OFMutableString *_string;
}
@end

static OFString *const whitespace[] = {
	@" \r \t\n\t \tasd  \t \t\t\r\n",
	@" \t\t  \t\t  \t \t"
};

@implementation OFMutableStringTests
- (Class)stringClass
{
	return [CustomMutableString class];
}

- (void)setUp
{
	[super setUp];

	_mutableString = [[self.stringClass alloc] initWithString: @"täṠ€🤔"];
}

- (void)dealloc
{
	[_mutableString release];

	[super dealloc];
}

- (void)testAppendString
{
	[_mutableString appendString: @"ö"];

	OTAssertEqualObjects(_mutableString, @"täṠ€🤔ö");
}

- (void)testAppendUTF8String
{
	[_mutableString appendUTF8String: "ö"];

	OTAssertEqualObjects(_mutableString, @"täṠ€🤔ö");
}

- (void)testAppendUTF8StringLength
{
	[_mutableString appendUTF8String: "\xEF\xBB\xBF" "öÖ" length: 7];

	OTAssertEqualObjects(_mutableString, @"täṠ€🤔öÖ");
}

- (void)testAppendFormat
{
	[_mutableString appendFormat: @"%02X", 15];

	OTAssertEqualObjects(_mutableString, @"täṠ€🤔0F");
}

- (void)testAppendCharactersLength
{
	[_mutableString appendCharacters: (OFUnichar []){ 0xF6, 0xD6 }
				  length: 2];

	OTAssertEqualObjects(_mutableString, @"täṠ€🤔öÖ");
}

- (void)testUppercase
{
	[_mutableString uppercase];

#ifdef OF_HAVE_UNICODE_TABLES
	OTAssertEqualObjects(_mutableString, @"TÄṠ€🤔");
#else
	OTAssertEqualObjects(_mutableString, @"TäṠ€🤔");
#endif
}

- (void)testLowercase
{
	[_mutableString lowercase];

#ifdef OF_HAVE_UNICODE_TABLES
	OTAssertEqualObjects(_mutableString, @"täṡ€🤔");
#else
	OTAssertEqualObjects(_mutableString, @"täṠ€🤔");
#endif
}

- (void)testCapitalize
{
	OFMutableString *string =
	    [self.stringClass stringWithString: @"täṠ€🤔täṠ€🤔 täṠ€🤔"];

	[string capitalize];

#ifdef OF_HAVE_UNICODE_TABLES
	OTAssertEqualObjects(string, @"Täṡ€🤔täṡ€🤔 Täṡ€🤔");
#else
	OTAssertEqualObjects(string, @"TäṠ€🤔täṠ€🤔 TäṠ€🤔");
#endif
}

- (void)testInsertStringAtIndex
{
	[_mutableString insertString: @"fööbär" atIndex: 2];

	OTAssertEqualObjects(_mutableString, @"täfööbärṠ€🤔");
}

- (void)testSetCharacterAtIndex
{
	[_mutableString setCharacter: 0x1F600 atIndex: 2];

	OTAssertEqualObjects(_mutableString, @"tä😀€🤔");
}

- (void)testDeleteCharactersInRange
{
	[_mutableString deleteCharactersInRange: OFMakeRange(2, 2)];

	OTAssertEqualObjects(_mutableString, @"tä🤔");
}

- (void)testDeleteCharactersInRangeThrowsWithOutOfRangeRange
{
	OTAssertThrowsSpecific(
	    [_mutableString deleteCharactersInRange: OFMakeRange(4, 2)],
	    OFOutOfRangeException);

	OTAssertThrowsSpecific(
	    [_mutableString deleteCharactersInRange: OFMakeRange(5, 1)],
	    OFOutOfRangeException);

	OTAssertThrowsSpecific(
	    [_mutableString deleteCharactersInRange: OFMakeRange(6, 0)],
	    OFOutOfRangeException);
}

- (void)testReplaceCharactersInRangeWithString
{
	OFMutableString *string =
	    [self.stringClass stringWithString: @"𝄞öööbä€"];

	[string replaceCharactersInRange: OFMakeRange(1, 3)
			      withString: @"äöüß"];
	OTAssertEqualObjects(string, @"𝄞äöüßbä€");

	[string replaceCharactersInRange: OFMakeRange(4, 2) withString: @"b"];
	OTAssertEqualObjects(string, @"𝄞äöübä€");

	[string replaceCharactersInRange: OFMakeRange(0, 7) withString: @""];
	OTAssertEqualObjects(string, @"");
}

- (void)testReplaceCharactersInRangeWithStringFailsWithOutOfRangeRange
{
	OTAssertThrowsSpecific(
	    [_mutableString replaceCharactersInRange: OFMakeRange(4, 2)
					  withString: @"abc"],
	    OFOutOfRangeException);

	OTAssertThrowsSpecific(
	    [_mutableString replaceCharactersInRange: OFMakeRange(5, 1)
					  withString: @"abc"],
	    OFOutOfRangeException);

	OTAssertThrowsSpecific(
	    [_mutableString replaceCharactersInRange: OFMakeRange(6, 0)
					  withString: @""],
	    OFOutOfRangeException);
}

- (void)testReplaceOccurrencesOfStringWithString
{
	OFMutableString *string;

	string = [self.stringClass stringWithString: @"asd fo asd fofo asd"];
	[string replaceOccurrencesOfString: @"fo" withString: @"foo"];
	OTAssertEqualObjects(string, @"asd foo asd foofoo asd");

	string = [self.stringClass stringWithString: @"XX"];
	[string replaceOccurrencesOfString: @"X" withString: @"XX"];
	OTAssertEqualObjects(string, @"XXXX");
}

- (void)testReplaceOccurrencesOfStringWithStringOptionsRange
{
	OFMutableString *string =
	    [self.stringClass stringWithString: @"foofoobarfoobarfoo"];

	[string replaceOccurrencesOfString: @"oo"
				withString: @"óò"
				   options: 0
				     range: OFMakeRange(2, 15)];
	OTAssertEqualObjects(string, @"foofóòbarfóòbarfoo");
}

- (void)
  testReplaceOccurrencesOfStringWithStringOptionsRangeThrowsWithOutOfRangeRange
{
	OTAssertThrowsSpecific(
	    [_mutableString replaceOccurrencesOfString: @"t"
					    withString: @"abc"
					       options: 0
						 range: OFMakeRange(4, 2)],
	    OFOutOfRangeException);

	OTAssertThrowsSpecific(
	    [_mutableString replaceOccurrencesOfString: @"t"
					    withString: @"abc"
					       options: 0
						 range: OFMakeRange(5, 1)],
	    OFOutOfRangeException);

	OTAssertThrowsSpecific(
	    [_mutableString replaceOccurrencesOfString: @"t"
					    withString: @""
					       options: 0
						 range: OFMakeRange(6, 0)],
	    OFOutOfRangeException);
}

- (void)deleteLeadingWhitespaces
{
	OFMutableString *string;

	string = [self.stringClass stringWithString: whitespace[0]];
	[string deleteLeadingWhitespaces];
	OTAssertEqualObjects(string, @"asd  \t \t\t\r\n");

	string = [self.stringClass stringWithString: whitespace[1]];
	[string deleteLeadingWhitespaces];
	OTAssertEqualObjects(string, @"");
}

- (void)deleteTrailingWhitespaces
{
	OFMutableString *string;

	string = [self.stringClass stringWithString: whitespace[0]];
	[string deleteTrailingWhitespaces];
	OTAssertEqualObjects(string,  @" \r \t\n\t \tasd");

	string = [self.stringClass stringWithString: whitespace[1]];
	[string deleteTrailingWhitespaces];
	OTAssertEqualObjects(string, @"");
}

- (void)deleteEnclosingWhitespaces
{
	OFMutableString *string;

	string = [self.stringClass stringWithString: whitespace[0]];
	[string deleteEnclosingWhitespaces];
	OTAssertEqualObjects(string, @"asd");

	string = [self.stringClass stringWithString: whitespace[1]];
	[string deleteEnclosingWhitespaces];
	OTAssertEqualObjects(string, @"");
}
@end

@implementation CustomMutableString
- (instancetype)init
{
	self = [super init];

	@try {
		_string = [[OFMutableString alloc] init];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (instancetype)initWithString: (OFString *)string
{
	self = [super init];

	@try {
		_string = [string mutableCopy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (instancetype)initWithCString: (const char *)cString
		       encoding: (OFStringEncoding)encoding
			 length: (size_t)length
{
	self = [super init];

	@try {
		_string = [[OFMutableString alloc] initWithCString: cString
							  encoding: encoding
							    length: length];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (instancetype)initWithUTF16String: (const OFChar16 *)UTF16String
			     length: (size_t)length
			  byteOrder: (OFByteOrder)byteOrder
{
	self = [super init];

	@try {
		_string = [[OFMutableString alloc]
		    initWithUTF16String: UTF16String
				 length: length
			      byteOrder: byteOrder];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (instancetype)initWithUTF32String: (const OFChar32 *)UTF32String
			     length: (size_t)length
			  byteOrder: (OFByteOrder)byteOrder
{
	self = [super init];

	@try {
		_string = [[OFMutableString alloc]
		    initWithUTF32String: UTF32String
				 length: length
			      byteOrder: byteOrder];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (instancetype)initWithFormat: (OFConstantString *)format
		     arguments: (va_list)arguments
{
	self = [super init];

	@try {
		_string = [[OFMutableString alloc] initWithFormat: format
							arguments: arguments];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_string release];

	[super dealloc];
}

- (OFUnichar)characterAtIndex: (size_t)idx
{
	return [_string characterAtIndex: idx];
}

- (size_t)length
{
	return _string.length;
}

- (void)replaceCharactersInRange: (OFRange)range
		      withString: (OFString *)string
{
	[_string replaceCharactersInRange: range withString: string];
}
@end

Added new_tests/OFMutableUTF8StringTests.m version [be500c9e1a].





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * 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.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFMutableStringTests.h"

#import "OFMutableUTF8String.h"

@interface OFMutableUTF8StringTests: OFMutableStringTests
@end

@implementation OFMutableUTF8StringTests
- (Class)arrayClass
{
	return [OFMutableUTF8String class];
}
@end

Added new_tests/OFStringTests.h version [358687fcb0].



















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * 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.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "ObjFW.h"
#import "ObjFWTest.h"

@interface OFStringTests: OTTestCase
{
	OFString *_string;
}

@property (readonly, nonatomic) Class stringClass;
@end

Renamed and modified tests/OFStringTests.m [dc9aaa2341] to new_tests/OFStringTests.m [4ac11edd9c].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
61
62
63






































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































64
65
66
67
68
69
70
71

#include "config.h"

#include <stdlib.h>
#include <string.h>
#include <math.h>

#import "TestsAppDelegate.h"

#import "OFString.h"
#import "OFMutableUTF8String.h"
#import "OFUTF8String.h"

#ifndef INFINITY
# define INFINITY __builtin_inf()
#endif

static OFString *module;
static OFString *const whitespace[] = {
	@" \r \t\n\t \tasd  \t \t\t\r\n",
	@" \t\t  \t\t  \t \t"
};
static const OFUnichar unicharString[] = {
	0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0x1F03A, 0
};
static const OFUnichar swappedUnicharString[] = {
	0xFFFE0000, 0x66000000, 0xF6000000, 0xF6000000, 0x62000000, 0xE4000000,
	0x72000000, 0x3AF00100, 0
};
static const OFChar16 char16String[] = {
	0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0xD83C, 0xDC3A, 0
};
static const OFChar16 swappedChar16String[] = {
	0xFFFE, 0x6600, 0xF600, 0xF600, 0x6200, 0xE400, 0x7200, 0x3CD8, 0x3ADC,
	0
};

@interface SimpleString: OFString
{
	OFMutableString *_string;
}
@end

@interface SimpleMutableString: OFMutableString
{
	OFMutableString *_string;
}
@end







































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































@implementation SimpleString
- (instancetype)init
{
	self = [super init];

	@try {
		_string = [[OFMutableString alloc] init];
	} @catch (id e) {







<
<
|
<
<





<
<
<
<
<















|





|





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







15
16
17
18
19
20
21


22


23
24
25
26
27





28
29
30
31
32
33
34
35
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540

#include "config.h"

#include <stdlib.h>
#include <string.h>
#include <math.h>



#import "OFStringTests.h"



#ifndef INFINITY
# define INFINITY __builtin_inf()
#endif






static const OFUnichar unicharString[] = {
	0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0x1F03A, 0
};
static const OFUnichar swappedUnicharString[] = {
	0xFFFE0000, 0x66000000, 0xF6000000, 0xF6000000, 0x62000000, 0xE4000000,
	0x72000000, 0x3AF00100, 0
};
static const OFChar16 char16String[] = {
	0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0xD83C, 0xDC3A, 0
};
static const OFChar16 swappedChar16String[] = {
	0xFFFE, 0x6600, 0xF600, 0xF600, 0x6200, 0xE400, 0x7200, 0x3CD8, 0x3ADC,
	0
};

@interface CustomString: OFString
{
	OFMutableString *_string;
}
@end

@interface CustomMutableString: OFMutableString
{
	OFMutableString *_string;
}
@end

@interface EntityHandler: OFObject <OFStringXMLUnescapingDelegate>
@end

@implementation OFStringTests
- (Class)stringClass
{
	return [CustomString class];
}

- (void)setUp
{
	[super setUp];

	_string = [[self.stringClass alloc] initWithString: @"täṠ€🤔"];
}

- (void)dealloc
{
	[_string release];

	[super dealloc];
}

- (void)testIsEqual
{
	OTAssertEqualObjects(_string, @"täṠ€🤔");
	OTAssertEqualObjects(@"täṠ€🤔", _string);
	OTAssertNotEqualObjects([self.stringClass stringWithString: @"test"],
	    @"täṠ€🤔");
	OTAssertNotEqualObjects(@"täṠ€🤔",
	    [self.stringClass stringWithString: @"test"]);
}

- (void)testHash
{
	OTAssertEqual(_string.hash, @"täṠ€🤔".hash);
	OTAssertNotEqual([[self.stringClass stringWithString: @"test"] hash],
	    @"täṠ€".hash);
}

- (void)testCompare
{
	OTAssertEqual([_string compare: @"täṠ€🤔"], OFOrderedSame);
	OTAssertEqual([[self.stringClass stringWithString: @""]
	    compare: @"a"], OFOrderedAscending);
	OTAssertEqual([[self.stringClass stringWithString: @"a"]
	    compare: @"b"], OFOrderedAscending);
	OTAssertEqual([[self.stringClass stringWithString: @"cd"]
	    compare: @"bc"], OFOrderedDescending);
	OTAssertEqual([[self.stringClass stringWithString: @"ä"]
	    compare: @"ö"], OFOrderedAscending);
	OTAssertEqual([[self.stringClass stringWithString: @"€"]
	    compare: @"ß"], OFOrderedDescending);
	OTAssertEqual([[self.stringClass stringWithString: @"aa"]
	    compare: @"z"], OFOrderedAscending);
	OTAssertEqual([@"aa" compare:
	    [self.stringClass stringWithString: @"z"]], OFOrderedAscending);
}

- (void)testCaseInsensitiveCompare
{
#ifdef OF_HAVE_UNICODE_TABLES
	OTAssertEqual([[self.stringClass stringWithString: @"a"]
	    caseInsensitiveCompare: @"A"], OFOrderedSame);
	OTAssertEqual([[self.stringClass stringWithString: @"Ä"]
	    caseInsensitiveCompare: @"ä"], OFOrderedSame);
	OTAssertEqual([[self.stringClass stringWithString: @"я"]
	    caseInsensitiveCompare: @"Я"], OFOrderedSame);
	OTAssertEqual([[self.stringClass stringWithString: @"€"]
	    caseInsensitiveCompare: @"ß"], OFOrderedDescending);
	OTAssertEqual([[self.stringClass stringWithString: @"ß"]
	    caseInsensitiveCompare: @"→"], OFOrderedAscending);
	OTAssertEqual([[self.stringClass stringWithString: @"AA"]
	    caseInsensitiveCompare: @"z"], OFOrderedAscending);
	OTAssertEqual([[self.stringClass stringWithString: @"ABC"]
	    caseInsensitiveCompare: @"AbD"], OFOrderedAscending);
#else
	OTAssertEqual([[self.stringClass stringWithString: @"a"]
	    caseInsensitiveCompare: @"A"], OFOrderedSame);
	OTAssertEqual([[self.stringClass stringWithString: @"AA"]
	    caseInsensitiveCompare: @"z"], OFOrderedAscending);
	OTAssertEqual([[self.stringClass stringWithString: @"ABC"]
	    caseInsensitiveCompare: @"AbD"], OFOrderedAscending);
#endif
}

- (void)testDescription
{
	OTAssertEqualObjects(_string.description, @"täṠ€🤔");
}

- (void)testLength
{
	OTAssertEqual(_string.length, 5);
}

- (void)testUTF8StringLength
{
	OTAssertEqual(_string.UTF8StringLength, 13);
}

- (void)testCharacterAtIndex
{
	OTAssertEqual([_string characterAtIndex: 0], 't');
	OTAssertEqual([_string characterAtIndex: 1], 0xE4);
	OTAssertEqual([_string characterAtIndex: 2], 0x1E60);
	OTAssertEqual([_string characterAtIndex: 3], 0x20AC);
	OTAssertEqual([_string characterAtIndex: 4], 0x1F914);
}

- (void)testCharacterAtIndexFailsWithOutOfRangeIndex
{
	OTAssertThrowsSpecific([_string characterAtIndex: 5],
	    OFOutOfRangeException);
}

- (void)testUppercaseString
{
#ifdef OF_HAVE_UNICODE_TABLES
	OTAssertEqualObjects(_string.uppercaseString, @"TÄṠ€🤔");
#else
	OTAssertEqualObjects(_string.uppercaseString, @"TäṠ€🤔");
#endif
}

- (void)testLowercaseString
{
#ifdef OF_HAVE_UNICODE_TABLES
	OTAssertEqualObjects(_string.lowercaseString, @"täṡ€🤔");
#else
	OTAssertEqualObjects(_string.lowercaseString, @"täṠ€🤔");
#endif
}

- (void)testCapitalizedString
{
#ifdef OF_HAVE_UNICODE_TABLES
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"täṠ€🤔täṠ€🤔 täṠ€🤔"] capitalizedString], @"Täṡ€🤔täṡ€🤔 Täṡ€🤔");
#else
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"täṠ€🤔täṠ€🤔 täṠ€🤔"] capitalizedString], @"TäṠ€🤔täṠ€🤔 TäṠ€🤔");
#endif
}

- (void)testStringWithUTF8StringLength
{
	OTAssertEqualObjects([self.stringClass
	    stringWithUTF8String: "\xEF\xBB\xBF" "foobar"
			  length: 6], @"foo");
}

- (void)testStringWithUTF16String
{
	OTAssertEqualObjects([self.stringClass
	    stringWithUTF16String: char16String], @"fööbär🀺");
	OTAssertEqualObjects([self.stringClass
	    stringWithUTF16String: swappedChar16String], @"fööbär🀺");
}

- (void)testStringWithUTF32String
{
	OTAssertEqualObjects([self.stringClass
	    stringWithUTF32String: unicharString], @"fööbär🀺");
	OTAssertEqualObjects([self.stringClass
	    stringWithUTF32String: swappedUnicharString], @"fööbär🀺");
}

- (void)testStringWithUTF8StringFailsWithInvalidUTF8
{
	OTAssertThrowsSpecific(
	    [self.stringClass stringWithUTF8String: "\xE0\x80"],
	    OFInvalidEncodingException);

	OTAssertThrowsSpecific(
	    [self.stringClass stringWithUTF8String: "\xF0\x80\x80\xC0"],
	    OFInvalidEncodingException);
}

- (void)testStringWithCStringEncodingISO8859_1
{
	OTAssertEqualObjects([self.stringClass
	    stringWithCString: "\xE4\xF6\xFC"
		     encoding: OFStringEncodingISO8859_1], @"äöü");
}

#ifdef HAVE_ISO_8859_15
- (void)testStringWithCStringEncodingISO8859_15
{
	OTAssertEqualObjects([self.stringClass
	    stringWithCString: "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE"
		     encoding: OFStringEncodingISO8859_15], @"€ŠšŽžŒœŸ");
}
#endif

#ifdef HAVE_WINDOWS_1252
- (void)testStringWithCStringEncodingWindows1252
{
	OTAssertEqualObjects([self.stringClass
	    stringWithCString: "\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B"
			       "\x8C\x8E\x91\x92\x93\x94\x95\x96\x97\x98\x99"
			       "\x9A\x9B\x9C\x9E\x9F"
		     encoding: OFStringEncodingWindows1252],
	    @"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ");
}
#endif

#ifdef HAVE_CODEPAGE_437
- (void)testStringWithCStringEncodingCodepage437
{
	OTAssertEqualObjects([self.stringClass
	    stringWithCString: "\xB0\xB1\xB2\xDB"
		     encoding: OFStringEncodingCodepage437], @"░▒▓█");
}
#endif

#ifdef OF_HAVE_FILES
- (void)testStringWithContentsOfFileEncoding
{
	OTAssertEqualObjects([self.stringClass
	    stringWithContentsOfFile: @"testfile.txt"
			    encoding: OFStringEncodingISO8859_1], @"testäöü");
}

- (void)testStringWithContentsOfIRIEncoding
{
	OTAssertEqualObjects([self.stringClass
	    stringWithContentsOfIRI: [OFIRI fileIRIWithPath: @"testfile.txt"]
			   encoding: OFStringEncodingISO8859_1], @"testäöü");
}
#endif

- (void)testCStringWithEncodingASCII
{
	OTAssertEqual(strcmp([[self.stringClass stringWithString:
	    @"This is a test"] cStringWithEncoding: OFStringEncodingASCII],
	    "This is a test"), 0);

	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"This is a tést"] cStringWithEncoding: OFStringEncodingASCII],
	    OFInvalidEncodingException);
}

- (void)testCStringWithEncodingISO8859_1
{
	OTAssertEqual(strcmp([[self.stringClass stringWithString:
	    @"This is ä test"] cStringWithEncoding: OFStringEncodingISO8859_1],
	    "This is \xE4 test"), 0);

	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"This is ä t€st"] cStringWithEncoding: OFStringEncodingISO8859_1],
	    OFInvalidEncodingException);
}

#ifdef HAVE_ISO_8859_15
- (void)testCStringWithEncodingISO8859_15
{
	OTAssertEqual(strcmp([[self.stringClass stringWithString:
	    @"This is ä t€st"] cStringWithEncoding: OFStringEncodingISO8859_15],
	    "This is \xE4 t\xA4st"), 0);

	OTAssertThrowsSpecific(
	    [[self.stringClass stringWithString: @"This is ä t€st…"]
	    cStringWithEncoding: OFStringEncodingISO8859_15],
	    OFInvalidEncodingException);
}
#endif

#ifdef HAVE_WINDOWS_1252
- (void)testCStringWithEncodingWindows1252
{
	OTAssertEqual(
	    strcmp([[self.stringClass stringWithString: @"This is ä t€st…"]
	    cStringWithEncoding: OFStringEncodingWindows1252],
	    "This is \xE4 t\x80st\x85"), 0);

	OTAssertThrowsSpecific(
	    [[self.stringClass stringWithString: @"This is ä t€st…‼"]
	    cStringWithEncoding: OFStringEncodingWindows1252],
	    OFInvalidEncodingException);
}
#endif

#ifdef HAVE_CODEPAGE_437
- (void)testCStringWithEncodingCodepage437
{
	OTAssertEqual(
	    strcmp([[self.stringClass stringWithString: @"Tést strîng ░▒▓"]
	    cStringWithEncoding: OFStringEncodingCodepage437],
	    "T\x82st str\x8Cng \xB0\xB1\xB2"), 0);

	OTAssertThrowsSpecific(
	    [[self.stringClass stringWithString: @"T€st strîng ░▒▓"]
	    cStringWithEncoding: OFStringEncodingCodepage437],
	    OFInvalidEncodingException);
}
#endif

- (void)testLossyCStringWithEncodingASCII
{
	OTAssertEqual(strcmp([[self.stringClass stringWithString:
	    @"This is a tést"] lossyCStringWithEncoding: OFStringEncodingASCII],
	    "This is a t?st"), 0);
}

- (void)testLossyCStringWithEncodingISO8859_1
{
	OTAssertEqual(
	    strcmp([[self.stringClass stringWithString: @"This is ä t€st"]
	    lossyCStringWithEncoding: OFStringEncodingISO8859_1],
	    "This is \xE4 t?st"), 0);
}

#ifdef HAVE_ISO_8859_15
- (void)testLossyCStringWithEncodingISO8859_15
{
	OTAssertEqual(
	    strcmp([[self.stringClass stringWithString: @"This is ä t€st…"]
	    lossyCStringWithEncoding: OFStringEncodingISO8859_15],
	    "This is \xE4 t\xA4st?"), 0);
}
#endif

#ifdef HAVE_WINDOWS_1252
- (void)testLossyCStringWithEncodingWindows1252
{
	OTAssertEqual(
	    strcmp([[self.stringClass stringWithString: @"This is ä t€st…‼"]
	    lossyCStringWithEncoding: OFStringEncodingWindows1252],
	    "This is \xE4 t\x80st\x85?"), 0);
}
#endif

#ifdef HAVE_CODEPAGE_437
- (void)testLossyCStringWithEncodingCodepage437
{
	OTAssertEqual(
	    strcmp([[self.stringClass stringWithString: @"T€st strîng ░▒▓"]
	    lossyCStringWithEncoding: OFStringEncodingCodepage437],
	    "T?st str\x8Cng \xB0\xB1\xB2"), 0);
}
#endif

- (void)testStringWithFormat
{
	OTAssertEqualObjects(
	    ([self.stringClass stringWithFormat: @"%@:%d", @"test", 123]),
	    @"test:123");
}

- (void)testRangeOfString
{
	OFString *string = [self.stringClass stringWithString: @"𝄞öö"];

	OTAssertEqual([string rangeOfString: @"öö"].location, 1);
	OTAssertEqual([string rangeOfString: @"ö"].location, 1);
	OTAssertEqual([string rangeOfString: @"𝄞"].location, 0);
	OTAssertEqual([string rangeOfString: @"x"].location, OFNotFound);

	OTAssertEqual([string
	    rangeOfString: @"öö"
		  options: OFStringSearchBackwards].location, 1);

	OTAssertEqual([string
	    rangeOfString: @"ö"
		  options: OFStringSearchBackwards].location, 2);

	OTAssertEqual([string
	    rangeOfString: @"𝄞"
		  options: OFStringSearchBackwards].location, 0);

	OTAssertEqual([string
	    rangeOfString: @"x"
		  options: OFStringSearchBackwards].location, OFNotFound);
}

- (void)testRangeOfStringFailsWithOutOfRangeRange
{
	OTAssertThrowsSpecific(
	    [_string rangeOfString: @"t" options: 0 range: OFMakeRange(6, 1)],
	    OFOutOfRangeException);
}

- (void)testIndexOfCharacterFromSet
{
	OFCharacterSet *characterSet =
	    [OFCharacterSet characterSetWithCharactersInString: @"cđ"];

	OTAssertEqual([[self.stringClass stringWithString: @"abcđabcđe"]
	    indexOfCharacterFromSet: characterSet], 2);

	OTAssertEqual([[self.stringClass stringWithString: @"abcđabcđë"]
	    indexOfCharacterFromSet: characterSet
			    options: OFStringSearchBackwards], 7);

	OTAssertEqual([[self.stringClass stringWithString: @"abcđabcđë"]
	    indexOfCharacterFromSet: characterSet
			    options: 0
			      range: OFMakeRange(4, 4)], 6);

	OTAssertEqual([[self.stringClass stringWithString: @"abcđabcđëf"]
	    indexOfCharacterFromSet: characterSet
			    options: 0
			      range: OFMakeRange(8, 2)], OFNotFound);
}

- (void)testIndexOfCharacterFromSetFailsWithOutOfRangeRange
{
	OFCharacterSet *characterSet =
	    [OFCharacterSet characterSetWithCharactersInString: @"cđ"];

	OTAssertThrowsSpecific([[self.stringClass stringWithString: @"𝄞öö"]
	    indexOfCharacterFromSet: characterSet
			    options: 0
			      range: OFMakeRange(3, 1)],
	    OFOutOfRangeException);
}

- (void)testSubstringWithRange
{
	OTAssertEqualObjects([_string substringWithRange: OFMakeRange(1, 2)],
	    @"äṠ");

	OTAssertEqualObjects([_string substringWithRange: OFMakeRange(3, 0)],
	    @"");
}

- (void)testSubstringWithRangeFailsWithOutOfRangeRange
{
	OTAssertThrowsSpecific([_string substringWithRange: OFMakeRange(4, 2)],
	    OFOutOfRangeException);

	OTAssertThrowsSpecific([_string substringWithRange: OFMakeRange(6, 0)],
	    OFOutOfRangeException);
}

- (void)testStringByAppendingString
{
	OTAssertEqualObjects([_string stringByAppendingString: @"äöü"],
	    @"täṠ€🤔äöü");
}

- (void)testHasPrefix
{
	OTAssertTrue([_string hasPrefix: @"täṠ"]);
	OTAssertFalse([_string hasPrefix: @"🤔"]);
}

- (void)testHasSuffix
{
	OTAssertTrue([_string hasSuffix: @"🤔"]);
	OTAssertFalse([_string hasSuffix: @"täṠ"]);
}

- (void)testComponentsSeparatedByString
{
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"fooXXbarXXXXbazXXXX"] componentsSeparatedByString: @"XX"],
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"", @"baz", @"", @"",
	    nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] componentsSeparatedByString: @""],
	    [OFArray arrayWithObject: @"foo"]);
}

- (void)testComponentsSeparatedByStringOptions
{
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"fooXXbarXXXXbazXXXX"]
	    componentsSeparatedByString: @"XX"
				options: OFStringSkipEmptyComponents],
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]));
}

- (void)testComponentsSeparatedByCharactersInSet
{
	OFCharacterSet *characterSet =
	    [OFCharacterSet characterSetWithCharactersInString: @"XYZ"];

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"fooXYbarXYZXbazXYXZx"]
	    componentsSeparatedByCharactersInSet: characterSet],
	    ([OFArray arrayWithObjects: @"foo", @"", @"bar", @"", @"", @"",
	    @"baz", @"", @"", @"", @"x", nil]));
}

- (void)testComponentsSeparatedByCharactersInSetOptions
{
	OFCharacterSet *characterSet =
	    [OFCharacterSet characterSetWithCharactersInString: @"XYZ"];

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"fooXYbarXYZXbazXYXZ"]
	    componentsSeparatedByCharactersInSet: characterSet
					 options: OFStringSkipEmptyComponents],
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]));
}

- (void)testLongLongValue
{
	OTAssertEqual([[self.stringClass stringWithString:
	    @"1234"] longLongValue], 1234);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\r\n+123  "] longLongValue], 123);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"-500\t"] longLongValue], -500);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"-0x10\t"] longLongValueWithBase: 0], -0x10);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\t\t\r\n"] longLongValue], 0);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"123f"] longLongValueWithBase: 16], 0x123f);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"-1234"] longLongValueWithBase: 0], -1234);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\t\n0xABcd\r"] longLongValueWithBase: 0], 0xABCD);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"1234567"] longLongValueWithBase: 8], 01234567);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\r\n0123"] longLongValueWithBase: 0], 0123);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"765\t"] longLongValueWithBase: 8], 0765);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\t\t\r\n"] longLongValueWithBase: 8], 0);
}

- (void)testLongLongValueThrowsOnInvalidFormat
{
	OTAssertThrowsSpecific(
	    [[self.stringClass stringWithString: @"abc"] longLongValue],
	    OFInvalidFormatException);

	OTAssertThrowsSpecific(
	    [[self.stringClass stringWithString: @"0a"] longLongValue],
	    OFInvalidFormatException);

	OTAssertThrowsSpecific(
	    [[self.stringClass stringWithString: @"0 1"] longLongValue],
	    OFInvalidFormatException);

	OTAssertThrowsSpecific(
	    [[self.stringClass stringWithString: @"0xABCDEFG"]
	    longLongValueWithBase: 0],
	    OFInvalidFormatException);

	OTAssertThrowsSpecific(
	    [[self.stringClass stringWithString: @"0x"]
	    longLongValueWithBase: 0],
	    OFInvalidFormatException);
}

- (void)testLongLongValueThrowsOnOutOfRange
{
	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"-12345678901234567890123456789012345678901234567890"
	    @"12345678901234567890123456789012345678901234567890"]
	    longLongValueWithBase: 16], OFOutOfRangeException)
}

- (void)testUnsignedLongLongValue
{
	OTAssertEqual([[self.stringClass stringWithString:
	    @"1234"] unsignedLongLongValue], 1234);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\r\n+123  "] unsignedLongLongValue], 123);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\t\t\r\n"] unsignedLongLongValue], 0);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"123f"] unsignedLongLongValueWithBase: 16], 0x123f);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"1234"] unsignedLongLongValueWithBase: 0], 1234);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\t\n0xABcd\r"] unsignedLongLongValueWithBase: 0], 0xABCD);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"1234567"] unsignedLongLongValueWithBase: 8], 01234567);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\r\n0123"] unsignedLongLongValueWithBase: 0], 0123);

	OTAssertEqual([[self.stringClass stringWithString: @"765\t"]
	    unsignedLongLongValueWithBase: 8], 0765);

	OTAssertEqual([[self.stringClass stringWithString: @"\t\t\r\n"]
	    unsignedLongLongValueWithBase: 8], 0);
}

- (void)testUnsignedLongLongValueThrowsOnOutOfRange
{
	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
	    @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"]
	    unsignedLongLongValueWithBase: 16], OFOutOfRangeException);
}

- (void)testFloatValue
{
	/*
	 * These test numbers can be generated without rounding if we have IEEE
	 * floating point numbers, thus we can use OTAssertEqual on them.
	 */

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\t-0.25 "] floatValue], -0.25);

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\r\n\tINF\t\n"] floatValue], INFINITY);
	OTAssertEqual([[self.stringClass stringWithString:
	    @"\r -INFINITY\n"] floatValue], -INFINITY);

	OTAssertTrue(isnan([[self.stringClass stringWithString:
	    @"   NAN\t\t"] floatValue]));
	OTAssertTrue(isnan([[self.stringClass stringWithString:
	    @"   -NaN\t\t"] floatValue]));
}

- (void)testFloatValueThrowsOnInvalidFormat
{
	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"0.0a"] floatValue], OFInvalidFormatException);
	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"0 0"] floatValue], OFInvalidFormatException);
	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"0,0"] floatValue], OFInvalidFormatException);
}

- (void)testDoubleValue
{
#if (defined(OF_SOLARIS) && defined(OF_X86)) || defined(OF_AMIGAOS_M68K)
	/*
	 * Solaris' strtod() has weird rounding on x86, but not on AMD64.
	 * AmigaOS 3 with libnix has weird rounding as well.
	 */
	OTAssertEqual([[self.stringClass stringWithString:
	    @"\t-0.125 "] doubleValue], -0.125);
#elif defined(OF_ANDROID) || defined(OF_SOLARIS) || defined(OF_HPUX) || \
    defined(OF_DJGPP) || defined(OF_AMIGAOS_M68K)
	/*
	 * Android, Solaris, HP-UX, DJGPP and AmigaOS 3 do not accept 0x for
	 * strtod().
	 */
	OTAssertEqual([[self.stringClass stringWithString:
	    @"\t-0.123456789 "] doubleValue], -0.123456789);
#else
	OTAssertEqual([[self.stringClass stringWithString:
	    @"\t-0x1.FFFFFFFFFFFFFP-1020 "] doubleValue],
	    -0x1.FFFFFFFFFFFFFP-1020);
#endif

	OTAssertEqual([[self.stringClass stringWithString:
	    @"\r\n\tINF\t\n"] doubleValue], INFINITY);
	OTAssertEqual([[self.stringClass stringWithString:
	    @"\r -INFINITY\n"] doubleValue], -INFINITY);

	OTAssertTrue(isnan([[self.stringClass stringWithString:
	    @"   NAN\t\t"] doubleValue]));
	OTAssertTrue(isnan([[self.stringClass stringWithString:
	    @"   -NaN\t\t"] doubleValue]));
}

- (void)testDoubleValueThrowsOnInvalidFormat
{
	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"0.0a"] doubleValue], OFInvalidFormatException);
	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"0 0"] doubleValue], OFInvalidFormatException);
	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"0,0"] doubleValue], OFInvalidFormatException);
}

- (void)testCharacters
{
	OTAssertEqual(memcmp([[self.stringClass stringWithString: @"fööbär🀺"]
	    characters], unicharString + 1, sizeof(unicharString) - 8), 0);
}

- (void)testUTF16String
{
	OFString *string = [self.stringClass stringWithString: @"fööbär🀺"];

	OTAssertEqual(memcmp(string.UTF16String, char16String + 1,
	    OFUTF16StringLength(char16String) * 2), 0);

#ifdef OF_BIG_ENDIAN
	OTAssertEqual(memcmp([string UTF16StringWithByteOrder:
	    OFByteOrderLittleEndian], swappedChar16String + 1,
	    OFUTF16StringLength(swappedChar16String) * 2), 0);
#else
	OTAssertEqual(memcmp([string UTF16StringWithByteOrder:
	    OFByteOrderBigEndian], swappedChar16String + 1,
	    OFUTF16StringLength(swappedChar16String) * 2), 0);
#endif
}

- (void)testUTF16StringLength
{
	OTAssertEqual(_string.UTF16StringLength, 6);
}

- (void)testUTF32String
{
	OFString *string = [self.stringClass stringWithString: @"fööbär🀺"];

	OTAssertEqual(memcmp(string.UTF32String, unicharString + 1,
	    OFUTF32StringLength(unicharString) * 4), 0);

#ifdef OF_BIG_ENDIAN
	OTAssertEqual(memcmp([string UTF32StringWithByteOrder:
	    OFByteOrderLittleEndian], swappedUnicharString + 1,
	    OFUTF32StringLength(swappedUnicharString) * 4), 0);
#else
	OTAssertEqual(memcmp([string UTF32StringWithByteOrder:
	    OFByteOrderBigEndian], swappedUnicharString + 1,
	    OFUTF32StringLength(swappedUnicharString) * 4), 0);
#endif
}

- (void)testStringByMD5Hashing
{
	OTAssertEqualObjects(_string.stringByMD5Hashing,
	    @"7e6bef5fe100d93e808d15b1c6e6145a");
}

- (void)testStringByRIPEMD160Hashing
{
	OTAssertEqualObjects(_string.stringByRIPEMD160Hashing,
	    @"2fd0ec899c55cf2821a2f844b9d80887fc351103");
}

- (void)testStringBySHA1Hashing
{
	OTAssertEqualObjects(_string.stringBySHA1Hashing,
	    @"3f76f9358b372b7147344b7a3ba6d309e4466b3a");
}

- (void)testStringBySHA224Hashing
{
	OTAssertEqualObjects(_string.stringBySHA224Hashing,
	    @"6e57ec72e4da55c46d88a15ce7ce4d8db83d0493a263134a3734259d");
}

- (void)testStringBySHA256Hashing
{
	OTAssertEqualObjects(_string.stringBySHA256Hashing,
	    @"6eac4d3d0b4152c82ff88599482696ca"
	    @"d6dca0b533e8a2e6963d995b19b0a683");
}

- (void)testStringBySHA384Hashing
{
	OTAssertEqualObjects(_string.stringBySHA384Hashing,
	    @"d9bd6a671407d01cee4022888677040d"
	    @"108dd0270c38e0ce755d6dcadb4bf9c1"
	    @"89204dd2a51f954be55ea5d5fe00667b");
}

- (void)testStringBySHA512Hashing
{
	OTAssertEqualObjects(_string.stringBySHA512Hashing,
	    @"64bec66b3633c585da6d32760fa3617a"
	    @"47ca4c247472bdbbfb452b2dbf5a3612"
	    @"5629053394a16ecd08f8a21d461537c5"
	    @"f1224cbb379589e73dcd6763ec4f886c");
}

- (void)testStringByAddingPercentEncodingWithAllowedCharacters
{
	OFCharacterSet *characterSet =
	    [OFCharacterSet characterSetWithCharactersInString: @"abfo'_~$🍏"];

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo\"ba'_~$]🍏🍌"]
	    stringByAddingPercentEncodingWithAllowedCharacters: characterSet],
	    @"foo%22ba'_~$%5D🍏%F0%9F%8D%8C");
}

- (void)testStringByRemovingPercentEncoding
{
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo%20bar%22+%24%F0%9F%8D%8C"] stringByRemovingPercentEncoding],
	    @"foo bar\"+$🍌");
}

- (void)testStringByRemovingPercentEncodingThrowsOnInvalidFormat
{
	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"foo%xbar"] stringByRemovingPercentEncoding],
	    OFInvalidFormatException);
}

- (void)testStringByRemovingPercentEncodingThrowsOnInvalidEncoding
{
	OTAssertThrowsSpecific([[self.stringClass stringWithString:
	    @"foo%FFbar"] stringByRemovingPercentEncoding],
	    OFInvalidEncodingException);
}

- (void)testStringByXMLEscaping
{
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"<hello> &world'\"!&"] stringByXMLEscaping],
	    @"&lt;hello&gt; &amp;world&apos;&quot;!&amp;");
}

- (void)testStringByXMLUnescaping
{
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"&lt;hello&gt; &amp;world&apos;&quot;!&amp;"]
	    stringByXMLUnescaping],
	    @"<hello> &world'\"!&");

	OTAssertEqualObjects([[self.stringClass stringWithString: @"&#x79;"]
	    stringByXMLUnescaping], @"y");
	OTAssertEqualObjects([[self.stringClass stringWithString: @"&#xe4;"]
	    stringByXMLUnescaping], @"ä");
	OTAssertEqualObjects([[self.stringClass stringWithString: @"&#8364;"]
	    stringByXMLUnescaping], @"€");
	OTAssertEqualObjects([[self.stringClass stringWithString: @"&#x1D11E;"]
	    stringByXMLUnescaping], @"𝄞");
}

- (void)testStringByXMLUnescapingThrowsOnUnknownEntities
{
	OTAssertThrowsSpecific([[self.stringClass stringWithString: @"&foo;"]
	    stringByXMLUnescaping], OFUnknownXMLEntityException);
}

- (void)testStringByXMLUnescapingThrowsOnInvalidFormat
{
	OTAssertThrowsSpecific([[self.stringClass stringWithString: @"x&amp"]
	    stringByXMLUnescaping], OFInvalidFormatException);
	OTAssertThrowsSpecific([[self.stringClass stringWithString: @"&#;"]
	    stringByXMLUnescaping], OFInvalidFormatException);
	OTAssertThrowsSpecific([[self.stringClass stringWithString: @"&#x;"]
	    stringByXMLUnescaping], OFInvalidFormatException);
	OTAssertThrowsSpecific([[self.stringClass stringWithString: @"&#g;"]
	    stringByXMLUnescaping], OFInvalidFormatException);
	OTAssertThrowsSpecific([[self.stringClass stringWithString: @"&#xg;"]
	    stringByXMLUnescaping], OFInvalidFormatException);
}

- (void)testStringByXMLUnescapingWithDelegate
{
	EntityHandler *entityHandler =
	    [[[EntityHandler alloc] init] autorelease];

	OTAssertEqualObjects([[self.stringClass stringWithString: @"x&foo;y"]
	    stringByXMLUnescapingWithDelegate: entityHandler],
	    @"xbary");
}

#ifdef OF_HAVE_BLOCKS
- (void)testStringByXMLUnescapingWithBlock
{
	OTAssertEqualObjects([[self.stringClass stringWithString: @"x&foo;y"]
	    stringByXMLUnescapingWithBlock: ^ OFString * (OFString *string,
							  OFString *entity) {
		if ([entity isEqual: @"foo"])
			return @"bar";

		return nil;
	    }], @"xbary");
}

- (void)testEnumerateLinesUsingBlock
{
	__block size_t count = 0;

	[[self.stringClass stringWithString: @"foo\nbar\nbaz"]
	    enumerateLinesUsingBlock: ^ (OFString *line, bool *stop) {
		switch (count++) {
		case 0:
			OTAssertEqualObjects(line, @"foo");
			break;
		case 1:
			OTAssertEqualObjects(line, @"bar");
			break;
		case 2:
			OTAssertEqualObjects(line, @"baz");
			break;
		default:
			OTAssert(false);
		}
	}];

	OTAssertEqual(count, 3);
}
#endif

#ifdef OF_HAVE_FILES
- (void)testIsAbsolutePath
{
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	OTAssertTrue(
	    [[self.stringClass stringWithString: @"C:\\foo"] isAbsolutePath]);
	OTAssertTrue(
	    [[self.stringClass stringWithString: @"a:/foo"] isAbsolutePath]);
	OTAssertFalse(
	    [[self.stringClass stringWithString: @"foo"] isAbsolutePath]);
	OTAssertFalse(
	    [[self.stringClass stringWithString: @"b:foo"] isAbsolutePath]);
#  ifdef OF_WINDOWS
	OTAssertTrue(
	    [[self.stringClass stringWithString: @"\\\\foo"] isAbsolutePath]);
#  endif
# elif defined(OF_AMIGAOS)
	OTAssertTrue(
	    [[self.stringClass stringWithString: @"dh0:foo"] isAbsolutePath]);
	OTAssertTrue(
	    [[self.stringClass stringWithString: @"dh0:a/b"] isAbsolutePath]);
	OTAssertFalse(
	    [[self.stringClass stringWithString: @"foo/bar"] isAbsolutePath]);
	OTAssertFalse(
	    [[self.stringClass stringWithString: @"foo"] isAbsolutePath]);
# elif defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) || \
    defined(OF_WII) || defined(OF_NINTENDO_SWITCH)
	OTAssertTrue(
	    [[self.stringClass stringWithString: @"sdmc:/foo"] isAbsolutePath]);
	OTAssertFalse(
	    [[self.stringClass stringWithString: @"sdmc:foo"] isAbsolutePath]);
	OTAssertFalse(
	    [[self.stringClass stringWithString: @"foo/bar"] isAbsolutePath]);
	OTAssertFalse(
	    [[self.stringClass stringWithString: @"foo"] isAbsolutePath]);
# else
	OTAssertTrue(
	    [[self.stringClass stringWithString: @"/foo"] isAbsolutePath]);
	OTAssertTrue(
	    [[self.stringClass stringWithString: @"/foo/bar"] isAbsolutePath]);
	OTAssertFalse(
	    [[self.stringClass stringWithString: @"foo/bar"] isAbsolutePath]);
	OTAssertFalse(
	    [[self.stringClass stringWithString: @"foo"] isAbsolutePath]);
# endif
}

- (void)testStringByAppendingPathComponent
{
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	OTAssertEqualObjects([[self.stringClass stringWithString: @"foo\\bar"]
	    stringByAppendingPathComponent: @"baz"],
	    @"foo\\bar\\baz");

	OTAssertEqualObjects([[self.stringClass stringWithString: @"foo\\bar\\"]
	    stringByAppendingPathComponent: @"baz"],
	    @"foo\\bar\\baz");
# else
	OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"]
	    stringByAppendingPathComponent: @"baz"],
	    @"foo/bar/baz");

	OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar/"]
	    stringByAppendingPathComponent: @"baz"],
	    @"foo/bar/baz");
# endif
}

- (void)testStringByAppendingPathExtension
{
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] stringByAppendingPathExtension: @"bar"],
	    @"foo.bar");

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:\\tmp\\foo"] stringByAppendingPathExtension: @"bar"],
	    @"c:\\tmp\\foo.bar");

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:\\tmp\\/\\"] stringByAppendingPathExtension: @"bar"],
	    @"c:\\tmp.bar");
# elif defined(OF_AMIGAOS)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] stringByAppendingPathExtension: @"bar"],
	    @"foo.bar");

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] stringByAppendingPathExtension: @"baz"],
	    @"foo/bar.baz");
# else
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] stringByAppendingPathExtension: @"bar"],
	    @"foo.bar");

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] stringByAppendingPathExtension: @"baz"],
	    @"foo/bar.baz");

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo///"] stringByAppendingPathExtension: @"bar"],
	    @"foo.bar");
# endif
}

- (void)testPathWithComponents
{
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])],
	    @"foo\\bar\\baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"c:\\", @"foo", @"bar", @"baz", nil])],
	    @"c:\\foo\\bar\\baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"c:", @"foo", @"bar", @"baz", nil])],
	    @"c:foo\\bar\\baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"c:", @"\\", @"foo", @"bar", @"baz",
	    nil])], @"c:\\foo\\bar\\baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"c:", @"/", @"foo", @"bar", @"baz",
	    nil])], @"c:/foo\\bar\\baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"foo/", @"bar\\", @"", @"baz", @"\\",
	    nil])], @"foo/bar\\baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"foo"]], @"foo");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"c:"]], @"c:");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"c:\\"]], @"c:\\");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"\\"]], @"\\");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"/"]], @"/");

#  ifdef OF_WINDOWS
	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"\\\\", @"foo", @"bar", nil])],
	    @"\\\\foo\\bar");
#  endif
# elif defined(OF_AMIGAOS)
	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"dh0:", @"foo", @"bar", @"baz", nil])],
	    @"dh0:foo/bar/baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])],
	    @"foo/bar/baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"foo/", @"bar", @"", @"baz", @"/",
	    nil])], @"foo//bar/baz//");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"foo"]], @"foo");
# elif defined(OF_WII) || defined(OF_NINTENDO_DS) || \
    defined(OF_NINTENDO_3DS) || defined(OF_NINTENDO_SWITCH)
	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])],
	    @"foo/bar/baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"sdmc:", @"foo", @"bar", @"baz",
	    nil])], @"sdmc:/foo/bar/baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"foo/", @"bar/", @"", @"baz", @"/",
	    nil])], @"foo/bar/baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"foo"]], @"foo");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"sdmc:"]], @"sdmc:/");
# else
	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"/", @"foo", @"bar", @"baz", nil])],
	    @"/foo/bar/baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])],
	    @"foo/bar/baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    ([OFArray arrayWithObjects: @"foo/", @"bar", @"", @"baz", @"/",
	    nil])], @"foo/bar/baz");

	OTAssertEqualObjects([self.stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"foo"]], @"foo");
# endif
}

- (void)testPathComponents
{
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:/tmp"].pathComponents],
	    ([OFArray arrayWithObjects: @"c:/", @"tmp", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:\\tmp\\"] pathComponents],
	    ([OFArray arrayWithObjects: @"c:\\", @"tmp", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:\\"] pathComponents], [OFArray arrayWithObject: @"c:\\"]);

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:/"] pathComponents], [OFArray arrayWithObject: @"c:/"]);

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:"] pathComponents], [OFArray arrayWithObject: @"c:"]);

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo\\bar"] pathComponents],
	    ([OFArray arrayWithObjects: @"foo", @"bar", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo\\bar/baz/"] pathComponents],
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo\\/"] pathComponents], [OFArray arrayWithObject: @"foo"]);

#  ifdef OF_WINDOWS
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"\\\\foo\\bar"] pathComponents],
	    ([OFArray arrayWithObjects: @"\\\\", @"foo", @"bar", nil]));
#  endif

	OTAssertEqualObjects([[self.stringClass stringWithString: @""]
	    pathComponents], [OFArray array]);
# elif defined(OF_AMIGAOS)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:tmp"] pathComponents],
	    ([OFArray arrayWithObjects: @"dh0:", @"tmp", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:tmp/"] pathComponents],
	    ([OFArray arrayWithObjects: @"dh0:", @"tmp", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:/"] pathComponents],
	    ([OFArray arrayWithObjects: @"dh0:", @"/", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] pathComponents],
	    ([OFArray arrayWithObjects: @"foo", @"bar", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar/baz/"] pathComponents],
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo//"] pathComponents],
	    ([OFArray arrayWithObjects: @"foo", @"/", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString: @""]
	    pathComponents], [OFArray array]);
# elif defined(OF_NINTENDO_3DS) || defined(OF_WII) || \
    defined(OF_NINTENDO_SWITCH)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"sdmc:/tmp"] pathComponents],
	    ([OFArray arrayWithObjects: @"sdmc:", @"tmp", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"sdmc:/"] pathComponents], [OFArray arrayWithObject: @"sdmc:"]);

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] pathComponents],
	    ([OFArray arrayWithObjects: @"foo", @"bar", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar/baz/"] pathComponents],
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo//"] pathComponents], [OFArray arrayWithObject: @"foo"]);

	OTAssertEqualObjects([[self.stringClass stringWithString: @""]
	    pathComponents], [OFArray array]);
# else
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/tmp"] pathComponents],
	    ([OFArray arrayWithObjects: @"/", @"tmp", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/tmp/"] pathComponents],
	    ([OFArray arrayWithObjects: @"/", @"tmp", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/"] pathComponents], [OFArray arrayWithObject: @"/"]);

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] pathComponents],
	    ([OFArray arrayWithObjects: @"foo", @"bar", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar/baz/"] pathComponents],
	    ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]));

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo//"] pathComponents], [OFArray arrayWithObject: @"foo"]);

	OTAssertEqualObjects([[self.stringClass stringWithString: @""]
	    pathComponents], [OFArray array]);
# endif
}

- (void)testLastPathComponent
{
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:/tmp"] lastPathComponent], @"tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:\\tmp\\"] lastPathComponent], @"tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:\\"] lastPathComponent], @"c:\\");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:/"] lastPathComponent], @"c:/");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"\\"] lastPathComponent], @"\\");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] lastPathComponent], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo\\bar"] lastPathComponent], @"bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar/baz/"] lastPathComponent], @"baz");
#  ifdef OF_WINDOWS
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"\\\\foo\\bar"] lastPathComponent], @"bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"\\\\"] lastPathComponent], @"\\\\");
#  endif
# elif defined(OF_AMIGAOS)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:tmp"] lastPathComponent], @"tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:tmp/"] lastPathComponent], @"tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:/"] lastPathComponent], @"/");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:"] lastPathComponent], @"dh0:");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] lastPathComponent], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] lastPathComponent], @"bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar/baz/"] lastPathComponent], @"baz");
# elif defined(OF_WII) || defined(OF_NINTENDO_DS) || \
    defined(OF_NINTENDO_3DS) || defined(OF_NINTENDO_SWITCH)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"sdmc:/tmp"] lastPathComponent], @"tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"sdmc:/tmp/"] lastPathComponent], @"tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"sdmc:/"] lastPathComponent], @"sdmc:/");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"sdmc:"] lastPathComponent], @"sdmc:");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] lastPathComponent], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] lastPathComponent], @"bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar/baz/"] lastPathComponent], @"baz");
# else
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/tmp"] lastPathComponent], @"tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/tmp/"] lastPathComponent], @"tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/"] lastPathComponent], @"/");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] lastPathComponent], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] lastPathComponent], @"bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar/baz/"] lastPathComponent], @"baz");
# endif
}

- (void)testPathExtension
{
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo.bar"] pathExtension], @"bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/.bar"] pathExtension], @"");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/.bar.baz"] pathExtension], @"baz");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar.baz/"] pathExtension], @"baz");
}

- (void)testStringByDeletingLastPathComponent
{
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"\\tmp"] stringByDeletingLastPathComponent], @"\\");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/tmp/"] stringByDeletingLastPathComponent], @"/");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:\\"] stringByDeletingLastPathComponent], @"c:\\");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:/"] stringByDeletingLastPathComponent], @"c:/");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:\\tmp/foo/"] stringByDeletingLastPathComponent], @"c:\\tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo\\bar"] stringByDeletingLastPathComponent], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"\\"] stringByDeletingLastPathComponent], @"\\");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] stringByDeletingLastPathComponent], @".");
#  ifdef OF_WINDOWS
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"\\\\foo\\bar"] stringByDeletingLastPathComponent], @"\\\\foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"\\\\foo"] stringByDeletingLastPathComponent], @"\\\\");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"\\\\"] stringByDeletingLastPathComponent], @"\\\\");
#  endif
# elif defined(OF_AMIGAOS)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:"] stringByDeletingLastPathComponent], @"dh0:");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:tmp"] stringByDeletingLastPathComponent], @"dh0:");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:tmp/"] stringByDeletingLastPathComponent], @"dh0:");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:/"] stringByDeletingLastPathComponent], @"dh0:");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:tmp/foo/"] stringByDeletingLastPathComponent], @"dh0:tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] stringByDeletingLastPathComponent], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] stringByDeletingLastPathComponent], @"");
# elif defined(OF_NINTENDO_3DS) || defined(OF_WII) || \
    defined(OF_NINTENDO_SWITCH)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/tmp/"] stringByDeletingLastPathComponent], @"");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"sdmc:/tmp/foo/"] stringByDeletingLastPathComponent],
	    @"sdmc:/tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"sdmc:/"] stringByDeletingLastPathComponent], @"sdmc:/");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] stringByDeletingLastPathComponent], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/"] stringByDeletingLastPathComponent], @"");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] stringByDeletingLastPathComponent], @".");
# else
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/tmp"] stringByDeletingLastPathComponent], @"/");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/tmp/"] stringByDeletingLastPathComponent], @"/");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/tmp/foo/"] stringByDeletingLastPathComponent], @"/tmp");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo/bar"] stringByDeletingLastPathComponent], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/"] stringByDeletingLastPathComponent], @"/");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo"] stringByDeletingLastPathComponent], @".");
# endif
}

- (void)testStringByDeletingPathExtension
{
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo.bar"] stringByDeletingPathExtension], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo..bar"] stringByDeletingPathExtension], @"foo.");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:/foo.\\bar"] stringByDeletingPathExtension], @"c:/foo.\\bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:\\foo./bar.baz"] stringByDeletingPathExtension],
	    @"c:\\foo.\\bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo.bar/"] stringByDeletingPathExtension], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @".foo"] stringByDeletingPathExtension], @".foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @".foo.bar"] stringByDeletingPathExtension], @".foo");
# elif defined(OF_AMIGAOS)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo.bar"] stringByDeletingPathExtension], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo..bar"] stringByDeletingPathExtension], @"foo.");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:foo.bar"] stringByDeletingPathExtension], @"dh0:foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:foo./bar"] stringByDeletingPathExtension], @"dh0:foo./bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"dh0:foo./bar.baz"] stringByDeletingPathExtension],
	    @"dh0:foo./bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo.bar/"] stringByDeletingPathExtension], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @".foo"] stringByDeletingPathExtension], @".foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @".foo\\bar"] stringByDeletingPathExtension], @".foo\\bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @".foo.bar"] stringByDeletingPathExtension], @".foo");
# elif defined(OF_WII) || defined(OF_NINTENDO_DS) || \
    defined(OF_NINTENDO_3DS) || defined(OF_NINTENDO_SWITCH)
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo.bar"] stringByDeletingPathExtension], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo..bar"] stringByDeletingPathExtension], @"foo.");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"sdmc:/foo./bar"] stringByDeletingPathExtension],
	    @"sdmc:/foo./bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"sdmc:/foo./bar.baz"] stringByDeletingPathExtension],
	    @"sdmc:/foo./bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo.bar/"] stringByDeletingPathExtension], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @".foo"] stringByDeletingPathExtension], @".foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @".foo.bar"] stringByDeletingPathExtension], @".foo");
# else
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo.bar"] stringByDeletingPathExtension], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo..bar"] stringByDeletingPathExtension], @"foo.");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/foo./bar"] stringByDeletingPathExtension], @"/foo./bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"/foo./bar.baz"] stringByDeletingPathExtension], @"/foo./bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"foo.bar/"] stringByDeletingPathExtension], @"foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @".foo"] stringByDeletingPathExtension], @".foo");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @".foo\\bar"] stringByDeletingPathExtension], @".foo\\bar");
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @".foo.bar"] stringByDeletingPathExtension], @".foo");
# endif
}

# if defined(OF_WINDOWS) || defined(OF_MSDOS)
- (void)testStringByStandardizingPath
{
	/* TODO: Add more tests */

	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"c:\\..\\asd"] stringByStandardizingPath],
	    @"c:\\..\\asd");

#  ifndef OF_MSDOS
	OTAssertEqualObjects([[self.stringClass stringWithString:
	    @"\\\\foo\\..\\bar\\qux"] stringByStandardizingPath],
	    @"\\\\bar\\qux");
#  endif
}
# endif
#endif
@end

@implementation CustomString
- (instancetype)init
{
	self = [super init];

	@try {
		_string = [[OFMutableString alloc] init];
	} @catch (id e) {
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492

- (size_t)length
{
	return _string.length;
}
@end

@implementation SimpleMutableString
+ (void)initialize
{
	if (self == [SimpleMutableString class])
		[self inheritMethodsFromClass: [SimpleString class]];
}

- (void)replaceCharactersInRange: (OFRange)range
		      withString: (OFString *)string
{
	[_string replaceCharactersInRange: range withString: string];
}
@end

@interface EntityHandler: OFObject <OFStringXMLUnescapingDelegate>
@end

@implementation EntityHandler
-	  (OFString *)string: (OFString *)string
  containsUnknownEntityNamed: (OFString *)entity
{
	if ([entity isEqual: @"foo"])
		return @"bar";

	return nil;
}
@end

@implementation TestsAppDelegate (OFStringTests)
- (void)stringTestsWithClass: (Class)stringClass
		mutableClass: (Class)mutableStringClass
{
	void *pool = objc_autoreleasePoolPush();
	OFMutableString *mutableString1, *mutableString2, *mutableString3;
	OFString *string;
	OFArray *array;
	size_t i;
	const OFUnichar *characters;
	const uint16_t *UTF16Characters;
	OFCharacterSet *characterSet;
	EntityHandler *entityHandler;
#ifdef OF_HAVE_BLOCKS
	__block int j;
	__block bool ok;
#endif

#define C(s) ((OFString *)[stringClass stringWithString: s])

	mutableString1 = [mutableStringClass stringWithString: @"täs€"];
	mutableString2 = [mutableStringClass string];
	mutableString3 = [[mutableString1 copy] autorelease];

	TEST(@"-[isEqual:]", [mutableString1 isEqual: mutableString3] &&
	    ![mutableString1 isEqual: [[[OFObject alloc] init] autorelease]])

	TEST(@"-[compare:]",
	    [mutableString1 compare: mutableString3] == OFOrderedSame &&
	    [mutableString1 compare: @""] != OFOrderedSame &&
	    [C(@"") compare: @"a"] == OFOrderedAscending &&
	    [C(@"a") compare: @"b"] == OFOrderedAscending &&
	    [C(@"cd") compare: @"bc"] == OFOrderedDescending &&
	    [C(@"ä") compare: @"ö"] == OFOrderedAscending &&
	    [C(@"€") compare: @"ß"] == OFOrderedDescending &&
	    [C(@"aa") compare: @"z"] == OFOrderedAscending)

#ifdef OF_HAVE_UNICODE_TABLES
	TEST(@"-[caseInsensitiveCompare:]",
	    [C(@"a") caseInsensitiveCompare: @"A"] == OFOrderedSame &&
	    [C(@"Ä") caseInsensitiveCompare: @"ä"] == OFOrderedSame &&
	    [C(@"я") caseInsensitiveCompare: @"Я"] == OFOrderedSame &&
	    [C(@"€") caseInsensitiveCompare: @"ß"] == OFOrderedDescending &&
	    [C(@"ß") caseInsensitiveCompare: @"→"] == OFOrderedAscending &&
	    [C(@"AA") caseInsensitiveCompare: @"z"] == OFOrderedAscending &&
	    [[stringClass stringWithUTF8String: "ABC"] caseInsensitiveCompare:
	    [stringClass stringWithUTF8String: "AbD"]] ==
	    [C(@"abc") compare: @"abd"])
#else
	TEST(@"-[caseInsensitiveCompare:]",
	    [C(@"a") caseInsensitiveCompare: @"A"] == OFOrderedSame &&
	    [C(@"AA") caseInsensitiveCompare: @"z"] == OFOrderedAscending &&
	    [[stringClass stringWithUTF8String: "ABC"] caseInsensitiveCompare:
	    [stringClass stringWithUTF8String: "AbD"]] ==
	    [C(@"abc") compare: @"abd"])
#endif

	TEST(@"-[hash] is the same if -[isEqual:] is true",
	    mutableString1.hash == mutableString3.hash)

	TEST(@"-[description]",
	    [mutableString1.description isEqual: mutableString1])

	TEST(@"-[appendString:] and -[appendUTF8String:]",
	    R([mutableString2 appendUTF8String: "1𝄞"]) &&
	    R([mutableString2 appendString: @"3"]) &&
	    R([mutableString1 appendString: mutableString2]) &&
	    [mutableString1 isEqual: @"täs€1𝄞3"])

	TEST(@"-[appendCharacters:length:]",
	    R([mutableString2 appendCharacters: unicharString + 6 length: 2]) &&
	    [mutableString2 isEqual: @"1𝄞3r🀺"])

	TEST(@"-[length]", mutableString1.length == 7)
	TEST(@"-[UTF8StringLength]", mutableString1.UTF8StringLength == 13)
	TEST(@"-[hash]", mutableString1.hash == 0x705583C0)

	TEST(@"-[characterAtIndex:]",
	    [mutableString1 characterAtIndex: 0] == 't' &&
	    [mutableString1 characterAtIndex: 1] == 0xE4 &&
	    [mutableString1 characterAtIndex: 3] == 0x20AC &&
	    [mutableString1 characterAtIndex: 5] == 0x1D11E)

	EXPECT_EXCEPTION(@"Detect out of range in -[characterAtIndex:]",
	    OFOutOfRangeException, [mutableString1 characterAtIndex: 7])

	mutableString2 = [mutableStringClass stringWithString: @"abc"];

#ifdef OF_HAVE_UNICODE_TABLES
	TEST(@"-[uppercase]", R([mutableString1 uppercase]) &&
	    [mutableString1 isEqual: @"TÄS€1𝄞3"] &&
	    R([mutableString2 uppercase]) && [mutableString2 isEqual: @"ABC"])

	TEST(@"-[lowercase]", R([mutableString1 lowercase]) &&
	    [mutableString1 isEqual: @"täs€1𝄞3"] &&
	    R([mutableString2 lowercase]) && [mutableString2 isEqual: @"abc"])

	TEST(@"-[uppercaseString]",
	    [[mutableString1 uppercaseString] isEqual: @"TÄS€1𝄞3"])

	TEST(@"-[lowercaseString]", R([mutableString1 uppercase]) &&
	    [[mutableString1 lowercaseString] isEqual: @"täs€1𝄞3"])

	TEST(@"-[capitalizedString]", [C(@"džbla tdžst TDŽST").capitalizedString
	    isEqual: @"Džbla Tdžst Tdžst"])
#else
	TEST(@"-[uppercase]", R([mutableString1 uppercase]) &&
	    [mutableString1 isEqual: @"3𝄞1€SäT"] &&
	    R([mutableString2 uppercase]) && [mutableString2 isEqual: @"ABC"])

	TEST(@"-[lowercase]", R([mutableString1 lowercase]) &&
	    [mutableString1 isEqual: @"3𝄞1€sät"] &&
	    R([mutableString2 lowercase]) && [mutableString2 isEqual: @"abc"])

	TEST(@"-[uppercaseString]",
	    [mutableString1.uppercaseString isEqual: @"3𝄞1€SäT"])

	TEST(@"-[lowercaseString]",
	    R([mutableString1 uppercase]) &&
	    [mutableString1.lowercaseString isEqual: @"3𝄞1€sät"])

	TEST(@"-[capitalizedString]", [C(@"džbla tdžst TDŽST").capitalizedString
	    isEqual: @"džbla Tdžst TDŽst"])
#endif

	TEST(@"+[stringWithUTF8String:length:]",
	    (mutableString1 = [mutableStringClass
	    stringWithUTF8String: "\xEF\xBB\xBF" "foobar"
			  length: 6]) &&
	    [mutableString1 isEqual: @"foo"])

	TEST(@"+[stringWithUTF16String:]",
	    (string = [stringClass stringWithUTF16String: char16String]) &&
	    [string isEqual: @"fööbär🀺"] &&
	    (string = [stringClass stringWithUTF16String:
	    swappedChar16String]) && [string isEqual: @"fööbär🀺"])

	TEST(@"+[stringWithUTF32String:]",
	    (string = [stringClass stringWithUTF32String: unicharString]) &&
	    [string isEqual: @"fööbär🀺"] &&
	    (string = [stringClass stringWithUTF32String:
	    swappedUnicharString]) && [string isEqual: @"fööbär🀺"])

#ifdef OF_HAVE_FILES
	TEST(@"+[stringWithContentsOfFile:encoding]", (string = [stringClass
	    stringWithContentsOfFile: @"testfile.txt"
			    encoding: OFStringEncodingISO8859_1]) &&
	    [string isEqual: @"testäöü"])

	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]) &&
	    [mutableString1 isEqual: @"foobar"])

	EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #1",
	    OFInvalidEncodingException,
	    [stringClass stringWithUTF8String: "\xE0\x80"])
	EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #2",
	    OFInvalidEncodingException,
	    [stringClass stringWithUTF8String: "\xF0\x80\x80\xC0"])

	TEST(@"Conversion of ISO 8859-1 to Unicode",
	    [[stringClass stringWithCString: "\xE4\xF6\xFC"
				   encoding: OFStringEncodingISO8859_1]
	    isEqual: @"äöü"])

#ifdef HAVE_ISO_8859_15
	TEST(@"Conversion of ISO 8859-15 to Unicode",
	    [[stringClass stringWithCString: "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE"
				   encoding: OFStringEncodingISO8859_15]
	    isEqual: @"€ŠšŽžŒœŸ"])
#endif

#ifdef HAVE_WINDOWS_1252
	TEST(@"Conversion of Windows 1252 to Unicode",
	    [[stringClass stringWithCString: "\x80\x82\x83\x84\x85\x86\x87\x88"
					     "\x89\x8A\x8B\x8C\x8E\x91\x92\x93"
					     "\x94\x95\x96\x97\x98\x99\x9A\x9B"
					     "\x9C\x9E\x9F"
				   encoding: OFStringEncodingWindows1252]
	    isEqual: @"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ"])
#endif

#ifdef HAVE_CODEPAGE_437
	TEST(@"Conversion of Codepage 437 to Unicode",
	    [[stringClass stringWithCString: "\xB0\xB1\xB2\xDB"
				   encoding: OFStringEncodingCodepage437]
	    isEqual: @"░▒▓█"])
#endif

	TEST(@"Conversion of Unicode to ASCII #1",
	    !strcmp([C(@"This is a test") cStringWithEncoding:
	    OFStringEncodingASCII], "This is a test"))

	EXPECT_EXCEPTION(@"Conversion of Unicode to ASCII #2",
	    OFInvalidEncodingException,
	    [C(@"This is a tést")
	    cStringWithEncoding: OFStringEncodingASCII])

	TEST(@"Conversion of Unicode to ISO-8859-1 #1",
	    !strcmp([C(@"This is ä test") cStringWithEncoding:
	    OFStringEncodingISO8859_1], "This is \xE4 test"))

	EXPECT_EXCEPTION(@"Conversion of Unicode to ISO-8859-1 #2",
	    OFInvalidEncodingException,
	    [C(@"This is ä t€st") cStringWithEncoding:
	    OFStringEncodingISO8859_1])

#ifdef HAVE_ISO_8859_15
	TEST(@"Conversion of Unicode to ISO-8859-15 #1",
	    !strcmp([C(@"This is ä t€st") cStringWithEncoding:
	    OFStringEncodingISO8859_15], "This is \xE4 t\xA4st"))

	EXPECT_EXCEPTION(@"Conversion of Unicode to ISO-8859-15 #2",
	    OFInvalidEncodingException,
	    [C(@"This is ä t€st…") cStringWithEncoding:
	    OFStringEncodingISO8859_15])
#endif

#ifdef HAVE_WINDOWS_1252
	TEST(@"Conversion of Unicode to Windows-1252 #1",
	    !strcmp([C(@"This is ä t€st…") cStringWithEncoding:
	    OFStringEncodingWindows1252], "This is \xE4 t\x80st\x85"))

	EXPECT_EXCEPTION(@"Conversion of Unicode to Windows-1252 #2",
	    OFInvalidEncodingException, [C(@"This is ä t€st…‼")
	    cStringWithEncoding: OFStringEncodingWindows1252])
#endif

#ifdef HAVE_CODEPAGE_437
	TEST(@"Conversion of Unicode to Codepage 437 #1",
	    !strcmp([C(@"Tést strîng ░▒▓") cStringWithEncoding:
	    OFStringEncodingCodepage437], "T\x82st str\x8Cng \xB0\xB1\xB2"))

	EXPECT_EXCEPTION(@"Conversion of Unicode to Codepage 437 #2",
	    OFInvalidEncodingException, [C(@"T€st strîng ░▒▓")
	    cStringWithEncoding: OFStringEncodingCodepage437])
#endif

	TEST(@"Lossy conversion of Unicode to ASCII",
	    !strcmp([C(@"This is a tést") lossyCStringWithEncoding:
	    OFStringEncodingASCII], "This is a t?st"))

	TEST(@"Lossy conversion of Unicode to ISO-8859-1",
	    !strcmp([C(@"This is ä t€st") lossyCStringWithEncoding:
	    OFStringEncodingISO8859_1], "This is \xE4 t?st"))

#ifdef HAVE_ISO_8859_15
	TEST(@"Lossy conversion of Unicode to ISO-8859-15",
	    !strcmp([C(@"This is ä t€st…") lossyCStringWithEncoding:
	    OFStringEncodingISO8859_15], "This is \xE4 t\xA4st?"))
#endif

#ifdef HAVE_WINDOWS_1252
	TEST(@"Lossy conversion of Unicode to Windows-1252",
	    !strcmp([C(@"This is ä t€st…‼") lossyCStringWithEncoding:
	    OFStringEncodingWindows1252], "This is \xE4 t\x80st\x85?"))
#endif

#ifdef HAVE_CODEPAGE_437
	TEST(@"Lossy conversion of Unicode to Codepage 437",
	    !strcmp([C(@"T€st strîng ░▒▓") lossyCStringWithEncoding:
	    OFStringEncodingCodepage437], "T?st str\x8Cng \xB0\xB1\xB2"))
#endif

	TEST(@"+[stringWithFormat:]",
	    [(mutableString1 = [mutableStringClass stringWithFormat: @"%@:%d",
								     @"test",
								     123])
	    isEqual: @"test:123"])

	TEST(@"-[appendFormat:]",
	    R(([mutableString1 appendFormat: @"%02X", 15])) &&
	    [mutableString1 isEqual: @"test:1230F"])

	TEST(@"-[rangeOfString:]",
	    [C(@"𝄞öö") rangeOfString: @"öö"].location == 1 &&
	    [C(@"𝄞öö") rangeOfString: @"ö"].location == 1 &&
	    [C(@"𝄞öö") rangeOfString: @"𝄞"].location == 0 &&
	    [C(@"𝄞öö") rangeOfString: @"x"].location == OFNotFound &&
	    [C(@"𝄞öö") rangeOfString: @"öö"
	    options: OFStringSearchBackwards].location == 1 &&
	    [C(@"𝄞öö") rangeOfString: @"ö"
	    options: OFStringSearchBackwards].location == 2 &&
	    [C(@"𝄞öö") rangeOfString: @"𝄞"
	    options: OFStringSearchBackwards].location == 0 &&
	    [C(@"𝄞öö") rangeOfString: @"x"
	    options: OFStringSearchBackwards].location == OFNotFound)

	EXPECT_EXCEPTION(
	    @"Detect out of range in -[rangeOfString:options:range:]",
	    OFOutOfRangeException,
	    [C(@"𝄞öö") rangeOfString: @"ö" options: 0 range: OFMakeRange(3, 1)])

	characterSet =
	    [OFCharacterSet characterSetWithCharactersInString: @"cđ"];
	TEST(@"-[indexOfCharacterFromSet:]",
	    [C(@"abcđabcđe") indexOfCharacterFromSet: characterSet] == 2 &&
	    [C(@"abcđabcđë")
	    indexOfCharacterFromSet: characterSet
			    options: OFStringSearchBackwards] == 7 &&
	    [C(@"abcđabcđë") indexOfCharacterFromSet: characterSet
					     options: 0
					       range: OFMakeRange(4, 4)] == 6 &&
	    [C(@"abcđabcđëf")
	    indexOfCharacterFromSet: characterSet
			    options: 0
			      range: OFMakeRange(8, 2)] == OFNotFound)

	EXPECT_EXCEPTION(
	    @"Detect out of range in -[indexOfCharacterFromSet:options:range:]",
	    OFOutOfRangeException,
	    [C(@"𝄞öö") indexOfCharacterFromSet: characterSet
				       options: 0
					 range: OFMakeRange(3, 1)])

	TEST(@"-[substringWithRange:]",
	    [[C(@"𝄞öö") substringWithRange: OFMakeRange(1, 1)] isEqual: @"ö"] &&
	    [[C(@"𝄞öö") substringWithRange: OFMakeRange(3, 0)] isEqual: @""])

	EXPECT_EXCEPTION(@"Detect out of range in -[substringWithRange:] #1",
	    OFOutOfRangeException,
	    [C(@"𝄞öö") substringWithRange: OFMakeRange(2, 2)])
	EXPECT_EXCEPTION(@"Detect out of range in -[substringWithRange:] #2",
	    OFOutOfRangeException,
	    [C(@"𝄞öö") substringWithRange: OFMakeRange(4, 0)])

	TEST(@"-[stringByAppendingString:]",
	    [[C(@"foo") stringByAppendingString: @"bar"] isEqual: @"foobar"])

#ifdef OF_HAVE_FILES
# if defined(OF_WINDOWS)
	TEST(@"-[isAbsolutePath]",
	    C(@"C:\\foo").absolutePath && C(@"a:/foo").absolutePath &&
	    !C(@"foo").absolutePath && !C(@"b:foo").absolutePath &&
	    C(@"\\\\foo").absolutePath)
# elif  defined(OF_MSDOS)
	TEST(@"-[isAbsolutePath]",
	    C(@"C:\\foo").absolutePath && C(@"a:/foo").absolutePath &&
	    !C(@"foo").absolutePath && !C(@"b:foo").absolutePath)
# elif defined(OF_AMIGAOS)
	TEST(@"-[isAbsolutePath]",
	    C(@"dh0:foo").absolutePath && C(@"dh0:a/b").absolutePath &&
	    !C(@"foo/bar").absolutePath && !C(@"foo").absolutePath)
# elif defined(OF_NINTENDO_3DS) || defined(OF_WII) || \
    defined(OF_NINTENDO_SWITCH)
	TEST(@"-[isAbsolutePath]",
	    C(@"sdmc:/foo").absolutePath && !C(@"sdmc:foo").absolutePath &&
	    !C(@"foo/bar").absolutePath && !C(@"foo").absolutePath)
# else
	TEST(@"-[isAbsolutePath]",
	    C(@"/foo").absolutePath && C(@"/foo/bar").absolutePath &&
	    !C(@"foo/bar").absolutePath && !C(@"foo").absolutePath)
# endif

	mutableString1 = [mutableStringClass stringWithString: @"foo"];
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	[mutableString1 appendString: @"\\"];
# else
	[mutableString1 appendString: @"/"];
# endif
	[mutableString1 appendString: @"bar"];
	mutableString2 = [mutableStringClass stringWithString: mutableString1];
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	[mutableString2 appendString: @"\\"];
# else
	[mutableString2 appendString: @"/"];
# endif
	string = [stringClass stringWithString: mutableString2];
	[mutableString2 appendString: @"baz"];
	TEST(@"-[stringByAppendingPathComponent:]",
	    [[mutableString1 stringByAppendingPathComponent: @"baz"]
	    isEqual: mutableString2] &&
	    [[string stringByAppendingPathComponent: @"baz"]
	    isEqual: mutableString2])

# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	TEST(@"-[stringByAppendingPathExtension:]",
	    [[C(@"foo") stringByAppendingPathExtension: @"bar"]
	    isEqual: @"foo.bar"] &&
	    [[C(@"c:\\tmp\\foo") stringByAppendingPathExtension: @"bar"]
	    isEqual: @"c:\\tmp\\foo.bar"] &&
	    [[C(@"c:\\tmp\\/\\") stringByAppendingPathExtension: @"bar"]
	    isEqual: @"c:\\tmp.bar"])
# elif defined(OF_AMIGAOS)
	TEST(@"-[stringByAppendingPathExtension:]",
	    [[C(@"foo") stringByAppendingPathExtension: @"bar"]
	    isEqual: @"foo.bar"] &&
	    [[C(@"foo/bar") stringByAppendingPathExtension: @"baz"]
	    isEqual: @"foo/bar.baz"])
# else
	TEST(@"-[stringByAppendingPathExtension:]",
	    [[C(@"foo") stringByAppendingPathExtension: @"bar"]
	    isEqual: @"foo.bar"] &&
	    [[C(@"foo/bar") stringByAppendingPathExtension: @"baz"]
	    isEqual: @"foo/bar.baz"] &&
	    [[C(@"foo///") stringByAppendingPathExtension: @"bar"]
	    isEqual: @"foo.bar"])
# endif
#endif

	TEST(@"-[hasPrefix:]", [C(@"foobar") hasPrefix: @"foo"] &&
	    ![C(@"foobar") hasPrefix: @"foobar0"])

	TEST(@"-[hasSuffix:]", [C(@"foobar") hasSuffix: @"bar"] &&
	    ![C(@"foobar") hasSuffix: @"foobar0"])

	i = 0;
	TEST(@"-[componentsSeparatedByString:]",
	    (array = [C(@"fooXXbarXXXXbazXXXX")
	    componentsSeparatedByString: @"XX"]) &&
	    [[array objectAtIndex: i++] isEqual: @"foo"] &&
	    [[array objectAtIndex: i++] isEqual: @"bar"] &&
	    [[array objectAtIndex: i++] isEqual: @""] &&
	    [[array objectAtIndex: i++] isEqual: @"baz"] &&
	    [[array objectAtIndex: i++] isEqual: @""] &&
	    [[array objectAtIndex: i++] isEqual: @""] &&
	    array.count == i &&
	    (array = [C(@"foo") componentsSeparatedByString: @""]) &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    array.count == 1)

	i = 0;
	TEST(@"-[componentsSeparatedByString:options:]",
	    (array = [C(@"fooXXbarXXXXbazXXXX")
	    componentsSeparatedByString: @"XX"
				options: OFStringSkipEmptyComponents]) &&
	    [[array objectAtIndex: i++] isEqual: @"foo"] &&
	    [[array objectAtIndex: i++] isEqual: @"bar"] &&
	    [[array objectAtIndex: i++] isEqual: @"baz"] &&
	    array.count == i)

	characterSet =
	    [OFCharacterSet characterSetWithCharactersInString: @"XYZ"];

	i = 0;
	TEST(@"-[componentsSeparatedByCharactersInSet:]",
	    (array = [C(@"fooXYbarXYZXbazXYXZx")
	    componentsSeparatedByCharactersInSet: characterSet]) &&
	    [[array objectAtIndex: i++] isEqual: @"foo"] &&
	    [[array objectAtIndex: i++] isEqual: @""] &&
	    [[array objectAtIndex: i++] isEqual: @"bar"] &&
	    [[array objectAtIndex: i++] isEqual: @""] &&
	    [[array objectAtIndex: i++] isEqual: @""] &&
	    [[array objectAtIndex: i++] isEqual: @""] &&
	    [[array objectAtIndex: i++] isEqual: @"baz"] &&
	    [[array objectAtIndex: i++] isEqual: @""] &&
	    [[array objectAtIndex: i++] isEqual: @""] &&
	    [[array objectAtIndex: i++] isEqual: @""] &&
	    [[array objectAtIndex: i++] isEqual: @"x"] &&
	    array.count == i)

	i = 0;
	TEST(@"-[componentsSeparatedByCharactersInSet:options:]",
	    (array = [C(@"fooXYbarXYZXbazXYXZ")
	    componentsSeparatedByCharactersInSet: characterSet
	    options: OFStringSkipEmptyComponents]) &&
	    [[array objectAtIndex: i++] isEqual: @"foo"] &&
	    [[array objectAtIndex: i++] isEqual: @"bar"] &&
	    [[array objectAtIndex: i++] isEqual: @"baz"] &&
	    array.count == i)

#ifdef OF_HAVE_FILES
# if defined(OF_WINDOWS)
	TEST(@"+[pathWithComponents:]",
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]] isEqual: @"foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"c:\\", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"c:\\foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"c:", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"c:foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"c:", @"\\", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"c:\\foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"c:", @"/", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"c:/foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo/", @"bar\\", @"", @"baz", @"\\", nil]]
	    isEqual: @"foo/bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", nil]] isEqual: @"foo"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObject: @"c:"]]
	    isEqual: @"c:"] &&
	    [[stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"c:\\"]] isEqual: @"c:\\"] &&
	    [[stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"\\"]] isEqual: @"\\"] &&
	    [[stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"/"]] isEqual: @"/"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"\\\\", @"foo", @"bar", nil]] isEqual: @"\\\\foo\\bar"])
# elif defined(OF_MSDOS)
	TEST(@"+[pathWithComponents:]",
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]] isEqual: @"foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"c:\\", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"c:\\foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"c:", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"c:foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"c:", @"\\", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"c:\\foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"c:", @"/", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"c:/foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo/", @"bar\\", @"", @"baz", @"\\", nil]]
	    isEqual: @"foo/bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", nil]] isEqual: @"foo"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObject: @"c:"]]
	    isEqual: @"c:"] &&
	    [[stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"c:\\"]] isEqual: @"c:\\"] &&
	    [[stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"\\"]] isEqual: @"\\"] &&
	    [[stringClass pathWithComponents:
	    [OFArray arrayWithObject: @"/"]] isEqual: @"/"])
# elif defined(OF_AMIGAOS)
	TEST(@"+[pathWithComponents:]",
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"dh0:", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"dh0:foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]] isEqual: @"foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo/", @"bar", @"", @"baz", @"/", nil]]
	    isEqual: @"foo//bar/baz//"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", nil]] isEqual: @"foo"])
# elif defined(OF_NINTENDO_3DS) || defined(OF_WII) || \
    defined(OF_NINTENDO_SWITCH)
	TEST(@"+[pathWithComponents:]",
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]] isEqual: @"foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"sdmc:", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"sdmc:/foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo/", @"bar/", @"", @"baz", @"/", nil]]
	    isEqual: @"foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", nil]] isEqual: @"foo"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObject:
	    @"sdmc:"]] isEqual: @"sdmc:/"])
# else
	TEST(@"+[pathWithComponents:]",
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"/", @"foo", @"bar", @"baz", nil]] isEqual: @"/foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]] isEqual: @"foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo/", @"bar", @"", @"baz", @"/", nil]]
	    isEqual: @"foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", nil]] isEqual: @"foo"])
# endif

# if defined(OF_WINDOWS)
	TEST(@"-[pathComponents]",
	    /* c:/tmp */
	    (array = C(@"c:/tmp").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"c:/"] &&
	    [[array objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* c:\tmp\ */
	    (array = C(@"c:\\tmp\\").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"c:\\"] &&
	    [[array objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* c:\ */
	    (array = C(@"c:\\").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"c:\\"] &&
	    /* c:/ */
	    (array = C(@"c:/").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"c:/"] &&
	    /* c: */
	    (array = C(@"c:").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"c:"] &&
	    /* foo\bar */
	    (array = C(@"foo\\bar").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"bar"] &&
	    /* foo\bar/baz/ */
	    (array = C(@"foo\\bar/baz/").pathComponents) && array.count == 3 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"bar"] &&
	    [[array objectAtIndex: 2] isEqual: @"baz"] &&
	    /* foo\/ */
	    (array = C(@"foo\\/").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    /* \\foo\bar */
	    (array = C(@"\\\\foo\\bar").pathComponents) && array.count == 3 &&
	    [[array objectAtIndex: 0] isEqual: @"\\\\"] &&
	    [[array objectAtIndex: 1] isEqual: @"foo"] &&
	    [[array objectAtIndex: 2] isEqual: @"bar"] &&
	    C(@"").pathComponents.count == 0)
# elif defined(OF_MSDOS)
	TEST(@"-[pathComponents]",
	    /* c:/tmp */
	    (array = C(@"c:/tmp").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"c:/"] &&
	    [[array objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* c:\tmp\ */
	    (array = C(@"c:\\tmp\\").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"c:\\"] &&
	    [[array objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* c:\ */
	    (array = C(@"c:\\").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"c:\\"] &&
	    /* c:/ */
	    (array = C(@"c:/").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"c:/"] &&
	    /* c: */
	    (array = C(@"c:").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"c:"] &&
	    /* foo\bar */
	    (array = C(@"foo\\bar").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"bar"] &&
	    /* foo\bar/baz/ */
	    (array = C(@"foo\\bar/baz/").pathComponents) && array.count == 3 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"bar"] &&
	    [[array objectAtIndex: 2] isEqual: @"baz"] &&
	    /* foo\/ */
	    (array = C(@"foo\\/").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    C(@"").pathComponents.count == 0)
# elif defined(OF_AMIGAOS)
	TEST(@"-[pathComponents]",
	    /* dh0:tmp */
	    (array = C(@"dh0:tmp").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"dh0:"] &&
	    [[array objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* dh0:tmp/ */
	    (array = C(@"dh0:tmp/").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"dh0:"] &&
	    [[array objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* dh0: */
	    (array = C(@"dh0:/").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"dh0:"] &&
	    [[array objectAtIndex: 1] isEqual: @"/"] &&
	    /* foo/bar */
	    (array = C(@"foo/bar").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"bar"] &&
	    /* foo/bar/baz/ */
	    (array = C(@"foo/bar/baz/").pathComponents) && array.count == 3 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"bar"] &&
	    [[array objectAtIndex: 2] isEqual: @"baz"] &&
	    /* foo// */
	    (array = C(@"foo//").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"/"] &&
	    C(@"").pathComponents.count == 0)
# elif defined(OF_NINTENDO_3DS) || defined(OF_WII) || \
    defined(OF_NINTENDO_SWITCH)
	TEST(@"-[pathComponents]",
	    /* sdmc:/tmp */
	    (array = C(@"sdmc:/tmp").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"sdmc:"] &&
	    [[array objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* sdmc:/ */
	    (array = C(@"sdmc:/").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"sdmc:"] &&
	    /* foo/bar */
	    (array = C(@"foo/bar").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"bar"] &&
	    /* foo/bar/baz/ */
	    (array = C(@"foo/bar/baz/").pathComponents) && array.count == 3 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"bar"] &&
	    [[array objectAtIndex: 2] isEqual: @"baz"] &&
	    /* foo// */
	    (array = C(@"foo//").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    C(@"").pathComponents.count == 0)
# else
	TEST(@"-[pathComponents]",
	    /* /tmp */
	    (array = C(@"/tmp").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"/"] &&
	    [[array objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* /tmp/ */
	    (array = C(@"/tmp/").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"/"] &&
	    [[array objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* / */
	    (array = C(@"/").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"/"] &&
	    /* foo/bar */
	    (array = C(@"foo/bar").pathComponents) && array.count == 2 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"bar"] &&
	    /* foo/bar/baz/ */
	    (array = C(@"foo/bar/baz/").pathComponents) && array.count == 3 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    [[array objectAtIndex: 1] isEqual: @"bar"] &&
	    [[array objectAtIndex: 2] isEqual: @"baz"] &&
	    /* foo// */
	    (array = C(@"foo//").pathComponents) && array.count == 1 &&
	    [[array objectAtIndex: 0] isEqual: @"foo"] &&
	    C(@"").pathComponents.count == 0)
# endif

# if defined(OF_WINDOWS)
	TEST(@"-[lastPathComponent]",
	    [C(@"c:/tmp").lastPathComponent isEqual: @"tmp"] &&
	    [C(@"c:\\tmp\\").lastPathComponent isEqual: @"tmp"] &&
	    [C(@"c:\\").lastPathComponent isEqual: @"c:\\"] &&
	    [C(@"c:/").lastPathComponent isEqual: @"c:/"] &&
	    [C(@"\\").lastPathComponent isEqual: @"\\"] &&
	    [C(@"foo").lastPathComponent isEqual: @"foo"] &&
	    [C(@"foo\\bar").lastPathComponent isEqual: @"bar"] &&
	    [C(@"foo/bar/baz/").lastPathComponent isEqual: @"baz"] &&
	    [C(@"\\\\foo\\bar").lastPathComponent isEqual: @"bar"] &&
	    [C(@"\\\\").lastPathComponent isEqual: @"\\\\"])
# elif defined(OF_MSDOS)
	TEST(@"-[lastPathComponent]",
	    [C(@"c:/tmp").lastPathComponent isEqual: @"tmp"] &&
	    [C(@"c:\\tmp\\").lastPathComponent isEqual: @"tmp"] &&
	    [C(@"c:\\").lastPathComponent isEqual: @"c:\\"] &&
	    [C(@"c:/").lastPathComponent isEqual: @"c:/"] &&
	    [C(@"\\").lastPathComponent isEqual: @"\\"] &&
	    [C(@"foo").lastPathComponent isEqual: @"foo"] &&
	    [C(@"foo\\bar").lastPathComponent isEqual: @"bar"] &&
	    [C(@"foo/bar/baz/").lastPathComponent isEqual: @"baz"])
# elif defined(OF_AMIGAOS)
	TEST(@"-[lastPathComponent]",
	    [C(@"dh0:tmp").lastPathComponent isEqual: @"tmp"] &&
	    [C(@"dh0:tmp/").lastPathComponent isEqual: @"tmp"] &&
	    [C(@"dh0:/").lastPathComponent isEqual: @"/"] &&
	    [C(@"dh0:").lastPathComponent isEqual: @"dh0:"] &&
	    [C(@"foo").lastPathComponent isEqual: @"foo"] &&
	    [C(@"foo/bar").lastPathComponent isEqual: @"bar"] &&
	    [C(@"foo/bar/baz/").lastPathComponent isEqual: @"baz"])
# elif defined(OF_NINTENDO_3DS) || defined(OF_WII) || \
    defined(OF_NINTENDO_SWITCH)
	TEST(@"-[lastPathComponent]",
	    [C(@"sdmc:/tmp").lastPathComponent isEqual: @"tmp"] &&
	    [C(@"sdmc:/tmp/").lastPathComponent isEqual: @"tmp"] &&
	    [C(@"sdmc:/").lastPathComponent isEqual: @"sdmc:/"] &&
	    [C(@"sdmc:").lastPathComponent isEqual: @"sdmc:"] &&
	    [C(@"foo").lastPathComponent isEqual: @"foo"] &&
	    [C(@"foo/bar").lastPathComponent isEqual: @"bar"] &&
	    [C(@"foo/bar/baz/").lastPathComponent isEqual: @"baz"])
# else
	TEST(@"-[lastPathComponent]",
	    [C(@"/tmp").lastPathComponent isEqual: @"tmp"] &&
	    [C(@"/tmp/").lastPathComponent isEqual: @"tmp"] &&
	    [C(@"/").lastPathComponent isEqual: @"/"] &&
	    [C(@"foo").lastPathComponent isEqual: @"foo"] &&
	    [C(@"foo/bar").lastPathComponent isEqual: @"bar"] &&
	    [C(@"foo/bar/baz/").lastPathComponent isEqual: @"baz"])
# endif

	TEST(@"-[pathExtension]",
	    [C(@"foo.bar").pathExtension isEqual: @"bar"] &&
	    [C(@"foo/.bar").pathExtension isEqual: @""] &&
	    [C(@"foo/.bar.baz").pathExtension isEqual: @"baz"] &&
	    [C(@"foo/bar.baz/").pathExtension isEqual: @"baz"])

# if defined(OF_WINDOWS)
	TEST(@"-[stringByDeletingLastPathComponent]",
	    [C(@"\\tmp").stringByDeletingLastPathComponent isEqual: @"\\"] &&
	    [C(@"/tmp/").stringByDeletingLastPathComponent isEqual: @"/"] &&
	    [C(@"c:\\").stringByDeletingLastPathComponent isEqual: @"c:\\"] &&
	    [C(@"c:/").stringByDeletingLastPathComponent isEqual: @"c:/"] &&
	    [C(@"c:\\tmp/foo/").stringByDeletingLastPathComponent
	    isEqual: @"c:\\tmp"] &&
	    [C(@"foo\\bar").stringByDeletingLastPathComponent
	    isEqual: @"foo"] &&
	    [C(@"\\").stringByDeletingLastPathComponent isEqual: @"\\"] &&
	    [C(@"foo").stringByDeletingLastPathComponent isEqual: @"."] &&
	    [C(@"\\\\foo\\bar").stringByDeletingLastPathComponent
	    isEqual: @"\\\\foo"] &&
	    [C(@"\\\\foo").stringByDeletingLastPathComponent
	    isEqual: @"\\\\"] &&
	    [C(@"\\\\").stringByDeletingLastPathComponent isEqual: @"\\\\"])
# elif defined(OF_MSDOS)
	TEST(@"-[stringByDeletingLastPathComponent]",
	    [C(@"\\tmp").stringByDeletingLastPathComponent isEqual: @"\\"] &&
	    [C(@"/tmp/").stringByDeletingLastPathComponent isEqual: @"/"] &&
	    [C(@"c:\\").stringByDeletingLastPathComponent isEqual: @"c:\\"] &&
	    [C(@"c:/").stringByDeletingLastPathComponent isEqual: @"c:/"] &&
	    [C(@"c:\\tmp/foo/").stringByDeletingLastPathComponent
	    isEqual: @"c:\\tmp"] &&
	    [C(@"foo\\bar").stringByDeletingLastPathComponent
	    isEqual: @"foo"] &&
	    [C(@"\\").stringByDeletingLastPathComponent isEqual: @"\\"] &&
	    [C(@"foo").stringByDeletingLastPathComponent isEqual: @"."])
# elif defined(OF_AMIGAOS)
	TEST(@"-[stringByDeletingLastPathComponent]",
	    [C(@"dh0:").stringByDeletingLastPathComponent isEqual: @"dh0:"] &&
	    [C(@"dh0:tmp").stringByDeletingLastPathComponent
	    isEqual: @"dh0:"] &&
	    [C(@"dh0:tmp/").stringByDeletingLastPathComponent
	    isEqual: @"dh0:"] &&
	    [C(@"dh0:/").stringByDeletingLastPathComponent isEqual: @"dh0:"] &&
	    [C(@"dh0:tmp/foo/").stringByDeletingLastPathComponent
	    isEqual: @"dh0:tmp"] &&
	    [C(@"foo/bar").stringByDeletingLastPathComponent isEqual: @"foo"] &&
	    [C(@"foo").stringByDeletingLastPathComponent isEqual: @""])
# elif defined(OF_NINTENDO_3DS) || defined(OF_WII) || \
    defined(OF_NINTENDO_SWITCH)
	TEST(@"-[stringByDeletingLastPathComponent]",
	    [C(@"/tmp/").stringByDeletingLastPathComponent isEqual: @""] &&
	    [C(@"sdmc:/tmp/foo/").stringByDeletingLastPathComponent
	    isEqual: @"sdmc:/tmp"] &&
	    [C(@"sdmc:/").stringByDeletingLastPathComponent
	    isEqual: @"sdmc:/"] &&
	    [C(@"foo/bar").stringByDeletingLastPathComponent isEqual: @"foo"] &&
	    [C(@"/").stringByDeletingLastPathComponent isEqual: @""] &&
	    [C(@"foo").stringByDeletingLastPathComponent isEqual: @"."])
# else
	TEST(@"-[stringByDeletingLastPathComponent]",
	    [C(@"/tmp").stringByDeletingLastPathComponent isEqual: @"/"] &&
	    [C(@"/tmp/").stringByDeletingLastPathComponent isEqual: @"/"] &&
	    [C(@"/tmp/foo/").stringByDeletingLastPathComponent
	    isEqual: @"/tmp"] &&
	    [C(@"foo/bar").stringByDeletingLastPathComponent isEqual: @"foo"] &&
	    [C(@"/").stringByDeletingLastPathComponent isEqual: @"/"] &&
	    [C(@"foo").stringByDeletingLastPathComponent isEqual: @"."])
# endif

# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	TEST(@"-[stringByDeletingPathExtension]",
	    [C(@"foo.bar").stringByDeletingPathExtension isEqual: @"foo"] &&
	    [C(@"foo..bar").stringByDeletingPathExtension isEqual: @"foo."] &&
	    [C(@"c:/foo.\\bar").stringByDeletingPathExtension
	    isEqual: @"c:/foo.\\bar"] &&
	    [C(@"c:\\foo./bar.baz").stringByDeletingPathExtension
	    isEqual: @"c:\\foo.\\bar"] &&
	    [C(@"foo.bar/").stringByDeletingPathExtension isEqual: @"foo"] &&
	    [C(@".foo").stringByDeletingPathExtension isEqual: @".foo"] &&
	    [C(@".foo.bar").stringByDeletingPathExtension isEqual: @".foo"])
# elif defined(OF_AMIGAOS)
	TEST(@"-[stringByDeletingPathExtension]",
	    [C(@"foo.bar").stringByDeletingPathExtension isEqual: @"foo"] &&
	    [C(@"foo..bar").stringByDeletingPathExtension isEqual: @"foo."] &&
	    [C(@"dh0:foo.bar").stringByDeletingPathExtension
	    isEqual: @"dh0:foo"] &&
	    [C(@"dh0:foo./bar").stringByDeletingPathExtension
	    isEqual: @"dh0:foo./bar"] &&
	    [C(@"dh0:foo./bar.baz").stringByDeletingPathExtension
	    isEqual: @"dh0:foo./bar"] &&
	    [C(@"foo.bar/").stringByDeletingPathExtension isEqual: @"foo"] &&
	    [C(@".foo").stringByDeletingPathExtension isEqual: @".foo"] &&
	    [C(@".foo\\bar").stringByDeletingPathExtension
	    isEqual: @".foo\\bar"] &&
	    [C(@".foo.bar").stringByDeletingPathExtension isEqual: @".foo"])
# elif defined(OF_NINTENDO_3DS) || defined(OF_WII) || \
    defined(OF_NINTENDO_SWITCH)
	TEST(@"-[stringByDeletingPathExtension]",
	    [C(@"foo.bar").stringByDeletingPathExtension isEqual: @"foo"] &&
	    [C(@"foo..bar").stringByDeletingPathExtension isEqual: @"foo."] &&
	    [C(@"sdmc:/foo./bar").stringByDeletingPathExtension
	    isEqual: @"sdmc:/foo./bar"] &&
	    [C(@"sdmc:/foo./bar.baz").stringByDeletingPathExtension
	    isEqual: @"sdmc:/foo./bar"] &&
	    [C(@"foo.bar/").stringByDeletingPathExtension isEqual: @"foo"] &&
	    [C(@".foo").stringByDeletingPathExtension isEqual: @".foo"] &&
	    [C(@".foo.bar").stringByDeletingPathExtension isEqual: @".foo"])
# else
	TEST(@"-[stringByDeletingPathExtension]",
	    [C(@"foo.bar").stringByDeletingPathExtension isEqual: @"foo"] &&
	    [C(@"foo..bar").stringByDeletingPathExtension isEqual: @"foo."] &&
	    [C(@"/foo./bar").stringByDeletingPathExtension
	    isEqual: @"/foo./bar"] &&
	    [C(@"/foo./bar.baz").stringByDeletingPathExtension
	    isEqual: @"/foo./bar"] &&
	    [C(@"foo.bar/").stringByDeletingPathExtension isEqual: @"foo"] &&
	    [C(@".foo").stringByDeletingPathExtension isEqual: @".foo"] &&
	    [C(@".foo\\bar").stringByDeletingPathExtension
	    isEqual: @".foo\\bar"] &&
	    [C(@".foo.bar").stringByDeletingPathExtension isEqual: @".foo"])
# endif

# ifdef OF_WINDOWS
	/* TODO: Add more tests */
	TEST(@"-[stringByStandardizingPath]",
	    [C(@"\\\\foo\\..\\bar\\qux").stringByStandardizingPath
	    isEqual: @"\\\\bar\\qux"] &&
	    [C(@"c:\\..\\asd").stringByStandardizingPath
	    isEqual: @"c:\\..\\asd"])
# endif
#endif

	TEST(@"-[longLongValue]",
	    C(@"1234").longLongValue == 1234 &&
	    C(@"\r\n+123  ").longLongValue == 123 &&
	    C(@"-500\t").longLongValue == -500 &&
	    [C(@"-0x10\t") longLongValueWithBase: 0] == -0x10 &&
	    C(@"\t\t\r\n").longLongValue == 0 &&
	    [C(@"123f") longLongValueWithBase: 16] == 0x123f &&
	    [C(@"-1234") longLongValueWithBase: 0] == -1234 &&
	    [C(@"\t\n0xABcd\r") longLongValueWithBase: 0] == 0xABCD &&
	    [C(@"1234567") longLongValueWithBase: 8] == 01234567 &&
	    [C(@"\r\n0123") longLongValueWithBase: 0] == 0123 &&
	    [C(@"765\t") longLongValueWithBase: 8] == 0765 &&
	    [C(@"\t\t\r\n") longLongValueWithBase: 8] == 0)

	TEST(@"-[unsignedLongLongValue]",
	    C(@"1234").unsignedLongLongValue == 1234 &&
	    C(@"\r\n+123  ").unsignedLongLongValue == 123 &&
	    C(@"\t\t\r\n").unsignedLongLongValue == 0 &&
	    [C(@"123f") unsignedLongLongValueWithBase: 16] == 0x123f &&
	    [C(@"1234") unsignedLongLongValueWithBase: 0] == 1234 &&
	    [C(@"\t\n0xABcd\r") unsignedLongLongValueWithBase: 0] == 0xABCD &&
	    [C(@"1234567") unsignedLongLongValueWithBase: 8] == 01234567 &&
	    [C(@"\r\n0123") unsignedLongLongValueWithBase: 0] == 0123 &&
	    [C(@"765\t") unsignedLongLongValueWithBase: 8] == 0765 &&
	    [C(@"\t\t\r\n") unsignedLongLongValueWithBase: 8] == 0)

	/*
	 * These test numbers can be generated without rounding if we have IEEE
	 * floating point numbers, thus we can use == on them.
	 */
	TEST(@"-[floatValue]",
	    C(@"\t-0.25 ").floatValue == -0.25 &&
	    C(@"\r\n\tINF\t\n").floatValue == INFINITY &&
	    C(@"\r -INFINITY\n").floatValue == -INFINITY &&
	    isnan(C(@"   NAN\t\t").floatValue) &&
	    isnan(C(@"   -NaN\t\t").floatValue))

#if !defined(OF_ANDROID) && !defined(OF_SOLARIS) && !defined(OF_HPUX) && \
    !defined(OF_DJGPP) && !defined(OF_AMIGAOS_M68K)
# define INPUT @"\t-0x1.FFFFFFFFFFFFFP-1020 "
# define EXPECTED -0x1.FFFFFFFFFFFFFP-1020
#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 AMD64.
 * AmigaOS 3 with libnix has weird rounding as well.
 */
#  define INPUT @"\t-0.125 "
#  define EXPECTED -0.125
# endif
#endif
	TEST(@"-[doubleValue]",
	    INPUT.doubleValue == EXPECTED &&
	    C(@"\r\n\tINF\t\n").doubleValue == INFINITY &&
	    C(@"\r -INFINITY\n").doubleValue == -INFINITY &&
	    isnan(C(@"   NAN\t\t").doubleValue))
#undef INPUT
#undef EXPECTED

	EXPECT_EXCEPTION(@"Detect invalid chars in -[longLongValue] #1",
	    OFInvalidFormatException, [C(@"abc") longLongValue])
	EXPECT_EXCEPTION(@"Detect invalid chars in -[longLongValue] #2",
	    OFInvalidFormatException, [C(@"0a") longLongValue])
	EXPECT_EXCEPTION(@"Detect invalid chars in -[longLongValue] #3",
	    OFInvalidFormatException, [C(@"0 1") longLongValue])
	EXPECT_EXCEPTION(@"Detect invalid chars in -[longLongValue] #4",
	    OFInvalidFormatException,
	    [C(@"0xABCDEFG") longLongValueWithBase: 0])
	EXPECT_EXCEPTION(@"Detect invalid chars in -[longLongValue] #5",
	    OFInvalidFormatException, [C(@"0x") longLongValueWithBase: 0])

	EXPECT_EXCEPTION(@"Detect invalid chars in -[floatValue] #1",
	    OFInvalidFormatException, [C(@"0.0a") floatValue])
	EXPECT_EXCEPTION(@"Detect invalid chars in -[floatValue] #2",
	    OFInvalidFormatException, [C(@"0 0") floatValue])
#ifdef HAVE_STRTOF_L
	/*
	 * Only do this if we have strtof_l, as the locale might allow the
	 * comma.
	 */
	EXPECT_EXCEPTION(@"Detect invalid chars in -[floatValue] #3",
	    OFInvalidFormatException, [C(@"0,0") floatValue])
#endif

	EXPECT_EXCEPTION(@"Detect invalid chars in -[doubleValue] #1",
	    OFInvalidFormatException, [C(@"0.0a") doubleValue])
	EXPECT_EXCEPTION(@"Detect invalid chars in -[doubleValue] #2",
	    OFInvalidFormatException, [C(@"0 0") doubleValue])
#ifdef HAVE_STRTOD_L
	/*
	 * Only do this if we have strtod_l, as the locale might allow the
	 * comma.
	 */
	EXPECT_EXCEPTION(@"Detect invalid chars in -[doubleValue] #3",
	    OFInvalidFormatException, [C(@"0,0") doubleValue])
#endif

	EXPECT_EXCEPTION(@"Detect out of range in -[longLongValue]",
	    OFOutOfRangeException,
	    [C(@"-12345678901234567890123456789012345678901234567890"
	       @"12345678901234567890123456789012345678901234567890")
	    longLongValueWithBase: 16])

	EXPECT_EXCEPTION(@"Detect out of range in -[unsignedLongLongValue]",
	    OFOutOfRangeException,
	    [C(@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
	       @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF")
	    unsignedLongLongValueWithBase: 16])

	TEST(@"-[characters]", (characters = C(@"fööbär🀺").characters) &&
	    !memcmp(characters, unicharString + 1, sizeof(unicharString) - 8))

#ifdef OF_BIG_ENDIAN
# define swappedByteOrder OFByteOrderLittleEndian
#else
# define swappedByteOrder OFByteOrderBigEndian
#endif
	TEST(@"-[UTF16String]", (UTF16Characters = C(@"fööbär🀺").UTF16String) &&
	    !memcmp(UTF16Characters, char16String + 1,
	    OFUTF16StringLength(char16String) * 2) &&
	    (UTF16Characters = [C(@"fööbär🀺")
	    UTF16StringWithByteOrder: swappedByteOrder]) &&
	    !memcmp(UTF16Characters, swappedChar16String + 1,
	    OFUTF16StringLength(swappedChar16String) * 2))

	TEST(@"-[UTF16StringLength]", C(@"fööbär🀺").UTF16StringLength == 8)

	TEST(@"-[UTF32String]", (characters = C(@"fööbär🀺").UTF32String) &&
	    !memcmp(characters, unicharString + 1,
	    OFUTF32StringLength(unicharString) * 4) &&
	    (characters = [C(@"fööbär🀺") UTF32StringWithByteOrder:
	    swappedByteOrder]) &&
	    !memcmp(characters, swappedUnicharString + 1,
	    OFUTF32StringLength(swappedUnicharString) * 4))
#undef swappedByteOrder

	TEST(@"-[stringByMD5Hashing]", [C(@"asdfoobar").stringByMD5Hashing
	    isEqual: @"184dce2ec49b5422c7cfd8728864db4c"])

	TEST(@"-[stringByRIPEMD160Hashing]",
	    [C(@"asdfoobar").stringByRIPEMD160Hashing
	    isEqual: @"021d773b0fac06eb6755ca6aa58a580c980f7f13"])

	TEST(@"-[stringBySHA1Hashing]", [C(@"asdfoobar").stringBySHA1Hashing
	    isEqual: @"f5f81ac0a8b5cbfdc4585ec1ad32e7b3a12b9b49"])

	TEST(@"-[stringBySHA224Hashing]", [C(@"asdfoobar").stringBySHA224Hashing
	    isEqual: @"5a06822dcbd5a874f67d062b80b9d8a9cb9b5b303960b9da9290c192"
	    ])

	TEST(@"-[stringBySHA256Hashing]", [C(@"asdfoobar").stringBySHA256Hashing
	    isEqual: @"28e65b1dcd7f6ce2ea6277b15f87b913628b5500bf7913a2bbf4cedc"
		     @"fa1215f6"])

	TEST(@"-[stringBySHA384Hashing]", [C(@"asdfoobar").stringBySHA384Hashing
	    isEqual: @"73286da882ffddca2f45e005cfa6b44f3fc65bfb26db1d087ded2f9c"
		     @"279e5addf8be854044bca0cece073fce28eec7d9"])

	TEST(@"-[stringBySHA512Hashing]", [C(@"asdfoobar").stringBySHA512Hashing
	    isEqual: @"0464c427da158b02161bb44a3090bbfc594611ef6a53603640454b56"
		     @"412a9247c3579a329e53a5dc74676b106755e3394f9454a2d4227324"
		     @"2615d32f80437d61"])

	characterSet =
	    [OFCharacterSet characterSetWithCharactersInString: @"abfo'_~$🍏"];
	TEST(@"-[stringByAddingPercentEncodingWithAllowedCharacters:]",
	    [[C(@"foo\"ba'_~$]🍏🍌")
	    stringByAddingPercentEncodingWithAllowedCharacters: characterSet]
	    isEqual: @"foo%22ba'_~$%5D🍏%F0%9F%8D%8C"])

	TEST(@"-[stringByRemovingPercentEncoding]",
	    [C(@"foo%20bar%22+%24%F0%9F%8D%8C").stringByRemovingPercentEncoding
	    isEqual: @"foo bar\"+$🍌"])

	TEST(@"-[insertString:atIndex:]",
	    (mutableString1 = [mutableStringClass
	    stringWithString: @"𝄞öööbä€"]) &&
	    R([mutableString1 insertString: @"äöü" atIndex: 3]) &&
	    [mutableString1 isEqual: @"𝄞ööäöüöbä€"])

	EXPECT_EXCEPTION(@"Detect invalid format in "
	    @"-[stringByRemovingPercentEncoding] #1",
	    OFInvalidFormatException,
	    [C(@"foo%xbar") stringByRemovingPercentEncoding])
	EXPECT_EXCEPTION(@"Detect invalid encoding in "
	    @"-[stringByRemovingPercentEncoding] #2",
	    OFInvalidEncodingException,
	    [C(@"foo%FFbar") stringByRemovingPercentEncoding])

	TEST(@"-[setCharacter:atIndex:]",
	    (mutableString1 = [mutableStringClass
	    stringWithString: @"abäde"]) &&
	    R([mutableString1 setCharacter: 0xF6 atIndex: 2]) &&
	    [mutableString1 isEqual: @"aböde"] &&
	    R([mutableString1 setCharacter: 'c' atIndex: 2]) &&
	    [mutableString1 isEqual: @"abcde"] &&
	    R([mutableString1 setCharacter: 0x20AC atIndex: 3]) &&
	    [mutableString1 isEqual: @"abc€e"] &&
	    R([mutableString1 setCharacter: 'x' atIndex: 1]) &&
	    [mutableString1 isEqual: @"axc€e"])

	TEST(@"-[deleteCharactersInRange:]",
	    (mutableString1 = [mutableStringClass
	    stringWithString: @"𝄞öööbä€"]) &&
	    R([mutableString1 deleteCharactersInRange: OFMakeRange(1, 3)]) &&
	    [mutableString1 isEqual: @"𝄞bä€"] &&
	    R([mutableString1 deleteCharactersInRange: OFMakeRange(0, 4)]) &&
	    [mutableString1 isEqual: @""])

	TEST(@"-[replaceCharactersInRange:withString:]",
	    (mutableString1 = [mutableStringClass
	    stringWithString: @"𝄞öööbä€"]) &&
	    R([mutableString1 replaceCharactersInRange: OFMakeRange(1, 3)
					    withString: @"äöüß"]) &&
	    [mutableString1 isEqual: @"𝄞äöüßbä€"] &&
	    R([mutableString1 replaceCharactersInRange: OFMakeRange(4, 2)
					    withString: @"b"]) &&
	    [mutableString1 isEqual: @"𝄞äöübä€"] &&
	    R([mutableString1 replaceCharactersInRange: OFMakeRange(0, 7)
					    withString: @""]) &&
	    [mutableString1 isEqual: @""])

	EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #1",
	    OFOutOfRangeException,
	    {
		mutableString1 = [mutableStringClass stringWithString: @"𝄞öö"];
		[mutableString1 deleteCharactersInRange: OFMakeRange(2, 2)];
	    })

	EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #2",
	    OFOutOfRangeException,
	    [mutableString1 deleteCharactersInRange: OFMakeRange(4, 0)])

	EXPECT_EXCEPTION(@"Detect OoR in "
	    @"-[replaceCharactersInRange:withString:] #1",
	    OFOutOfRangeException,
	    [mutableString1 replaceCharactersInRange: OFMakeRange(2, 2)
					  withString: @""])

	EXPECT_EXCEPTION(@"Detect OoR in "
	    @"-[replaceCharactersInRange:withString:] #2",
	    OFOutOfRangeException,
	    [mutableString1 replaceCharactersInRange: OFMakeRange(4, 0)
					  withString: @""])

	TEST(@"-[replaceOccurrencesOfString:withString:]",
	    (mutableString1 = [mutableStringClass stringWithString:
	    @"asd fo asd fofo asd"]) &&
	    R([mutableString1 replaceOccurrencesOfString: @"fo"
					      withString: @"foo"]) &&
	    [mutableString1 isEqual: @"asd foo asd foofoo asd"] &&
	    (mutableString1 = [mutableStringClass stringWithString: @"XX"]) &&
	    R([mutableString1 replaceOccurrencesOfString: @"X"
					      withString: @"XX"]) &&
	    [mutableString1 isEqual: @"XXXX"])

	TEST(@"-[replaceOccurrencesOfString:withString:options:range:]",
	    (mutableString1 = [mutableStringClass stringWithString:
	    @"foofoobarfoobarfoo"]) && R([mutableString1
	    replaceOccurrencesOfString: @"oo"
			    withString: @"óò"
			       options: 0
				 range: OFMakeRange(2, 15)]) &&
	    [mutableString1 isEqual: @"foofóòbarfóòbarfoo"])

	TEST(@"-[deleteLeadingWhitespaces]",
	    (mutableString1 = [mutableStringClass
	    stringWithString: whitespace[0]]) &&
	    R([mutableString1 deleteLeadingWhitespaces]) &&
	    [mutableString1 isEqual: @"asd  \t \t\t\r\n"] &&
	    (mutableString1 = [mutableStringClass
	    stringWithString: whitespace[1]]) &&
	    R([mutableString1 deleteLeadingWhitespaces]) &&
	    [mutableString1 isEqual: @""])

	TEST(@"-[deleteTrailingWhitespaces]",
	    (mutableString1 = [mutableStringClass
	    stringWithString: whitespace[0]]) &&
	    R([mutableString1 deleteTrailingWhitespaces]) &&
	    [mutableString1 isEqual: @" \r \t\n\t \tasd"] &&
	    (mutableString1 = [mutableStringClass
	    stringWithString: whitespace[1]]) &&
	    R([mutableString1 deleteTrailingWhitespaces]) &&
	    [mutableString1 isEqual: @""])

	TEST(@"-[deleteEnclosingWhitespaces]",
	    (mutableString1 = [mutableStringClass
	    stringWithString: whitespace[0]]) &&
	    R([mutableString1 deleteEnclosingWhitespaces]) &&
	    [mutableString1 isEqual: @"asd"] &&
	    (mutableString1 = [mutableStringClass
	    stringWithString: whitespace[1]]) &&
	    R([mutableString1 deleteEnclosingWhitespaces]) &&
	    [mutableString1 isEqual: @""])

	TEST(@"-[stringByXMLEscaping]",
	    (string = C(@"<hello> &world'\"!&").stringByXMLEscaping) &&
	    [string isEqual: @"&lt;hello&gt; &amp;world&apos;&quot;!&amp;"])

	TEST(@"-[stringByXMLUnescaping]",
	    [string.stringByXMLUnescaping isEqual: @"<hello> &world'\"!&"] &&
	    [C(@"&#x79;").stringByXMLUnescaping isEqual: @"y"] &&
	    [C(@"&#xe4;").stringByXMLUnescaping isEqual: @"ä"] &&
	    [C(@"&#8364;").stringByXMLUnescaping isEqual: @"€"] &&
	    [C(@"&#x1D11E;").stringByXMLUnescaping isEqual: @"𝄞"])

	EXPECT_EXCEPTION(@"Detect unknown entities in -[stringByXMLUnescaping]",
	    OFUnknownXMLEntityException, [C(@"&foo;") stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#1", OFInvalidFormatException,
	    [C(@"x&amp") stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#2", OFInvalidFormatException, [C(@"&#;") stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#3", OFInvalidFormatException, [C(@"&#x;") stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#4", OFInvalidFormatException, [C(@"&#g;") stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#5", OFInvalidFormatException,
	    [C(@"&#xg;") stringByXMLUnescaping])

	TEST(@"-[stringByXMLUnescapingWithDelegate:]",
	    (entityHandler = [[[EntityHandler alloc] init] autorelease]) &&
	    [[C(@"x&foo;y") stringByXMLUnescapingWithDelegate: entityHandler]
	    isEqual: @"xbary"])

#ifdef OF_HAVE_BLOCKS
	TEST(@"-[stringByXMLUnescapingWithBlock:]",
	    [[C(@"x&foo;y") stringByXMLUnescapingWithBlock:
		^ OFString *(OFString *str, OFString *entity) {
		    if ([entity isEqual: @"foo"])
			    return @"bar";

		    return nil;
	    }] isEqual: @"xbary"])

	j = 0;
	ok = true;
	[C(@"foo\nbar\nbaz") enumerateLinesUsingBlock:
	    ^ (OFString *line, bool *stop) {
		switch (j) {
		case 0:
			if (![line isEqual: @"foo"])
				ok = false;
			break;
		case 1:
			if (![line isEqual: @"bar"])
				ok = false;
			break;
		case 2:
			if (![line isEqual: @"baz"])
				ok = false;
			break;
		default:
			ok = false;
		}

		j++;
	}];
	TEST(@"-[enumerateLinesUsingBlock:]", ok)
#endif

#undef C

	objc_autoreleasePoolPop(pool);
}

- (void)stringTests
{
	module = @"OFString";
	[self stringTestsWithClass: [SimpleString class]
		      mutableClass: [SimpleMutableString class]];

	module = @"OFString_UTF8";
	[self stringTestsWithClass: [OFUTF8String class]
		      mutableClass: [OFMutableUTF8String class]];
}
@end







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<









<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

1645
1646
1647
1648
1649
1650
1651

















1652
1653
1654
1655
1656
1657
1658
1659
1660



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































1661

- (size_t)length
{
	return _string.length;
}
@end


















@implementation EntityHandler
-	  (OFString *)string: (OFString *)string
  containsUnknownEntityNamed: (OFString *)entity
{
	if ([entity isEqual: @"foo"])
		return @"bar";

	return nil;
}



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































@end

Added new_tests/OFUTF8StringTests.m version [29756ee219].





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * 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.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFStringTests.h"

#import "OFUTF8String.h"

@interface OFUTF8StringTests: OFStringTests
@end

@implementation OFUTF8StringTests
- (Class)arrayClass
{
	return [OFUTF8String class];
}
@end

Modified src/OFString.m from [855db5cb26] to [fd5aa1a3b0].

2337
2338
2339
2340
2341
2342
2343
2344

2345
2346
2347
2348


2349
2350
2351
2352
2353
2354
2355
	if ([stripped caseInsensitiveCompare: @"-NAN"] == OFOrderedSame)
		return -NAN;

#if defined(HAVE_STRTOF_L) || defined(HAVE_USELOCALE)
	const char *UTF8String = self.UTF8String;
#else
	/*
	 * If we have no strtof_l, we have no other choice but to replace "."

	 * with the locale's decimal point.
	 */
	OFString *decimalSeparator = [OFLocale decimalSeparator];
	const char *UTF8String = [self


	    stringByReplacingOccurrencesOfString: @"."
				      withString: decimalSeparator].UTF8String;
#endif
	char *endPtr = NULL;
	float value;

	errno = 0;







|
>
|


|
>
>







2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
	if ([stripped caseInsensitiveCompare: @"-NAN"] == OFOrderedSame)
		return -NAN;

#if defined(HAVE_STRTOF_L) || defined(HAVE_USELOCALE)
	const char *UTF8String = self.UTF8String;
#else
	/*
	 * If we have no strtof_l, we have no other choice than to replace the
	 * locale's decimal point with something that will be rejected and
	 * replacing "." with the locale's decimal point.
	 */
	OFString *decimalSeparator = [OFLocale decimalSeparator];
	const char *UTF8String = [[self
	    stringByReplacingOccurrencesOfString: decimalSeparator
				      withString: @"!"]
	    stringByReplacingOccurrencesOfString: @"."
				      withString: decimalSeparator].UTF8String;
#endif
	char *endPtr = NULL;
	float value;

	errno = 0;
2394
2395
2396
2397
2398
2399
2400
2401

2402
2403
2404
2405


2406
2407
2408
2409
2410
2411
2412
	if ([stripped caseInsensitiveCompare: @"-NAN"] == OFOrderedSame)
		return -NAN;

#if defined(HAVE_STRTOD_L) || defined(HAVE_USELOCALE)
	const char *UTF8String = self.UTF8String;
#else
	/*
	 * If we have no strtod_l, we have no other choice but to replace "."

	 * with the locale's decimal point.
	 */
	OFString *decimalSeparator = [OFLocale decimalSeparator];
	const char *UTF8String = [self


	    stringByReplacingOccurrencesOfString: @"."
				      withString: decimalSeparator].UTF8String;
#endif
	char *endPtr = NULL;
	double value;

	errno = 0;







|
>
|


|
>
>







2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
	if ([stripped caseInsensitiveCompare: @"-NAN"] == OFOrderedSame)
		return -NAN;

#if defined(HAVE_STRTOD_L) || defined(HAVE_USELOCALE)
	const char *UTF8String = self.UTF8String;
#else
	/*
	 * If we have no strtod_l, we have no other choice than to replace the
	 * locale's decimal point with something that will be rejected and
	 * replacing "." with the locale's decimal point.
	 */
	OFString *decimalSeparator = [OFLocale decimalSeparator];
	const char *UTF8String = [[self
	    stringByReplacingOccurrencesOfString: decimalSeparator
				      withString: @"!"]
	    stringByReplacingOccurrencesOfString: @"."
				      withString: decimalSeparator].UTF8String;
#endif
	char *endPtr = NULL;
	double value;

	errno = 0;

Modified tests/Makefile from [33d6256e99] to [532ecb85cc].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
SRCS = OFDataTests.m			\
       OFDictionaryTests.m		\
       OFListTests.m			\
       OFMemoryStreamTests.m		\
       OFNotificationCenterTests.m	\
       OFStreamTests.m			\
       OFStringTests.m			\
       OFValueTests.m			\
       OFXMLElementBuilderTests.m	\
       OFXMLNodeTests.m			\
       OFXMLParserTests.m		\
       RuntimeTests.m			\
       ${RUNTIME_ARC_TESTS_M}		\
       TestsAppDelegate.m		\







<







15
16
17
18
19
20
21

22
23
24
25
26
27
28
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
SRCS = OFDataTests.m			\
       OFDictionaryTests.m		\
       OFListTests.m			\
       OFMemoryStreamTests.m		\
       OFNotificationCenterTests.m	\
       OFStreamTests.m			\

       OFValueTests.m			\
       OFXMLElementBuilderTests.m	\
       OFXMLNodeTests.m			\
       OFXMLParserTests.m		\
       RuntimeTests.m			\
       ${RUNTIME_ARC_TESTS_M}		\
       TestsAppDelegate.m		\

Modified tests/TestsAppDelegate.h from [d0f720ed69] to [6f8ca2ade5].

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
- (void)runtimeARCTests;
@end

@interface TestsAppDelegate (OFStreamTests)
- (void)streamTests;
@end

@interface TestsAppDelegate (OFStringTests)
- (void)stringTests;
@end

@interface TestsAppDelegate (OFValueTests)
- (void)valueTests;
@end

@interface TestsAppDelegate (OFWindowsRegistryKeyTests)
- (void)windowsRegistryKeyTests;
@end







<
<
<
<







103
104
105
106
107
108
109




110
111
112
113
114
115
116
- (void)runtimeARCTests;
@end

@interface TestsAppDelegate (OFStreamTests)
- (void)streamTests;
@end





@interface TestsAppDelegate (OFValueTests)
- (void)valueTests;
@end

@interface TestsAppDelegate (OFWindowsRegistryKeyTests)
- (void)windowsRegistryKeyTests;
@end

Modified tests/TestsAppDelegate.m from [01275bfcd5] to [2f2d348e00].

370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
	    changeCurrentDirectoryPath: @"/apps/objfw-tests"];
#endif

	[self runtimeTests];
#ifdef COMPILER_SUPPORTS_ARC
	[self runtimeARCTests];
#endif
	[self stringTests];
	[self dataTests];
	[self dictionaryTests];
	[self listTests];
	[self valueTests];
	[self streamTests];
	[self memoryStreamTests];
	[self notificationCenterTests];







<







370
371
372
373
374
375
376

377
378
379
380
381
382
383
	    changeCurrentDirectoryPath: @"/apps/objfw-tests"];
#endif

	[self runtimeTests];
#ifdef COMPILER_SUPPORTS_ARC
	[self runtimeARCTests];
#endif

	[self dataTests];
	[self dictionaryTests];
	[self listTests];
	[self valueTests];
	[self streamTests];
	[self memoryStreamTests];
	[self notificationCenterTests];

Deleted tests/testfile.txt version [11bc6d44ee].

1
test
<