Add tests for classifications

This commit is contained in:
Dimitri Lozeve 2020-02-22 17:28:47 +01:00
parent 6d30b54570
commit fa6c02dc6c
2 changed files with 40 additions and 0 deletions

39
test/classification.jl Normal file
View 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

View file

@ -33,4 +33,5 @@ using Test
grid[9] = 3
@test GardenOptim.deltacost(grid, costs, 3, 8) != 0
end
include("classification.jl")
end