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

reverse search fix #41203

Merged
merged 2 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion base/strings/search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ function _rsearchindex(s::AbstractVector{<:Union{Int8,UInt8}}, t::AbstractVector
n = length(t)
m = length(s)
k = Int(_k) - sentinel
k < 1 && throw(BoundsError(s, _k))
k < 0 && throw(BoundsError(s, _k))

if n == 0
return 0 <= k <= m ? max(k, 1) : sentinel
Expand Down
1 change: 1 addition & 0 deletions test/strings/search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ for str in [astr]
@test findprev('l', str, 2) == nothing
@test findlast(',', str) == 6
@test findprev(',', str, 5) == nothing
@test findlast(str, "") == nothing
Moelf marked this conversation as resolved.
Show resolved Hide resolved
@test findlast('\n', str) == 14
end

Expand Down
1 change: 1 addition & 0 deletions test/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ end
@test split("", "") == rsplit("", "") == [""]
@test split("abc", "") == rsplit("abc", "") == ["a","b","c"]
@test rsplit("abc", "", limit=2) == ["ab","c"]
@test rsplit("", "//") == [""]
@test split("abc", "", limit=2) == ["a","bc"]

@test split("", r"") == [""]
Expand Down