Initial import of libucore

This commit is contained in:
Nils O. Selåsdal
2012-10-29 23:07:32 +01:00
commit ed3866e49a
79 changed files with 6181 additions and 0 deletions
+43
View File
@@ -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;
}