Skip to content

Add tests #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,46 @@ using TreeDataStructures
using Test

@testset "TreeDataStructures.jl" begin
# Write your tests here.
@testset "AVLTree" begin
tree = AVLTree{Int,Int}()
tree[1] = 10
tree[2] = 20
tree[3] = 30
@test tree[1] == 10
@test tree[2] == 20
@test tree[3] == 30

# value conversion
tree = AVLTree{Int,Float64}()
tree[1] = 10
tree[2] = 20
tree[3] = 30
@test tree[1] isa Float64
@test tree[1] == 10.0
@test tree[2] isa Float64
@test tree[2] == 20.0
@test tree[3] isa Float64
@test tree[3] == 30.0

# tree that accept any types
tree = AVLTree()
tree[1] = 1.1
tree[2] = 'A'
tree[3] = "test"
@test tree[1] == 1.1
@test tree[2] == 'A'
@test tree[3] == "test"

# show
tree = AVLTree{Int,Int}()
@test sprint(show, MIME("text/plain"), tree) == "AVLTree()"
tree[1] = 10
tree[2] = 20
tree[3] = 30
@test sprint(show, MIME("text/plain"), tree) == """
AVLTree
2 => 20
├─ 1 => 10
└─ 3 => 30"""
end
end