Skip to content

Commit

Permalink
permit deleteat! to take any idx, not just Integer
Browse files Browse the repository at this point in the history
  • Loading branch information
AsafManela committed May 15, 2019
1 parent caf4ed4 commit 787d6fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/WeakRefStrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ function Base.push!(arr::StringVector, val::Missing)
push!(arr.lengths, 0)
end

function Base.deleteat!(arr::StringVector, idx::Integer)
function Base.deleteat!(arr::StringVector, idx)
deleteat!(arr.lengths, idx)
deleteat!(arr.offsets, idx)
arr
Expand Down
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,16 @@ end
sv = StringVector{EscapedString{UInt8('"')}}(["Text\"\"inner quote\"\"Parse", "JuliaDB"])
@test sv[1] == "Text\"inner quote\"Parse"
end

@testset "deleteat!" begin
sv1 = StringVector{WeakRefString{UInt8}}(["foo", "bar"])
@test deleteat!(copy(sv1), 1) == ["bar"]
@test deleteat!(copy(sv1), [1,2]) == []
@test deleteat!(copy(sv1), 1:2) == []

sv2 = StringVector{String}(["baz", "qux"])
@test deleteat!(copy(sv2), 1) == ["qux"]
@test deleteat!(copy(sv2), [1,2]) == []
@test deleteat!(copy(sv2), 1:2) == []
end
end

0 comments on commit 787d6fe

Please sign in to comment.