X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fautodata%2Ftest%2Frun.c;fp=ccan%2Fautodata%2Ftest%2Frun.c;h=d70faaa2bf20d62bfa354febf94541ba418aedc8;hb=446eaa5f66db385d89357ba43aa5886f8b906ff0;hp=0000000000000000000000000000000000000000;hpb=6a8d296f9383dd25ec381e2ab136a33823d140e5;p=ccan diff --git a/ccan/autodata/test/run.c b/ccan/autodata/test/run.c new file mode 100644 index 00000000..d70faaa2 --- /dev/null +++ b/ccan/autodata/test/run.c @@ -0,0 +1,41 @@ +#include +/* Include the C files directly. */ +#include +#include + +AUTODATA_TYPE(autostrings, char); + +AUTODATA(autostrings, "hello"); +AUTODATA(autostrings, "world"); + +int main(void) +{ + char **table; + size_t num; + int i, hello = -1, world = -1, helper = -1; + + /* This is how many tests you plan to run */ + plan_tests(4); + + table = autodata_get(autostrings, &num); + ok1(num == 3); + + for (i = 0; i < num; i++) { + if (strcmp(table[i], "hello") == 0) + hello = i; + else if (strcmp(table[i], "world") == 0) + world = i; + else if (strcmp(table[i], "helper") == 0) + helper = i; + else + fail("Unknown entry %s", table[i]); + } + ok1(hello != -1); + ok1(world != -1); + ok1(helper != -1); + + autodata_free(table); + + /* This exits depending on whether all tests passed */ + return exit_status(); +}