summaryrefslogtreecommitdiff
path: root/ccan/foreach/test/run.c
blob: d12b6274efd3824781466f7b2da0e2fec7a8098e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <ccan/foreach/foreach.h>
#include <ccan/tap/tap.h>
#include <stdio.h>
#include <string.h>
#include <ccan/foreach/foreach.c>

int main(void)
{
	int i, expecti;
	const char *p, *expectp[] = { "hello", "there", "big", "big", "world" };

	plan_tests(11);

	expecti = 0;
	foreach_int(i, 0, 1, 2, 3, 4) {
		ok1(i == expecti);
		expecti++;
	}

	expecti = 0;
	foreach_ptr(p, "hello", "there", "big", "big", "world") {
		ok1(strcmp(expectp[expecti], p) == 0);
		expecti++;
	}
	ok1(p == NULL);

	return exit_status();
}