Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshday committed Sep 20, 2024
1 parent 80d6b5a commit f59e8f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Cobweb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ Base.push!(o::Node, x) = push!(children(o), x)
Base.append!(o::Node, x) = append!(children(o), x)
Base.deleteat!(o::Node, x) = deleteat!(children(o), x)
Base.pop!(o::Node) = pop!(children(o))
Base.popat!(o::Node, i) = popat!(children(o), i)
Base.popfirst!(o::Node) = popfirst!(children(o))
Base.splice!(o::Node, i::Integer) = splice!(children(o), i)
Base.splice!(o::Node, i::Integer, x) = splice!(children(o), i, x)
Base.empty!(o::Node) = empty!(children(o))



Expand Down
23 changes: 22 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,32 @@ end
@test get(node, :id2, 1) == 1
get!(node, :id2, "myid2")
@test propertynames(node) == [:id, :class, :id2]
@test node[end] == "content"
@test node[1] == node[end] == "content"
# push!
push!(node, h.span("child"))
@test node[end] == h.span("child")
# append!
append!(node, [h.span("child2"), h.span("child3")])
@test node[end] == h.span("child3")
# empty!
empty!(node)
@test isempty(node)
# pop!
push!(node, "test")
@test pop!(node) == "test"
@test isempty(node)
push!(node, "test")
# popat!
push!(node, "test")
@test popat!(node, 1) == "test"
# deleteat!
deleteat!(node, 1)
@test isempty(node)
# splice!
push!(node, "test")
@test splice!(node, 1, ["new"]) == "test"
@test splice!(node, 1) == "new"
@test isempty(node)
end
#-----------------------------------------------------------------------------# indexing
@testset "get/setindex" begin
Expand Down

0 comments on commit f59e8f5

Please sign in to comment.