Skip to content

Commit d7b59fd

Browse files
committed
add test for save and load
1 parent f77ebec commit d7b59fd

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ include("testPartialFactors.jl")
2323
@testset "basic Bayes tree construction" begin
2424
include("testBayesTreeiSAM2Example.jl")
2525
end
26+
27+
include("testTreeSaveLoad.jl")
28+
2629
@testset "Ensure converter types can be run from extending namespaces..." begin
2730
include("saveconvertertypes.jl")
2831
end

test/testTreeSaveLoad.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# test saving and loading of trees
2+
3+
using Test
4+
using IncrementalInference
5+
6+
@testset "Test loading and saving of Bayes (Junction) tree" begin
7+
8+
fg = loadCanonicalFG_Kaess(graphinit=false)
9+
tree = wipeBuildNewTree!(fg)
10+
11+
# save and load tree
12+
saveTree(tree)
13+
tree2 = loadTree()
14+
15+
# perform a few spot checks to see that the trees are similar
16+
@test length(tree.cliques) == length(tree2.cliques)
17+
@test getVariableOrder(tree) == getVariableOrder(tree2)
18+
19+
for (clid,cl) in tree.cliques
20+
fsyms = getFrontals(cl)
21+
cl2 = getCliq(tree2, fsyms[1])
22+
fsyms2 = getFrontals(cl2)
23+
@test fsyms == fsyms2
24+
@test getCliqSeparatorVarIds(cl) == getCliqSeparatorVarIds(cl2)
25+
@test typeof(cl) == typeof(cl2)
26+
end
27+
28+
end

0 commit comments

Comments
 (0)