X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fagar%2Ftest%2Ferror-graph.c;fp=ccan%2Fagar%2Ftest%2Ferror-graph.c;h=efd83a37bf0fba6ba27c5007cf9991b8ef379701;hb=c2966d1879c825cfaf0e7d6848a5da052ee4a038;hp=0000000000000000000000000000000000000000;hpb=06162212353c882249d7e207756ea81ea645fc30;p=ccan diff --git a/ccan/agar/test/error-graph.c b/ccan/agar/test/error-graph.c new file mode 100644 index 00000000..efd83a37 --- /dev/null +++ b/ccan/agar/test/error-graph.c @@ -0,0 +1,55 @@ +#include "config.h" + +#include + +#include +#include +#include + +#include "simple-graphr.h" + +static const void *error_first_edge_r(const struct agar_graph *gr, + const void *nr) +{ + return int2ptr(1); +} + +static const void *error_next_edge_r(const struct agar_graph *gr, + const void *nr, const void *e) +{ + assert(ptr2int(e) == 1); + + return NULL; +} + +static int error_edge_info_r(const struct agar_graph *gr, + const void *nr, const void *e, + struct agar_edge_info *eir) +{ + int fromindex = ptr2int(nr); + + switch (fromindex) { + case 1: + eir->to = int2ptr(2); + break; + + case 2: + eir->to = NULL; + break; + + case 3: + eir->to = int2ptr(4); + break; + + default: + return -1; + } + + return 0; +} + +void error_graphr_init(struct error_graphr *egr) +{ + agar_init_graph(&egr->gr, error_first_edge_r, error_next_edge_r, + error_edge_info_r); +}