summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_linked_list.in42
-rw-r--r--tests/core/test_linked_list.out1
-rw-r--r--tests/test_core.py45
3 files changed, 46 insertions, 42 deletions
diff --git a/tests/core/test_linked_list.in b/tests/core/test_linked_list.in
new file mode 100644
index 00000000..4ca978bf
--- /dev/null
+++ b/tests/core/test_linked_list.in
@@ -0,0 +1,42 @@
+
+ #include <stdio.h>
+ struct worker_args {
+ int value;
+ struct worker_args *next;
+ };
+ int main()
+ {
+ worker_args a;
+ worker_args b;
+ a.value = 60;
+ a.next = &b;
+ b.value = 900;
+ b.next = NULL;
+ worker_args* c = &a;
+ int total = 0;
+ while (c) {
+ total += c->value;
+ c = c->next;
+ }
+
+ // Chunk of em
+ worker_args chunk[10];
+ for (int i = 0; i < 9; i++) {
+ chunk[i].value = i*10;
+ chunk[i].next = &chunk[i+1];
+ }
+ chunk[9].value = 90;
+ chunk[9].next = &chunk[0];
+
+ c = chunk;
+ do {
+ total += c->value;
+ c = c->next;
+ } while (c != chunk);
+
+ printf("*%d,%d*\n", total, b.next);
+ // NULL *is* 0, in C/C++. No JS null! (null == 0 is false, etc.)
+
+ return 0;
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_linked_list.out b/tests/core/test_linked_list.out
new file mode 100644
index 00000000..f3b615b1
--- /dev/null
+++ b/tests/core/test_linked_list.out
@@ -0,0 +1 @@
+*1410,0* \ No newline at end of file
diff --git a/tests/test_core.py b/tests/test_core.py
index 66ef952b..030d8875 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1008,49 +1008,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
self.do_run_from_file(src, output)
def test_linked_list(self):
- src = '''
- #include <stdio.h>
- struct worker_args {
- int value;
- struct worker_args *next;
- };
- int main()
- {
- worker_args a;
- worker_args b;
- a.value = 60;
- a.next = &b;
- b.value = 900;
- b.next = NULL;
- worker_args* c = &a;
- int total = 0;
- while (c) {
- total += c->value;
- c = c->next;
- }
-
- // Chunk of em
- worker_args chunk[10];
- for (int i = 0; i < 9; i++) {
- chunk[i].value = i*10;
- chunk[i].next = &chunk[i+1];
- }
- chunk[9].value = 90;
- chunk[9].next = &chunk[0];
-
- c = chunk;
- do {
- total += c->value;
- c = c->next;
- } while (c != chunk);
-
- printf("*%d,%d*\\n", total, b.next);
- // NULL *is* 0, in C/C++. No JS null! (null == 0 is false, etc.)
+ test_path = path_from_root('tests', 'core', 'test_linked_list')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, '*1410,0*')
+ self.do_run_from_file(src, output)
def test_sup(self):
src = '''