]> pd.if.org Git - lice/blobdiff - tests/alignof.c
autocommit for files dated 2014-11-17 20:13:32
[lice] / tests / alignof.c
diff --git a/tests/alignof.c b/tests/alignof.c
new file mode 100644 (file)
index 0000000..f3a58a9
--- /dev/null
@@ -0,0 +1,43 @@
+// alignof
+
+#include <alignof.h>
+
+int main(void) {
+    expecti(__alignof_is_defined, 1);
+
+    expecti(alignof(char), 1);
+    expecti(alignof(int),  4);
+    expecti(alignof(long), 8);
+
+    struct test {
+        char a;
+        int  b;
+    };
+
+    expecti(alignof(struct test), 8);
+
+    expecti(_Alignof(char), 1);
+    expecti(__alignof__(char), 1);
+    expecti(_Alignof(struct test), 8);
+    expecti(__alignof__(struct test), 8);
+
+    struct complex {
+        struct {
+            char a;
+            short b;
+            int c;
+        } d;
+        char e;
+        union {
+            int f;
+            struct {
+                int g;
+                int h;
+            } i;
+        } j;
+    };
+
+    expecti(alignof(struct complex), 16);
+
+    return 0;
+}