Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Additional string tests for #11885 #11937

Merged
merged 1 commit into from Jun 30, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ end

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

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

@test searchindex("foo", 'o') == 2
@test searchindex("foo", 'o', 3) == 3

# string searchindex with a two-char UTF-8 (2 byte) string literal
@test searchindex("ééé", "éé") == 1
@test searchindex("ééé", "éé", 1) == 1
Expand Down Expand Up @@ -778,6 +782,12 @@ end
@test replace("ḟøøƀäṙḟøø", r"(ḟø|ƀä)", "xx") == "xxøxxṙxxø"
@test replace("ḟøøƀäṙḟøø", r"(ḟøø|ƀä)", "ƀäṙ") == "ƀäṙƀäṙṙƀäṙ"

@test replace("foo", "oo", uppercase) == "fOO"

# chomp/chop
@test chomp("foo\n") == "foo"
@test chop("foob") == "foo"

# lower and upper
@test uppercase("aBc") == "ABC"
@test uppercase('A') == 'A'
Expand Down Expand Up @@ -806,6 +816,8 @@ end
@test !endswith("abcd", "dc")
@test !endswith("cd", "abcd")

@test filter(x -> x ∈ ['f', 'o'], "foobar") == "foo"

# RepStrings and SubStrings
u8str2 = u8str^2
len_u8str = length(u8str)
Expand Down Expand Up @@ -848,6 +860,8 @@ ss=SubString(str2,1,4) #empty source string
ss=SubString(str2,1,1) #empty source string, identical start and end index
@test length(ss)==0

@test SubString("foobar",big(1),big(3)) == "foo"

str = "aa\u2200\u2222bb"
u = SubString(str, 3, 6)
@test length(u)==2
Expand Down Expand Up @@ -1153,6 +1167,7 @@ end

@test symbol("asdf") === :asdf
@test symbol(:abc,"def",'g',"hi",0) === :abcdefghi0
@test :a < :b
@test startswith(string(gensym("asdf")),"##asdf#")
@test gensym("asdf") != gensym("asdf")
@test gensym() != gensym()
Expand Down