aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Thibault <ajt@hyperlogic.org>2013-05-19 10:22:06 -0700
committerAnthony Thibault <ajt@hyperlogic.org>2013-05-19 10:22:06 -0700
commit4e66f07c04a2fd118b7f7aa1280f62974b77e48d (patch)
treed68f4e5b2aa0cb0971ce1d8343c75b05a5463785
parentcd2fc719f8501a9575dddd2a65c44384453a4177 (diff)
Issue #1172: added test_fscanf to runner.py
-rwxr-xr-xtests/runner.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 3ee54ad3..c9e952b8 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6316,6 +6316,31 @@ def process(filename):
self.emcc_args += ['--embed-file', 'eol.txt']
self.do_run(src, 'SUCCESS\n')
+ def test_fscanf(self):
+ if self.emcc_args is None: return self.skip('requires emcc')
+ open(os.path.join(self.get_dir(), 'three_numbers.txt'), 'w').write('''-1 0.1 -.1''')
+ src = r'''
+ #include <stdio.h>
+ #include <assert.h>
+ #include <float.h>
+ int main()
+ {
+ float x = FLT_MAX, y = FLT_MAX, z = FLT_MAX;
+
+ FILE* fp = fopen("three_numbers.txt", "r");
+ if (fp) {
+ int match = fscanf(fp, " %f %f %f ", &x, &y, &z);
+ printf("match = %d\n", match);
+ printf("x = %0.1f, y = %0.1f, z = %0.1f\n", x, y, z);
+ } else {
+ printf("failed to open three_numbers.txt\n");
+ }
+ return 0;
+ }
+ '''
+ self.emcc_args += ['--embed-file', 'three_numbers.txt']
+ self.do_run(src, 'match = 3\nx = -1.0, y = 0.1, z = -0.1\n')
+
def test_folders(self):
add_pre_run = '''
def process(filename):