summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2011-12-03 16:49:16 +0000
committerPeter Wu <lekensteyn@gmail.com>2011-12-03 16:49:16 +0000
commita3e28c60b97fd96182727715ba15ed0cc713597a (patch)
tree90df827d3f5700305f39ee504ca074575a5340b8 /tests
parent044d0814cacbcd3f3869276583cd566da182b0b2 (diff)
downloadpp2cc-a3e28c60b97fd96182727715ba15ed0cc713597a.tar.gz
Correct array initialization, add testcase
Diffstat (limited to 'tests')
-rw-r--r--tests/array-global.c8
-rw-r--r--tests/array-local.c6
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/array-global.c b/tests/array-global.c
new file mode 100644
index 0000000..6af2216
--- /dev/null
+++ b/tests/array-global.c
@@ -0,0 +1,8 @@
+int n = 4;
+int a[] = {5, 4, 3, 2};
+int one[1] = {0, 2};
+int two[2] = {9, 8};
+int main(){
+ // Should return 5 + 8 = 13 (0xd)
+ return *a + two[1];
+}
diff --git a/tests/array-local.c b/tests/array-local.c
new file mode 100644
index 0000000..7f9d274
--- /dev/null
+++ b/tests/array-local.c
@@ -0,0 +1,6 @@
+int main(){
+ int n = 4;
+ int a[] = {5, 4, 3, n};
+ // should return 5 + 4 + 4 = 13 = 0xd
+ return *a + a[1] + a[3];
+}