X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fagar%2Ftest%2Fapi-bellman_ford.c;h=a161b0ca63d9b3f398bb4e0b068d925e18b63dd2;hp=960cf3994f0109f17b0466fe25a38f0cb0326c00;hb=318edb2466a24a2eadcfd05fa83ae29c0e8aae03;hpb=eedf1079f38efb2b8dc4fd3f516cce8ac1272c06 diff --git a/ccan/agar/test/api-bellman_ford.c b/ccan/agar/test/api-bellman_ford.c index 960cf399..a161b0ca 100644 --- a/ccan/agar/test/api-bellman_ford.c +++ b/ccan/agar/test/api-bellman_ford.c @@ -229,12 +229,22 @@ static void test_shortcut2(void) tal_free(sr); } +static void test_negacycle(void) +{ + struct agar_state *sr; + + ok1(sr = agar_bellman_ford_new(NULL, &negacycle_graphr.gr, int2ptr(1))); + agar_bellman_ford_complete(sr); + ok1(agar_error(sr) == AGA_ERR_NEGATIVE_COST); + tal_free(sr); +} + int main(void) { plan_tests(3 + 15 + FULL_LEN * (FULL_LEN*4 - 1) + CHAIN_LEN * (1 + CHAIN_LEN*2) - + 10 + 32 + 7 + 7); + + 10 + 32 + 7 + 7 + 2); test_trivial(); test_parallel(); @@ -244,6 +254,7 @@ int main(void) test_traversal1(); test_shortcut1(); test_shortcut2(); + test_negacycle(); return exit_status(); }