Skip to content

Commit

Permalink
Add tests to search character in a string
Browse files Browse the repository at this point in the history
Add tests as suggested by @martinholters
  • Loading branch information
emmt authored Jun 11, 2020
1 parent b156d4c commit 9dbf458
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,48 @@ end
@test_throws DivideError mod(3, 1:0)
end

# https://github.com/JuliaLang/julia/pull/31664
let astr = "Hello, world.\n",
u8str = "∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε"
@test_throws BoundsError findnext('z', astr, 0)
@test_throws BoundsError findnext('', astr, 0)
@test findfirst('x', astr) == nothing
@test findfirst('\0', astr) == nothing
@test findfirst('\u80', astr) == nothing
@test findfirst('', astr) == nothing
@test findfirst('', u8str) == 1
@test findfirst('ε', u8str) == 5
@test findfirst('H', astr) == 1
@test findfirst('l', astr) == 3
@test findfirst('e', astr) == 2
@test findfirst('u', astr) == nothing
@test findnext('l', astr, 4) == 4
@test findnext('l', astr, 5) == 11
@test findnext('l', astr, 12) == nothing
@test findfirst(',', astr) == 6
@test findnext(',', astr, 7) == nothing
@test findfirst('\n', astr) == 14
@test findnext('\n', astr, 15) == nothing
@test_throws BoundsError findnext('ε', astr, nextind(astr,lastindex(astr))+1)
@test_throws BoundsError findnext('a', astr, nextind(astr,lastindex(astr))+1)
@test findlast('x', astr) == nothing
@test findlast('\0', astr) == nothing
@test findlast('\u80', astr) == nothing
@test findlast('', astr) == nothing
@test findlast('', u8str) == 1
@test findlast('ε', u8str) == 54
@test findlast('H', astr) == 1
@test findprev('H', astr, 0) == nothing
@test findlast('l', astr) == 11
@test findprev('l', astr, 5) == 4
@test findprev('l', astr, 4) == 4
@test findprev('l', astr, 3) == 3
@test findprev('l', astr, 2) == nothing
@test findlast(',', astr) == 6
@test findprev(',', astr, 5) == nothing
@test findlast('\n', astr) == 14
end

using LinearAlgebra

@testset "generalized dot #32739" begin
Expand Down

0 comments on commit 9dbf458

Please sign in to comment.