]> pd.if.org Git - lice/blobdiff - tests/pointer.c
autocommit for files dated 2014-11-17 20:13:36
[lice] / tests / pointer.c
diff --git a/tests/pointer.c b/tests/pointer.c
new file mode 100644 (file)
index 0000000..d734f78
--- /dev/null
@@ -0,0 +1,29 @@
+// pointers
+
+int main(void) {
+    int   a   = 1024;
+    int  *b   = &a;
+    char *c   = "hi";
+    char *d   = "hi" + 1;
+    char  e[] = "abc";
+    char *f   = e + 2;
+    char  g[] = "abc";
+
+    *g = 32;
+    expecti(*b, 1024);
+    expecti(*c, 'h');
+    expecti(*d, 'i');
+    expecti(*f, 'c');
+    expecti(*g, 32);
+
+    int aa[] = { 1, 2, 3 };
+    int *p = aa;
+    expecti(*p, 1); p++;
+    expecti(*p, 2); p++;
+    expecti(*p, 3);
+    expecti(*p, 3); p--;
+    expecti(*p, 2); p--;
+    expecti(*p, 1);
+
+    return 0;
+}