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
|
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
|
-
+
-
+
|
}
return self;
}
- (instancetype)initWithUTF16String: (const of_char16_t *)UTF16String
length: (size_t)length
byteOrder: (of_byte_order_t)byteOrder
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 of_char32_t *)UTF32String
length: (size_t)length
byteOrder: (of_byte_order_t)byteOrder
byteOrder: (OFByteOrder)byteOrder
{
self = [super init];
@try {
_string = [[OFMutableString alloc]
initWithUTF32String: UTF32String
length: length
|
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
|
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
|
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
|
s[0] = [mutableStringClass stringWithString: @"täs€"];
s[1] = [mutableStringClass string];
s[2] = [[s[0] copy] autorelease];
TEST(@"-[isEqual:]", [s[0] isEqual: s[2]] &&
![s[0] isEqual: [[[OFObject alloc] init] autorelease]])
TEST(@"-[compare:]", [s[0] compare: s[2]] == OF_ORDERED_SAME &&
[s[0] compare: @""] != OF_ORDERED_SAME &&
[C(@"") compare: @"a"] == OF_ORDERED_ASCENDING &&
[C(@"a") compare: @"b"] == OF_ORDERED_ASCENDING &&
[C(@"cd") compare: @"bc"] == OF_ORDERED_DESCENDING &&
[C(@"ä") compare: @"ö"] == OF_ORDERED_ASCENDING &&
[C(@"€") compare: @"ß"] == OF_ORDERED_DESCENDING &&
[C(@"aa") compare: @"z"] == OF_ORDERED_ASCENDING)
TEST(@"-[compare:]", [s[0] compare: s[2]] == OFOrderedSame &&
[s[0] 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"] == OF_ORDERED_SAME &&
[C(@"Ä") caseInsensitiveCompare: @"ä"] == OF_ORDERED_SAME &&
[C(@"я") caseInsensitiveCompare: @"Я"] == OF_ORDERED_SAME &&
[C(@"€") caseInsensitiveCompare: @"ß"] == OF_ORDERED_DESCENDING &&
[C(@"ß") caseInsensitiveCompare: @"→"] == OF_ORDERED_ASCENDING &&
[C(@"AA") caseInsensitiveCompare: @"z"] == OF_ORDERED_ASCENDING &&
[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"] == OF_ORDERED_SAME &&
[C(@"AA") caseInsensitiveCompare: @"z"] == OF_ORDERED_ASCENDING &&
[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",
s[0].hash == s[2].hash)
|
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
|
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
|
-
+
-
+
|
@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF")
unsignedLongLongValueWithBase: 16])
TEST(@"-[characters]", (ua = C(@"fööbär🀺").characters) &&
!memcmp(ua, ucstr + 1, sizeof(ucstr) - 8))
#ifdef OF_BIG_ENDIAN
# define SWAPPED_BYTE_ORDER OF_BYTE_ORDER_LITTLE_ENDIAN
# define SWAPPED_BYTE_ORDER OFByteOrderLittleEndian
#else
# define SWAPPED_BYTE_ORDER OF_BYTE_ORDER_BIG_ENDIAN
# define SWAPPED_BYTE_ORDER OFByteOrderBigEndian
#endif
TEST(@"-[UTF16String]", (u16a = C(@"fööbär🀺").UTF16String) &&
!memcmp(u16a, utf16str + 1, of_string_utf16_length(utf16str) * 2) &&
(u16a = [C(@"fööbär🀺")
UTF16StringWithByteOrder: SWAPPED_BYTE_ORDER]) &&
!memcmp(u16a, sutf16str + 1, of_string_utf16_length(sutf16str) * 2))
|