Remove unused main() args in many modules.
[ccan] / ccan / opt / test / run-iter.c
1 #include <ccan/tap/tap.h>
2 #include <stdarg.h>
3 #include <setjmp.h>
4 #include <stdlib.h>
5 #include <stdarg.h>
6 #include "utils.h"
7 #include <ccan/opt/opt.c>
8 #include <ccan/opt/usage.c>
9 #include <ccan/opt/helpers.c>
10 #include <ccan/opt/parse.c>
11
12 /* Test iterators. */
13 int main(void)
14 {
15         unsigned j, i, len = 0;
16         const char *p;
17
18         plan_tests(37 * 2);
19         for (j = 0; j < 2; j ++) {
20                 reset_options();
21                 /* Giving subtable a title makes an extra entry! */
22                 opt_register_table(subtables, j == 0 ? NULL : "subtable");
23
24                 p = first_lopt(&i, &len);
25                 ok1(i == j + 0);
26                 ok1(len == 3);
27                 ok1(strncmp(p, "jjj", len) == 0);
28                 p = next_lopt(p, &i, &len);
29                 ok1(i == j + 0);
30                 ok1(len == 3);
31                 ok1(strncmp(p, "lll", len) == 0);
32                 p = next_lopt(p, &i, &len);
33                 ok1(i == j + 1);
34                 ok1(len == 3);
35                 ok1(strncmp(p, "mmm", len) == 0);
36                 p = next_lopt(p, &i, &len);
37                 ok1(i == j + 5);
38                 ok1(len == 3);
39                 ok1(strncmp(p, "ddd", len) == 0);
40                 p = next_lopt(p, &i, &len);
41                 ok1(i == j + 6);
42                 ok1(len == 3);
43                 ok1(strncmp(p, "eee", len) == 0);
44                 p = next_lopt(p, &i, &len);
45                 ok1(i == j + 7);
46                 ok1(len == 3);
47                 ok1(strncmp(p, "ggg", len) == 0);
48                 p = next_lopt(p, &i, &len);
49                 ok1(i == j + 8);
50                 ok1(len == 3);
51                 ok1(strncmp(p, "hhh", len) == 0);
52                 p = next_lopt(p, &i, &len);
53                 ok1(!p);
54
55                 p = first_sopt(&i);
56                 ok1(i == j + 0);
57                 ok1(*p == 'j');
58                 p = next_sopt(p, &i);
59                 ok1(i == j + 0);
60                 ok1(*p == 'l');
61                 p = next_sopt(p, &i);
62                 ok1(i == j + 1);
63                 ok1(*p == 'm');
64                 p = next_sopt(p, &i);
65                 ok1(i == j + 2);
66                 ok1(*p == 'a');
67                 p = next_sopt(p, &i);
68                 ok1(i == j + 3);
69                 ok1(*p == 'b');
70                 p = next_sopt(p, &i);
71                 ok1(i == j + 7);
72                 ok1(*p == 'g');
73                 p = next_sopt(p, &i);
74                 ok1(i == j + 8);
75                 ok1(*p == 'h');
76                 p = next_sopt(p, &i);
77                 ok1(!p);
78         }
79
80         return exit_status();
81 }