From 4e66f07c04a2fd118b7f7aa1280f62974b77e48d Mon Sep 17 00:00:00 2001 From: Anthony Thibault Date: Sun, 19 May 2013 10:22:06 -0700 Subject: Issue #1172: added test_fscanf to runner.py --- tests/runner.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') 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 + #include + #include + 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): -- cgit v1.2.3-18-g5258