Skip to content

Commit 106177b

Browse files
committed
Add more tests
1 parent f4729cf commit 106177b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/runtests.jl

+32
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ using Test
44

55
@testset "TreeDataStructures.jl" begin
66
@testset "AVLTree" begin
7+
# insert
78
tree = AVLTree{Int,Int}()
89
tree[2] = 20
910
tree[1] = 10
@@ -24,6 +25,37 @@ using Test
2425
@test tree[3] isa Float64
2526
@test tree[3] == 30.0
2627

28+
# update values
29+
tree = AVLTree{Int,Int}()
30+
tree[2] = 20
31+
tree[1] = 10
32+
tree[3] = 30
33+
@test tree[2] == 20
34+
@test tree[1] == 10
35+
@test tree[3] == 30
36+
tree[2] = 22
37+
tree[1] = 11
38+
tree[3] = 33
39+
@test tree[2] == 22
40+
@test tree[1] == 11
41+
@test tree[3] == 33
42+
43+
# delete
44+
tree = AVLTree{Int,Int}()
45+
tree[2] = 20
46+
tree[1] = 10
47+
tree[3] = 30
48+
delete!(tree, 3)
49+
@test !isnothing(tree.root)
50+
@test !isnothing(tree.root.left)
51+
@test isnothing(tree.root.right)
52+
delete!(tree, 1)
53+
@test !isnothing(tree.root)
54+
@test isnothing(tree.root.left)
55+
@test isnothing(tree.root.right)
56+
delete!(tree, 2)
57+
@test isnothing(tree.root)
58+
2759
# tree that accept any types
2860
tree = AVLTree()
2961
tree[2] = 'A'

0 commit comments

Comments
 (0)