aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/core/test_flexarray_struct.in24
-rw-r--r--tests/core/test_flexarray_struct.out1
-rw-r--r--tests/test_core.py28
3 files changed, 28 insertions, 25 deletions
diff --git a/tests/core/test_flexarray_struct.in b/tests/core/test_flexarray_struct.in
new file mode 100644
index 00000000..40ee1ddd
--- /dev/null
+++ b/tests/core/test_flexarray_struct.in
@@ -0,0 +1,24 @@
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+typedef struct
+{
+ uint16_t length;
+ struct
+ {
+ int32_t int32;
+ } value[];
+} Tuple;
+
+int main() {
+ Tuple T[10];
+ Tuple *t = &T[0];
+
+ t->length = 4;
+ t->value->int32 = 100;
+
+ printf("(%d, %d)\n", t->length, t->value->int32);
+ return 0;
+}
diff --git a/tests/core/test_flexarray_struct.out b/tests/core/test_flexarray_struct.out
new file mode 100644
index 00000000..b6f53a0d
--- /dev/null
+++ b/tests/core/test_flexarray_struct.out
@@ -0,0 +1 @@
+(4, 100) \ No newline at end of file
diff --git a/tests/test_core.py b/tests/test_core.py
index 59a5261c..827cbf7d 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -2576,32 +2576,10 @@ The current type of b is: 9
self.do_run_from_file(src, output)
def test_flexarray_struct(self):
- src = r'''
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-typedef struct
-{
- uint16_t length;
- struct
- {
- int32_t int32;
- } value[];
-} Tuple;
-
-int main() {
- Tuple T[10];
- Tuple *t = &T[0];
-
- t->length = 4;
- t->value->int32 = 100;
+ test_path = path_from_root('tests', 'core', 'test_flexarray_struct')
+ src, output = (test_path + s for s in ('.in', '.out'))
- printf("(%d, %d)\n", t->length, t->value->int32);
- return 0;
-}
-'''
- self.do_run(src, '(4, 100)')
+ self.do_run_from_file(src, output)
def test_bsearch(self):
if Settings.QUANTUM_SIZE == 1: return self.skip('Test cannot work with q1')