]> git.ozlabs.org Git - ccan/blobdiff - ccan/aga/test/api-dijkstra.c
aga,agar: Negative weight cycle testcase
[ccan] / ccan / aga / test / api-dijkstra.c
index 74875fbc88f7de672acfb9be7a1cf6ea9e3f7eba..01bb5aa4d880f579ea4c60dd3f51a64a14a9657d 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_dijkstra_start(&ng.sg.g, &ng.sg.nodes[1]) == 0);
+       aga_dijkstra_complete(&ng.sg.g);
+       ok1(aga_error(&ng.sg.g) == AGA_ERR_NEGATIVE_COST);
+       aga_finish(&ng.sg.g);
+}
+
 int main(void)
 {
        plan_tests(7 + 20
                   + FULL_LEN * (1 + FULL_LEN*4)
                   + CHAIN_LEN * (1 + CHAIN_LEN*2)
-                  + 12 + 32 + 7 + 2);
+                  + 12 + 32 + 7 + 2 + 2);
 
        test_trivial();
        test_parallel();
@@ -261,6 +273,7 @@ int main(void)
        test_traversal1();
        test_shortcut1();
        test_shortcut2();
+       test_negacycle();
        
        return exit_status();
 }