Initial import of libucore
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#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 = 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;
|
||||
}
|
||||
Reference in New Issue
Block a user