X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fforeach%2Ftest%2Frun-single-arg.c;fp=ccan%2Fforeach%2Ftest%2Frun-single-arg.c;h=25413181cc6fcdca0b879c307949a3eb72efd663;hp=0000000000000000000000000000000000000000;hb=b824ee6e4ad48687325106c60ddb7f0b43565189;hpb=5b115ea9392ca30ce5f0bbeb18389ea9aaea7421 diff --git a/ccan/foreach/test/run-single-arg.c b/ccan/foreach/test/run-single-arg.c new file mode 100644 index 00000000..25413181 --- /dev/null +++ b/ccan/foreach/test/run-single-arg.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include + +int main(void) +{ + int i, num; + const char *p; + + plan_tests(5); + + num = 0; + foreach_int(i, 0) { + ok1(i == 0); + num++; + } + ok1(num == 1); + + num = 0; + foreach_ptr(p, "hello") { + ok1(strcmp("hello", p) == 0); + num++; + } + ok1(p == NULL); + ok1(num == 1); + + return exit_status(); +} +