diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-06 22:25:28 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:51 +0200 |
commit | dbc6b41b79db2907f5b5e496e9d3c32c7d811453 (patch) | |
tree | 3bb59b1bc11249f50c467d3fd3a259fd562409a9 | |
parent | 4274fd95d0e33d436fd6d16419b6aab34cae3ed4 (diff) |
Use do_run_from_file() for test_zerodiv
-rw-r--r-- | tests/core/test_zerodiv.in | 21 | ||||
-rw-r--r-- | tests/core/test_zerodiv.out | 4 | ||||
-rw-r--r-- | tests/test_core.py | 27 |
3 files changed, 28 insertions, 24 deletions
diff --git a/tests/core/test_zerodiv.in b/tests/core/test_zerodiv.in new file mode 100644 index 00000000..991b6c1d --- /dev/null +++ b/tests/core/test_zerodiv.in @@ -0,0 +1,21 @@ + + #include <stdio.h> + int main(int argc, const char* argv[]) + { + float f1 = 1.0f; + float f2 = 0.0f; + float f_zero = 0.0f; + + float f3 = 0.0f / f2; + float f4 = f2 / 0.0f; + float f5 = f2 / f2; + float f6 = f2 / f_zero; + + printf("f3: %f\n", f3); + printf("f4: %f\n", f4); + printf("f5: %f\n", f5); + printf("f6: %f\n", f6); + + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_zerodiv.out b/tests/core/test_zerodiv.out new file mode 100644 index 00000000..3bb47f8a --- /dev/null +++ b/tests/core/test_zerodiv.out @@ -0,0 +1,4 @@ +f3: nan +f4: nan +f5: nan +f6: nan diff --git a/tests/test_core.py b/tests/test_core.py index 1e131563..d8d2cbd7 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -776,31 +776,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co self.do_run_from_file(src, output, ['5', '6', '8']) def test_zerodiv(self): - self.do_run(r''' - #include <stdio.h> - int main(int argc, const char* argv[]) - { - float f1 = 1.0f; - float f2 = 0.0f; - float f_zero = 0.0f; - - float f3 = 0.0f / f2; - float f4 = f2 / 0.0f; - float f5 = f2 / f2; - float f6 = f2 / f_zero; - - printf("f3: %f\n", f3); - printf("f4: %f\n", f4); - printf("f5: %f\n", f5); - printf("f6: %f\n", f6); + test_path = path_from_root('tests', 'core', 'test_zerodiv') + src, output = (test_path + s for s in ('.in', '.out')) - return 0; - } - ''', '''f3: nan -f4: nan -f5: nan -f6: nan -''') + self.do_run_from_file(src, output) def test_zero_multiplication(self): src = ''' |