Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eliascarv committed Oct 21, 2024
1 parent f4729cf commit 106177b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Test

@testset "TreeDataStructures.jl" begin
@testset "AVLTree" begin
# insert
tree = AVLTree{Int,Int}()
tree[2] = 20
tree[1] = 10
Expand All @@ -24,6 +25,37 @@ using Test
@test tree[3] isa Float64
@test tree[3] == 30.0

# update values
tree = AVLTree{Int,Int}()
tree[2] = 20
tree[1] = 10
tree[3] = 30
@test tree[2] == 20
@test tree[1] == 10
@test tree[3] == 30
tree[2] = 22
tree[1] = 11
tree[3] = 33
@test tree[2] == 22
@test tree[1] == 11
@test tree[3] == 33

# delete
tree = AVLTree{Int,Int}()
tree[2] = 20
tree[1] = 10
tree[3] = 30
delete!(tree, 3)
@test !isnothing(tree.root)
@test !isnothing(tree.root.left)
@test isnothing(tree.root.right)
delete!(tree, 1)
@test !isnothing(tree.root)
@test isnothing(tree.root.left)
@test isnothing(tree.root.right)
delete!(tree, 2)
@test isnothing(tree.root)

# tree that accept any types
tree = AVLTree()
tree[2] = 'A'
Expand Down

0 comments on commit 106177b

Please sign in to comment.