]> git.ozlabs.org Git - ccan/blobdiff - ccan/aga/test/api-bellman_ford.c
aga,agar: Negative weight cycle testcase
[ccan] / ccan / aga / test / api-bellman_ford.c
index e0ce1a067822bad31e32377e110e8a39f06eb5d1..5dc032a77bbf7c7d5960465c26d01caea2a27b8d 100644 (file)
@@ -246,12 +246,24 @@ static void test_shortcut2(void)
        aga_finish(&s2g.sg.g);
 }
 
+static void test_negacycle(void)
+{
+       struct negacycle_graph ng;
+
+       negacycle_graph_init(&ng);
+
+       ok1(aga_bellman_ford_start(&ng.sg.g, &ng.sg.nodes[1]) == 0);
+       aga_bellman_ford_complete(&ng.sg.g);
+       ok1(aga_error(&ng.sg.g) == AGA_ERR_NEGATIVE_COST);
+       aga_finish(&ng.sg.g);
+}
+
 int main(void)
 {
        plan_tests(5 + 15
                   + FULL_LEN * (1 + FULL_LEN * 4)
                   + CHAIN_LEN * (1 + CHAIN_LEN * 2)
-                  + 10 + 32 + 7 + 7);
+                  + 10 + 32 + 7 + 7 + 2);
 
        test_trivial();
        test_parallel();
@@ -261,6 +273,7 @@ int main(void)
        test_traversal1();
        test_shortcut1();
        test_shortcut2();
+       test_negacycle();
        
        return exit_status();
 }