X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fstrset%2Ftest%2Frun-iterate-const.c;fp=ccan%2Fstrset%2Ftest%2Frun-iterate-const.c;h=42a1d73552b9541d19297770ad65bf9706e7b650;hb=932aeb6dcc4a6df2d08755f743659451c9721447;hp=0000000000000000000000000000000000000000;hpb=4ea280eb94ec5f2eef352066a94a160d9b8dd059;p=ccan diff --git a/ccan/strset/test/run-iterate-const.c b/ccan/strset/test/run-iterate-const.c new file mode 100644 index 00000000..42a1d735 --- /dev/null +++ b/ccan/strset/test/run-iterate-const.c @@ -0,0 +1,30 @@ +#include +#include +#include + +static bool found = false; + +/* Make sure const args work. */ +static bool find_string(const char *str, const char *cmp) +{ + if (strcmp(str, cmp) == 0) + found = true; + return false; +} + +int main(void) +{ + struct strset set; + + plan_tests(3); + + strset_init(&set); + ok1(strset_set(&set, "hello")); + ok1(strset_set(&set, "world")); + strset_iterate(&set, find_string, (const char *)"hello"); + ok1(found); + strset_destroy(&set); + + /* This exits depending on whether all tests passed */ + return exit_status(); +}