1 #include <ccan/container_of/container_of.h>
2 #include <ccan/tap/tap.h>
9 int main(int argc, char *argv[])
11 struct foo foo = { .a = 1, .b = 2 };
16 ok1(container_of(intp, struct foo, a) == &foo);
17 ok1(container_of(charp, struct foo, b) == &foo);
18 ok1(container_of_var(intp, &foo, a) == &foo);
19 ok1(container_of_var(charp, &foo, b) == &foo);
21 ok1(container_off(intp, struct foo, a) == 0);
22 ok1(container_off(charp, struct foo, b) == offsetof(struct foo, b));