]> git.ozlabs.org Git - ccan/blob - ccan/structeq/test/run-with-unknown-padding.c
structeq: fix case where we mark padding as unknown.
[ccan] / ccan / structeq / test / run-with-unknown-padding.c
1 #include <ccan/structeq/structeq.h>
2 #include <ccan/tap/tap.h>
3
4 /* In theory, this could be generated without padding, if alignof(int) were 0,
5  * and test would fail.  Call me when that happens. */
6 struct mydata {
7         char start;
8         int end;
9 };
10
11 STRUCTEQ_DEF(mydata, -3, start, end);
12
13 struct mydata2 {
14         char start;
15         int end;
16 };
17
18 STRUCTEQ_DEF(mydata2, -4, start, end);
19
20 int main(void)
21 {
22         struct mydata a, b;
23
24         /* This is how many tests you plan to run */
25         plan_tests(3);
26
27         a.start = 0;
28         a.end = 100;
29         ok1(mydata_eq(&a, &a));
30
31         b = a;
32         ok1(mydata_eq(&a, &b));
33
34         b.end++;
35         ok1(!mydata_eq(&a, &b));
36
37         /* This exits depending on whether all tests passed */
38         return exit_status();
39 }