46 lines
731 B
C
46 lines
731 B
C
#include <check.h>
|
|
#include "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 = UC_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;
|
|
}
|