Skip to content

Commit eecbe9f

Browse files
committed
Merge pull request #11937 from ninjin/nin/stests
RFC: Additional string tests for #11885
2 parents f98decc + 3c7652e commit eecbe9f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/strings.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ end
264264

265265
# string manipulation
266266
@test strip("\t hi \n") == "hi"
267+
@test strip("foobarfoo", ['f', 'o']) == "bar"
267268

268269
# some test strings
269270
astr = "Hello, world.\n"
@@ -573,6 +574,9 @@ end
573574
@test search("foo,bar,baz", r"az") == 10:11
574575
@test search("foo,bar,baz", r"az", 12) == 0:-1
575576

577+
@test searchindex("foo", 'o') == 2
578+
@test searchindex("foo", 'o', 3) == 3
579+
576580
# string searchindex with a two-char UTF-8 (2 byte) string literal
577581
@test searchindex("ééé", "éé") == 1
578582
@test searchindex("ééé", "éé", 1) == 1
@@ -778,6 +782,12 @@ end
778782
@test replace("ḟøøƀäṙḟøø", r"(ḟø|ƀä)", "xx") == "xxøxxṙxxø"
779783
@test replace("ḟøøƀäṙḟøø", r"(ḟøø|ƀä)", "ƀäṙ") == "ƀäṙƀäṙṙƀäṙ"
780784

785+
@test replace("foo", "oo", uppercase) == "fOO"
786+
787+
# chomp/chop
788+
@test chomp("foo\n") == "foo"
789+
@test chop("foob") == "foo"
790+
781791
# lower and upper
782792
@test uppercase("aBc") == "ABC"
783793
@test uppercase('A') == 'A'
@@ -806,6 +816,8 @@ end
806816
@test !endswith("abcd", "dc")
807817
@test !endswith("cd", "abcd")
808818

819+
@test filter(x -> x ['f', 'o'], "foobar") == "foo"
820+
809821
# RepStrings and SubStrings
810822
u8str2 = u8str^2
811823
len_u8str = length(u8str)
@@ -848,6 +860,8 @@ ss=SubString(str2,1,4) #empty source string
848860
ss=SubString(str2,1,1) #empty source string, identical start and end index
849861
@test length(ss)==0
850862

863+
@test SubString("foobar",big(1),big(3)) == "foo"
864+
851865
str = "aa\u2200\u2222bb"
852866
u = SubString(str, 3, 6)
853867
@test length(u)==2
@@ -1153,6 +1167,7 @@ end
11531167

11541168
@test symbol("asdf") === :asdf
11551169
@test symbol(:abc,"def",'g',"hi",0) === :abcdefghi0
1170+
@test :a < :b
11561171
@test startswith(string(gensym("asdf")),"##asdf#")
11571172
@test gensym("asdf") != gensym("asdf")
11581173
@test gensym() != gensym()

0 commit comments

Comments
 (0)