aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/stddef.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stddef.c')
-rw-r--r--tests/stddef.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/stddef.c b/tests/stddef.c
new file mode 100644
index 0000000..f63e57c
--- /dev/null
+++ b/tests/stddef.c
@@ -0,0 +1,23 @@
+#include <helpers.h>
+#include <stddef.h>
+
+struct S {
+ int x;
+ int y;
+};
+struct T {
+ char a;
+ int b;
+ char c;
+};
+
+int main() {
+ ASSERT_EQ(0, offsetof(struct S, x));
+ ASSERT_EQ(4, offsetof(struct S, y));
+ ASSERT_EQ(0, offsetof(struct T, a));
+ ASSERT_EQ(4, offsetof(struct T, b));
+ ASSERT_EQ(8, offsetof(struct T, c));
+
+ char buf[offsetof(struct T, b)];
+ ASSERT_EQ(4, sizeof(buf));
+}