Add validity checks to tests

This commit is contained in:
2023-08-24 14:44:21 +02:00
parent 383c92ec47
commit 1b4030d633
8 changed files with 150 additions and 4 deletions

View File

@ -47,6 +47,8 @@ function test_random_walk(g::DAG, n::Int64)
# the purpose here is to do "random" operations and reverse them again and validate that the graph stays the same and doesn't diverge
reset_graph!(g)
@test is_valid(g)
properties = graph_properties(g)
for i = 1:n
@ -78,6 +80,8 @@ function test_random_walk(g::DAG, n::Int64)
reset_graph!(g)
@test is_valid(g)
@test properties == graph_properties(g)
end
end

View File

@ -51,6 +51,8 @@ import MetagraphOptimization.make_node
insert_edge!(graph, BD, B1C_2, false)
insert_edge!(graph, CD, C1C, false)
@test is_valid(graph)
@test is_exit_node(d_exit)
@test is_entry_node(AD)
@test is_entry_node(BD)
@ -74,6 +76,8 @@ import MetagraphOptimization.make_node
@test Set(nr.input) == Set([B1D_1, B1D_2])
push_operation!(graph, nr)
opt = get_operations(graph)
@test is_valid(graph)
@test length(opt) == (nodeFusions = 4, nodeReductions = 0, nodeSplits = 1)
#println("After 2 Node Reductions:\n", opt)
@ -89,5 +93,7 @@ import MetagraphOptimization.make_node
opt = get_operations(graph)
@test length(opt) == (nodeFusions = 6, nodeReductions = 1, nodeSplits = 1)
#println("After reverting to the initial state:\n", opt)
@test is_valid(graph)
end
println("Node Reduction Unit Tests Complete!")

View File

@ -107,6 +107,8 @@ import MetagraphOptimization.partners
@test length(graph.dirtyNodes) == 26
@test length(graph.diff) == (addedNodes = 0, removedNodes = 0, addedEdges = 0, removedEdges = 0)
@test is_valid(graph)
@test is_entry_node(d_PB)
@test is_entry_node(d_PA)
@test is_entry_node(d_PBp)
@ -204,5 +206,7 @@ import MetagraphOptimization.partners
operations = get_operations(graph)
@test length(operations) == (nodeFusions = 10, nodeReductions = 0, nodeSplits = 0)
@test is_valid(graph)
end
println("Graph Unit Tests Complete!")