Files
libucore/test/test_containerof.c
T
2012-11-15 18:26:31 +01:00

44 lines
730 B
C

#include <check.h>
#include <ucore/ucore_utils.h>
struct Inner {
int x;
int y;
};
struct Outer {
int tag1;
int tag2;
struct Inner inner;
int tag3;
};
START_TEST (test_container_of)
struct Outer outer = {
.tag1 = 1,
.tag2 = 2,
.inner = {
.x = 1234,
.y = 5678
}
};
struct Inner *innerp = &outer.inner;
struct Outer *outerp = CONTAINER_OF(innerp, struct Outer, inner);
fail_if(outerp != &outer);
END_TEST
Suite *container_of_suite(void)
{
Suite *s = suite_create("container_of");
TCase *tc = tcase_create("container_of tests");
tcase_add_test(tc, test_container_of);
suite_add_tcase(s, tc);
return s;
}