diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 16:05:52 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:36:00 +0200 |
commit | e63b77e1763afff819dba9880b5b1855965e6db0 (patch) | |
tree | 62c3462e2296fa18509757be17ccd8b2e7a5660b | |
parent | bd0e4075eaa1dab1894947e2fa6650c723ee2911 (diff) |
Use do_run_from_file() for test_fwrite_0
-rw-r--r-- | tests/core/test_fwrite_0.in | 21 | ||||
-rw-r--r-- | tests/core/test_fwrite_0.out | 1 | ||||
-rw-r--r-- | tests/test_core.py | 24 |
3 files changed, 25 insertions, 21 deletions
diff --git a/tests/core/test_fwrite_0.in b/tests/core/test_fwrite_0.in new file mode 100644 index 00000000..478524bb --- /dev/null +++ b/tests/core/test_fwrite_0.in @@ -0,0 +1,21 @@ + + #include <stdio.h> + #include <stdlib.h> + + int main () + { + FILE *fh; + + fh = fopen("a.txt", "wb"); + if (!fh) exit(1); + fclose(fh); + + fh = fopen("a.txt", "rb"); + if (!fh) exit(1); + + char data[] = "foobar"; + size_t written = fwrite(data, 1, sizeof(data), fh); + + printf("written=%zu\n", written); + } +
\ No newline at end of file diff --git a/tests/core/test_fwrite_0.out b/tests/core/test_fwrite_0.out new file mode 100644 index 00000000..d96592d1 --- /dev/null +++ b/tests/core/test_fwrite_0.out @@ -0,0 +1 @@ +written=0
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index b0a676d0..dc27450d 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3847,28 +3847,10 @@ def process(filename): self.do_run(src, ('got: 35\ngot: 45\ngot: 25\ngot: 15\nisatty? 0,0,1\n', 'isatty? 0,0,1\ngot: 35\ngot: 45\ngot: 25\ngot: 15\n'), post_build=post) def test_fwrite_0(self): - src = r''' - #include <stdio.h> - #include <stdlib.h> - - int main () - { - FILE *fh; - - fh = fopen("a.txt", "wb"); - if (!fh) exit(1); - fclose(fh); - - fh = fopen("a.txt", "rb"); - if (!fh) exit(1); - - char data[] = "foobar"; - size_t written = fwrite(data, 1, sizeof(data), fh); + test_path = path_from_root('tests', 'core', 'test_fwrite_0') + src, output = (test_path + s for s in ('.in', '.out')) - printf("written=%zu\n", written); - } - ''' - self.do_run(src, 'written=0') + self.do_run_from_file(src, output) def test_fgetc_ungetc(self): src = open(path_from_root('tests', 'stdio', 'test_fgetc_ungetc.c'), 'r').read() |