Add tests for classifications
This commit is contained in:
parent
6d30b54570
commit
fa6c02dc6c
2 changed files with 40 additions and 0 deletions
39
test/classification.jl
Normal file
39
test/classification.jl
Normal file
|
@ -0,0 +1,39 @@
|
|||
using GardenOptim
|
||||
using Test
|
||||
|
||||
@testset "classification" begin
|
||||
clf = GardenOptim.Classification(
|
||||
Dict(
|
||||
"type"=>"Life",
|
||||
"name"=>"God",
|
||||
"children"=>[
|
||||
Dict(
|
||||
"type"=>"Family",
|
||||
"name"=>"Homo",
|
||||
"children"=>[
|
||||
Dict(
|
||||
"type"=>"Species",
|
||||
"name"=>"Human",
|
||||
"bio"=>"Homo sapiens",
|
||||
"children"=>[]
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
@testset "constructor" begin
|
||||
@test_throws UndefRefError clf.parent
|
||||
@test clf.children[1].parent === clf
|
||||
@test length(clf.children) == 1
|
||||
@test clf.children[1].type == :family
|
||||
@test clf.children[1].children[1].bio == "Homo sapiens"
|
||||
@test clf.children[1].children[1].name == :human
|
||||
@test clf.children[1].children[1].children == []
|
||||
end
|
||||
@testset "getfirstparent" begin
|
||||
@test GardenOptim.getfirstparent(:human, clf) === clf.children[1]
|
||||
@test GardenOptim.getfirstparent(:homo, clf) === clf.children[1]
|
||||
@test_throws UndefRefError GardenOptim.getfirstparent(:god, clf)
|
||||
end
|
||||
end
|
|
@ -33,4 +33,5 @@ using Test
|
|||
grid[9] = 3
|
||||
@test GardenOptim.deltacost(grid, costs, 3, 8) != 0
|
||||
end
|
||||
include("classification.jl")
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue