Skip to content

Commit 4044fd8

Browse files
committed
some tests
1 parent 315fad0 commit 4044fd8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/interfaceTests.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,41 @@ end
2222
global fac0, fac1, fac2 = DFGFactorSCA()
2323
end
2424

25+
26+
@testset "Custom Printing" begin
27+
28+
iobuf = IOBuffer()
29+
# for now just test the interface and a bit of output
30+
@test printVariable(var1) == nothing
31+
@test printFactor(fac1) == nothing
32+
33+
@test printVariable(iobuf, var1, skipfields=[:timestamp, :solver, :ppe]) == nothing
34+
@test String(take!(iobuf)) == "DFGVariable{TestSofttype1}\nlabel:\n:a\ntags:\nSet([:VARIABLE, :POSE])\nsmallData:\nDict(\"small\"=>\"data\")\nbigData:\nDict{Symbol,AbstractBigDataEntry}()\n_dfgNodeParams:\nDFGNodeParams(0)\n"
35+
36+
@test printVariable(iobuf, var1, short=true) == nothing
37+
@test String(take!(iobuf)) == "DFGVariable{TestSofttype1}\nlabel: a\ntags: Set([:VARIABLE, :POSE])\nsize marginal samples: (1, 1)\nkde bandwidths: [0.0]\nNo PPEs\n"
38+
39+
40+
@test printFactor(iobuf, fac1, skipfields=[:timestamp, :solver]) == nothing
41+
@test occursin(r"DFGFactor.*\nlabel:\n:abf1", String(take!(iobuf)))
42+
43+
String(take!(iobuf)) == "DFGFactor{TestCCW{TestFunctorInferenceType1}}\nlabel:\n:abf1\ntags:\nSet([:tag1, :tag2])\nsolvable:\n0\n_dfgNodeParams:\nDFGNodeParams(1)\n_variableOrderSymbols:\n[:a, :b]\n"
44+
45+
@test printFactor(iobuf, fac1, short=true) == nothing
46+
@test occursin(r"DFGFactor.*\nlabel.*\ntimestamp.*\ntags.*\nsolvable", String(take!(iobuf)))
47+
48+
# s = String(take!(iobuf))
49+
50+
@test show(var1) == nothing
51+
@test show(fac1) == nothing
52+
53+
@test show(iobuf, MIME("text/plain"), var1) == nothing
54+
isapprox(length(take!(iobuf)), 452, atol=10)
55+
@test show(iobuf, MIME("text/plain"), fac1) == nothing
56+
isapprox(length(take!(iobuf)), 301, atol=10)
57+
58+
end
59+
2560
@testset "Variables and Factors CRUD and SET" begin
2661
VariablesandFactorsCRUD_SET!(fg1, var1, var2, var3, fac0, fac1, fac2)
2762
end

0 commit comments

Comments
 (0)