︙ | | | ︙ | |
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
|
[mutableString1 characterAtIndex: 1] == 0xE4 &&
[mutableString1 characterAtIndex: 3] == 0x20AC &&
[mutableString1 characterAtIndex: 5] == 0x1D11E)
EXPECT_EXCEPTION(@"Detect out of range in -[characterAtIndex:]",
OFOutOfRangeException, [mutableString1 characterAtIndex: 7])
TEST(@"-[reverse]",
R([mutableString1 reverse]) && [mutableString1 isEqual: @"3𝄞1€sät"])
mutableString2 = [mutableStringClass stringWithString: @"abc"];
#ifdef OF_HAVE_UNICODE_TABLES
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"])
#else
TEST(@"-[uppercase]", R([mutableString1 uppercase]) &&
[mutableString1 isEqual: @"3𝄞1€SäT"] &&
R([mutableString2 uppercase]) && [mutableString2 isEqual: @"ABC"])
|
<
<
<
|
|
|
|
|
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
|
[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"])
|
︙ | | | ︙ | |
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
#ifdef OF_HAVE_FILES
TEST(@"+[stringWithContentsOfFile:encoding]", (string = [stringClass
stringWithContentsOfFile: @"testfile.txt"
encoding: OFStringEncodingISO8859_1]) &&
[string isEqual: @"testäöü"])
TEST(@"+[stringWithContentsOfURL:encoding]", (string = [stringClass
stringWithContentsOfURL: [OFURL fileURLWithPath: @"testfile.txt"]
encoding: OFStringEncodingISO8859_1]) &&
[string isEqual: @"testäöü"])
#endif
TEST(@"-[appendUTFString:length:]",
R([mutableString1 appendUTF8String: "\xEF\xBB\xBF" "barqux"
length: 6]) &&
|
|
|
|
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
#ifdef OF_HAVE_FILES
TEST(@"+[stringWithContentsOfFile:encoding]", (string = [stringClass
stringWithContentsOfFile: @"testfile.txt"
encoding: OFStringEncodingISO8859_1]) &&
[string isEqual: @"testäöü"])
TEST(@"+[stringWithContentsOfURI:encoding]", (string = [stringClass
stringWithContentsOfURI: [OFURI fileURIWithPath: @"testfile.txt"]
encoding: OFStringEncodingISO8859_1]) &&
[string isEqual: @"testäöü"])
#endif
TEST(@"-[appendUTFString:length:]",
R([mutableString1 appendUTF8String: "\xEF\xBB\xBF" "barqux"
length: 6]) &&
|
︙ | | | ︙ | |
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
|
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: OFRangeMake(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: OFRangeMake(4, 4)] == 6 &&
[C(@"abcđabcđëf")
indexOfCharacterFromSet: characterSet
options: 0
range: OFRangeMake(8, 2)] == OFNotFound)
EXPECT_EXCEPTION(
@"Detect out of range in -[indexOfCharacterFromSet:options:range:]",
OFOutOfRangeException,
[C(@"𝄞öö") indexOfCharacterFromSet: characterSet
options: 0
range: OFRangeMake(3, 1)])
TEST(@"-[substringWithRange:]",
[[C(@"𝄞öö") substringWithRange: OFRangeMake(1, 1)] isEqual: @"ö"] &&
[[C(@"𝄞öö") substringWithRange: OFRangeMake(3, 0)] isEqual: @""])
EXPECT_EXCEPTION(@"Detect out of range in -[substringWithRange:] #1",
OFOutOfRangeException,
[C(@"𝄞öö") substringWithRange: OFRangeMake(2, 2)])
EXPECT_EXCEPTION(@"Detect out of range in -[substringWithRange:] #2",
OFOutOfRangeException,
[C(@"𝄞öö") substringWithRange: OFRangeMake(4, 0)])
TEST(@"-[stringByAppendingString:]",
[[C(@"foo") stringByAppendingString: @"bar"] isEqual: @"foobar"])
TEST(@"-[stringByPrependingString:]",
[[C(@"foo") stringByPrependingString: @"bar"] isEqual: @"barfoo"])
#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)
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)
|
|
|
|
|
|
|
|
|
<
<
<
|
>
|
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
|
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)
|
︙ | | | ︙ | |
590
591
592
593
594
595
596
597
598
599
600
601
602
603
|
string = [stringClass stringWithString: mutableString2];
[mutableString2 appendString: @"baz"];
TEST(@"-[stringByAppendingPathComponent:]",
[[mutableString1 stringByAppendingPathComponent: @"baz"]
isEqual: mutableString2] &&
[[string stringByAppendingPathComponent: @"baz"]
isEqual: mutableString2])
#endif
TEST(@"-[hasPrefix:]", [C(@"foobar") hasPrefix: @"foo"] &&
![C(@"foobar") hasPrefix: @"foobar0"])
TEST(@"-[hasSuffix:]", [C(@"foobar") hasSuffix: @"bar"] &&
![C(@"foobar") hasSuffix: @"foobar0"])
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
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"])
|
︙ | | | ︙ | |
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
|
[[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)
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:
|
|
>
|
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
|
[[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:
|
︙ | | | ︙ | |
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
|
[[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)
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 &&
|
|
>
|
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
|
[[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 &&
|
︙ | | | ︙ | |
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
|
[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)
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"] &&
|
|
>
|
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
|
[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"] &&
|
︙ | | | ︙ | |
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
|
[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)
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"] &&
|
|
>
|
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
|
[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"] &&
|
︙ | | | ︙ | |
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
|
[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)
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"] &&
|
|
>
|
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
|
[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"] &&
|
︙ | | | ︙ | |
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
|
TEST(@"-[stringBySHA512Hashing]", [C(@"asdfoobar").stringBySHA512Hashing
isEqual: @"0464c427da158b02161bb44a3090bbfc594611ef6a53603640454b56"
@"412a9247c3579a329e53a5dc74676b106755e3394f9454a2d4227324"
@"2615d32f80437d61"])
characterSet =
[OFCharacterSet characterSetWithCharactersInString: @"abfo'_~$🍏"];
TEST(@"-[stringByURLEncodingWithAllowedCharacters:]",
[[C(@"foo\"ba'_~$]🍏🍌") stringByURLEncodingWithAllowedCharacters:
characterSet] isEqual: @"foo%22ba'_~$%5D🍏%F0%9F%8D%8C"])
TEST(@"-[stringByURLDecoding]",
[C(@"foo%20bar%22+%24%F0%9F%8D%8C").stringByURLDecoding
isEqual: @"foo bar\"+$🍌"])
TEST(@"-[insertString:atIndex:]",
(mutableString1 = [mutableStringClass
stringWithString: @"𝄞öööbä€"]) &&
R([mutableString1 insertString: @"äöü" atIndex: 3]) &&
[mutableString1 isEqual: @"𝄞ööäöüöbä€"])
EXPECT_EXCEPTION(@"Detect invalid format in -[stringByURLDecoding] "
@"#1", OFInvalidFormatException,
[C(@"foo%xbar") stringByURLDecoding])
EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] "
@"#2", OFInvalidEncodingException,
[C(@"foo%FFbar") stringByURLDecoding])
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: OFRangeMake(1, 3)]) &&
[mutableString1 isEqual: @"𝄞bä€"] &&
R([mutableString1 deleteCharactersInRange: OFRangeMake(0, 4)]) &&
[mutableString1 isEqual: @""])
TEST(@"-[replaceCharactersInRange:withString:]",
(mutableString1 = [mutableStringClass
stringWithString: @"𝄞öööbä€"]) &&
R([mutableString1 replaceCharactersInRange: OFRangeMake(1, 3)
withString: @"äöüß"]) &&
[mutableString1 isEqual: @"𝄞äöüßbä€"] &&
R([mutableString1 replaceCharactersInRange: OFRangeMake(4, 2)
withString: @"b"]) &&
[mutableString1 isEqual: @"𝄞äöübä€"] &&
R([mutableString1 replaceCharactersInRange: OFRangeMake(0, 7)
withString: @""]) &&
[mutableString1 isEqual: @""])
EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #1",
OFOutOfRangeException,
{
mutableString1 = [mutableStringClass stringWithString: @"𝄞öö"];
[mutableString1 deleteCharactersInRange: OFRangeMake(2, 2)];
})
EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #2",
OFOutOfRangeException,
[mutableString1 deleteCharactersInRange: OFRangeMake(4, 0)])
EXPECT_EXCEPTION(@"Detect OoR in "
@"-[replaceCharactersInRange:withString:] #1",
OFOutOfRangeException,
[mutableString1 replaceCharactersInRange: OFRangeMake(2, 2)
withString: @""])
EXPECT_EXCEPTION(@"Detect OoR in "
@"-[replaceCharactersInRange:withString:] #2",
OFOutOfRangeException,
[mutableString1 replaceCharactersInRange: OFRangeMake(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: OFRangeMake(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"] &&
|
|
|
>
|
|
|
|
>
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
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"] &&
|
︙ | | | ︙ | |