summaryrefslogtreecommitdiffstats
path: root/libacc
diff options
context:
space:
mode:
authorJack Palevich <jackpal@google.com>2009-07-31 11:27:29 -0700
committerJack Palevich <jackpal@google.com>2009-07-31 11:27:29 -0700
commitbeb4fe95a05e54e99f5fe90d5c64dae2f8aaa5af (patch)
tree3d69688742c3f047aa47ba3d9f8bd43ab48fbec3 /libacc
parent29daf577a110ab19ad333993f178483e747278f1 (diff)
downloadsystem_core-beb4fe95a05e54e99f5fe90d5c64dae2f8aaa5af.zip
system_core-beb4fe95a05e54e99f5fe90d5c64dae2f8aaa5af.tar.gz
system_core-beb4fe95a05e54e99f5fe90d5c64dae2f8aaa5af.tar.bz2
Test multiple levels of pointer indirection.
Diffstat (limited to 'libacc')
-rw-r--r--libacc/tests/data/pointers2.c35
-rw-r--r--libacc/tests/test.py13
2 files changed, 47 insertions, 1 deletions
diff --git a/libacc/tests/data/pointers2.c b/libacc/tests/data/pointers2.c
new file mode 100644
index 0000000..69e402f
--- /dev/null
+++ b/libacc/tests/data/pointers2.c
@@ -0,0 +1,35 @@
+// Test multiple levels of indirection
+
+void testsingle() {
+ int a = 0;
+ int* pa = &a;
+ printf("a = %d, *pa = %d\n", a, *pa);
+ *pa = 2;
+ printf("a = %d, *pa = %d\n", a, *pa);
+}
+
+void testdouble() {
+ int a = 0;
+ int* pa = &a;
+ int** ppa = &pa;
+ printf("a = %d, *pa = %d **ppa = %d\n", a, *pa, **ppa);
+ **ppa = 2;
+ printf("a = %d, *pa = %d **ppa = %d\n", a, *pa, **ppa);
+}
+
+void testtripple() {
+ int a = 0;
+ int* pa = &a;
+ int** ppa = &pa;
+ int*** pppa = &ppa;
+ printf("a = %d, *pa = %d **ppa = %d\n ***pppa = %d", a, *pa, **ppa, ***pppa);
+ ***pppa = 2;
+ printf("a = %d, *pa = %d **ppa = %d\n ***pppa = %d", a, *pa, **ppa, ***pppa);
+}
+
+int main() {
+ testsingle();
+ testdouble();
+ testdouble();
+ return 0;
+}
diff --git a/libacc/tests/test.py b/libacc/tests/test.py
index 31b8329..f9089be 100644
--- a/libacc/tests/test.py
+++ b/libacc/tests/test.py
@@ -324,11 +324,22 @@ result: 0""", """Literals: 1 -1
0
""")
- def testFilm (self):
+ def testFilm(self):
self.compileCheck(["-R", "data/film.c"], """Executing compiled code:
result: 0""", """testing...
Total bad: 0
""")
+
+ def testpointers2(self):
+ self.compileCheck(["-R", "data/pointers2.c"], """Executing compiled code:
+result: 0""", """a = 0, *pa = 0
+a = 2, *pa = 2
+a = 0, *pa = 0 **ppa = 0
+a = 2, *pa = 2 **ppa = 2
+a = 0, *pa = 0 **ppa = 0
+a = 2, *pa = 2 **ppa = 2
+""")
+
if __name__ == '__main__':
if not outputCanRun():
print "Many tests are expected to fail, because acc is not a 32-bit x86 Linux executable."