File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff 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'
You can’t perform that action at this time.
0 commit comments