]> pd.if.org Git - lice/blobdiff - tests/union.c
autocommit for files dated 2014-11-17 20:13:38
[lice] / tests / union.c
diff --git a/tests/union.c b/tests/union.c
new file mode 100644 (file)
index 0000000..cb0d982
--- /dev/null
@@ -0,0 +1,31 @@
+// unions
+
+int global = 5;
+int *pointer = &global;
+
+int main(void) {
+    union {
+        int a;
+        int b;
+    } a = { 128 };
+
+    union {
+        char a[4];
+        int  b;
+    } b = { .b = 0 };
+
+    b.a[1] = 1;
+
+    union {
+        char a[4];
+        int  b;
+    } c = { 0, 1, 0, 0 };
+
+    expecti(a.b, 128);
+    expecti(b.b, 256);
+    expecti(c.b, 256);
+
+    expecti(*pointer, 5);
+
+    return 0;
+}