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
|
TEST(@"-[indexOfLastOccurrenceOfString:]",
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆΓΆ"] == 1 &&
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆ"] == 2 &&
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"π"] == 0 &&
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"x"] == OF_INVALID_INDEX)
TEST(@"-[substringFromIndexToIndex:]",
[[@"πΓΆΓΆ" substringFromIndex: 1
toIndex: 2] isEqual: @"ΓΆ"] &&
[[@"πΓΆΓΆ" substringFromIndex: 3
toIndex: 3] isEqual: @""])
EXPECT_EXCEPTION(@"Detect out of range in "
@"-[substringFromIndex:toIndex:] #1", OFOutOfRangeException,
[@"πΓΆΓΆ" substringFromIndex: 2
toIndex: 4])
EXPECT_EXCEPTION(@"Detect out of range in "
@"-[substringFromIndex:toIndex:] #2", OFOutOfRangeException,
[@"πΓΆΓΆ" substringFromIndex: 4
toIndex: 4])
EXPECT_EXCEPTION(@"Detect start > end in "
@"-[substringFromIndex:toIndex:]", OFInvalidArgumentException,
[@"πΓΆΓΆ" substringFromIndex: 2
toIndex: 0])
TEST(@"-[stringByAppendingString:]",
[[@"foo" stringByAppendingString: @"bar"] isEqual: @"foobar"])
TEST(@"-[stringByPrependingString:]",
[[@"foo" stringByPrependingString: @"bar"] isEqual: @"barfoo"])
|
|
|
<
|
<
|
<
|
<
|
<
|
<
<
<
<
<
<
|
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
TEST(@"-[indexOfLastOccurrenceOfString:]",
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆΓΆ"] == 1 &&
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆ"] == 2 &&
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"π"] == 0 &&
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"x"] == OF_INVALID_INDEX)
TEST(@"-[substringWithRange:]",
[[@"πΓΆΓΆ" substringWithRange: of_range(1, 1)] isEqual: @"ΓΆ"] &&
[[@"πΓΆΓΆ" substringWithRange: of_range(3, 0)] isEqual: @""])
EXPECT_EXCEPTION(@"Detect out of range in -[substringWithRange:] #1",
OFOutOfRangeException, [@"πΓΆΓΆ" substringWithRange: of_range(2, 2)])
EXPECT_EXCEPTION(@"Detect out of range in -[substringWithRange:] #2",
OFOutOfRangeException, [@"πΓΆΓΆ" substringWithRange: of_range(4, 0)])
TEST(@"-[stringByAppendingString:]",
[[@"foo" stringByAppendingString: @"bar"] isEqual: @"foobar"])
TEST(@"-[stringByPrependingString:]",
[[@"foo" stringByPrependingString: @"bar"] isEqual: @"barfoo"])
|
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
|
EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] "
@"#1", OFInvalidEncodingException, [@"foo%bar" stringByURLDecoding])
EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] "
@"#2", OFInvalidEncodingException,
[@"foo%FFbar" stringByURLDecoding])
TEST(@"-[deleteCharactersFromIndex:toIndex:]",
(s[0] = [OFMutableString stringWithString: @"πΓΆΓΆΓΆbΓ€β¬"]) &&
R([s[0] deleteCharactersFromIndex: 1
toIndex: 4]) &&
[s[0] isEqual: @"πbΓ€β¬"] &&
R([s[0] deleteCharactersFromIndex: 0
toIndex: 4]) &&
[s[0] isEqual: @""])
TEST(@"-[replaceCharactersFromIndex:toIndex:withString:]",
(s[0] = [OFMutableString stringWithString: @"πΓΆΓΆΓΆbΓ€β¬"]) &&
R([s[0] replaceCharactersFromIndex: 1
toIndex: 4
withString: @"Àâü"]) &&
[s[0] isEqual: @"πÀâübΓ€β¬"] &&
R([s[0] replaceCharactersFromIndex: 0
toIndex: 7
withString: @""]) &&
[s[0] isEqual: @""])
EXPECT_EXCEPTION(@"Detect OoR in "
@"-[deleteCharactersFromIndex:toIndex:] #1", OFOutOfRangeException,
{
s[0] = [OFMutableString stringWithString: @"πΓΆΓΆ"];
[s[0] deleteCharactersFromIndex: 2
toIndex: 4];
})
EXPECT_EXCEPTION(@"Detect OoR in "
@"-[deleteCharactersFromIndex:toIndex:] #2", OFOutOfRangeException,
[s[0] deleteCharactersFromIndex: 4
toIndex: 4])
EXPECT_EXCEPTION(@"Detect s > e in "
@"-[deleteCharactersFromIndex:toIndex:]",
OFInvalidArgumentException,
[s[0] deleteCharactersFromIndex: 2
toIndex: 0])
EXPECT_EXCEPTION(@"OoR "
@"-[replaceCharactersFromIndex:toIndex:withString:] #1",
OFOutOfRangeException, [s[0] replaceCharactersFromIndex: 2
toIndex: 4
withString: @""])
EXPECT_EXCEPTION(@"OoR "
@"-[replaceCharactersFromIndex:toIndex:withString:] #2",
OFOutOfRangeException,
[s[0] replaceCharactersFromIndex: 4
toIndex: 4
withString: @""])
EXPECT_EXCEPTION(@"s>e in "
@"-[replaceCharactersFromIndex:toIndex:withString:]",
OFInvalidArgumentException, [s[0] replaceCharactersFromIndex: 2
toIndex: 0
withString: @""])
TEST(@"-[replaceOccurrencesOfString:withString:]",
(s[0] = [OFMutableString stringWithString:
@"asd fo asd fofo asd"]) &&
R([s[0] replaceOccurrencesOfString: @"fo"
withString: @"foo"]) &&
[s[0] isEqual: @"asd foo asd foofoo asd"] &&
|
|
|
<
|
<
|
|
<
|
|
<
|
|
|
|
<
|
|
|
<
|
<
|
<
<
<
<
<
|
<
|
|
<
|
<
|
<
<
<
<
<
<
|
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
|
EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] "
@"#1", OFInvalidEncodingException, [@"foo%bar" stringByURLDecoding])
EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] "
@"#2", OFInvalidEncodingException,
[@"foo%FFbar" stringByURLDecoding])
TEST(@"-[deleteCharactersInRange:]",
(s[0] = [OFMutableString stringWithString: @"πΓΆΓΆΓΆbΓ€β¬"]) &&
R([s[0] deleteCharactersInRange: of_range(1, 3)]) &&
[s[0] isEqual: @"πbΓ€β¬"] &&
R([s[0] deleteCharactersInRange: of_range(0, 4)]) &&
[s[0] isEqual: @""])
TEST(@"-[replaceCharactersInRange:withString:]",
(s[0] = [OFMutableString stringWithString: @"πΓΆΓΆΓΆbΓ€β¬"]) &&
R([s[0] replaceCharactersInRange: of_range(1, 3)
withString: @"Àâü"]) &&
[s[0] isEqual: @"πÀâübΓ€β¬"] &&
R([s[0] replaceCharactersInRange: of_range(0, 7)
withString: @""]) &&
[s[0] isEqual: @""])
EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #1",
OFOutOfRangeException,
{
s[0] = [OFMutableString stringWithString: @"πΓΆΓΆ"];
[s[0] deleteCharactersInRange: of_range(2, 2)];
})
EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #2",
OFOutOfRangeException,
[s[0] deleteCharactersInRange: of_range(4, 0)])
EXPECT_EXCEPTION(@"Detect OoR in -[replaceCharactersInRange:withString:] #1",
OFOutOfRangeException,
[s[0] replaceCharactersInRange: of_range(2, 2)
withString: @""])
EXPECT_EXCEPTION(@"Detect OoR in -[replaceCharactersInRange:withString:] #2",
OFOutOfRangeException,
[s[0] replaceCharactersInRange: of_range(4, 0)
withString: @""])
TEST(@"-[replaceOccurrencesOfString:withString:]",
(s[0] = [OFMutableString stringWithString:
@"asd fo asd fofo asd"]) &&
R([s[0] replaceOccurrencesOfString: @"fo"
withString: @"foo"]) &&
[s[0] isEqual: @"asd foo asd foofoo asd"] &&
|