ccan: make tal_dump() format more regular.
[ccan] / ccan / foreach / test / run-break.c
1 #include <ccan/foreach/foreach.h>
2 #include <ccan/tap/tap.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <ccan/foreach/foreach.c>
6
7 static int count_iters(void)
8 {
9         unsigned int count = 0;
10 #if !HAVE_COMPOUND_LITERALS || !HAVE_FOR_LOOP_DECLARATION
11         struct iter_info *i;
12         
13         list_for_each(&iters, i, list)
14                 count++;
15 #endif
16         return count;
17 }
18
19 int main(void)
20 {
21         int i, j, sum;
22
23         plan_tests(2);
24
25         sum = 0;
26         foreach_int(i, 0, 1, 2, 3, 4) {
27                 foreach_int(j, 0, 1, 2, 3, 4) {
28                         sum += i*j;
29                         if (j == i)
30                                 break;
31                 }
32         }
33         ok1(sum == 65);
34         ok1(count_iters() <= 2);
35
36         return exit_status();
37 }
38