From c9b3190f9ba547c58d83944e07d420563a62a0c8 Mon Sep 17 00:00:00 2001 From: David Wehr <dawehr@iastate.edu> Date: Wed, 22 Feb 2017 00:05:24 -0600 Subject: [PATCH] Added unit test for graph update rules. --- .../test/test_computation_graph.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/quad/computation_graph/test/test_computation_graph.c b/quad/computation_graph/test/test_computation_graph.c index e4155ec8f..1cf2b26d7 100644 --- a/quad/computation_graph/test/test_computation_graph.c +++ b/quad/computation_graph/test/test_computation_graph.c @@ -145,6 +145,21 @@ int graph_test_self_loop() { return 0; } +int graph_test_update_rules() { + struct computation_graph *graph = create_graph(); + int cblock = graph_add_node_const(graph, "const"); + int acum_b = graph_add_node_accum(graph, "accumulator"); + graph_set_source(graph, acum_b, ACCUM_IN, cblock, CONST_VAL); + + graph_set_param_val(graph, cblock, CONST_SET, 3); + int to_compute_for[1] = {acum_b}; + graph_compute_nodes(graph, to_compute_for, 1); + graph_compute_nodes(graph, to_compute_for, 1); + + double result = graph_get_output(graph, acum_b, ACCUMULATED); + return nequal(result, 3); +} + int main() { int success = 0; @@ -155,5 +170,6 @@ int main() { test(graph_test_single_run, "Test that blocks only get executed once"); test(graph_test_reset_rules, "Tests that already connected blocks don't get reset"); test(graph_test_self_loop, "Tests that a self-loop computation terminates"); + test(graph_test_update_rules, "Tests that nodes only update when their inputs change"); test_summary(); } -- GitLab