run.c 448 B

123456789101112131415161718192021
  1. #include "container_of/container_of.h"
  2. #include "tap/tap.h"
  3. struct foo {
  4. int a;
  5. char b;
  6. };
  7. int main(int argc, char *argv[])
  8. {
  9. struct foo foo = { .a = 1, .b = 2 };
  10. int *intp = &foo.a;
  11. char *charp = &foo.b;
  12. plan_tests(4);
  13. ok1(container_of(intp, struct foo, a) == &foo);
  14. ok1(container_of(charp, struct foo, b) == &foo);
  15. ok1(container_of_var(intp, &foo, a) == &foo);
  16. ok1(container_of_var(charp, &foo, b) == &foo);
  17. return exit_status();
  18. }