diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-06 22:48:09 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:51 +0200 |
commit | c9bf465d5a56efd7a14cd8ad01acccca77527aad (patch) | |
tree | 1b98cb458436903a05dc21bf4deae8116505804e /tests | |
parent | 63678388a4028a93c7bdd0ac45263faf509ce955 (diff) |
Use do_run_from_file() for test_rounding
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_rounding.in | 29 | ||||
-rw-r--r-- | tests/core/test_rounding.out | 1 | ||||
-rw-r--r-- | tests/test_core.py | 33 |
3 files changed, 33 insertions, 30 deletions
diff --git a/tests/core/test_rounding.in b/tests/core/test_rounding.in new file mode 100644 index 00000000..63960ac4 --- /dev/null +++ b/tests/core/test_rounding.in @@ -0,0 +1,29 @@ + + #include <stdio.h> + #include <math.h> + + int main() + { + printf("%.1f ", round(1.4)); + printf("%.1f ", round(1.6)); + printf("%.1f ", round(-1.4)); + printf("%.1f ", round(-1.6)); + + printf("%.1f ", round(1.5)); + printf("%.1f ", round(2.5)); + printf("%.1f ", round(-1.5)); + printf("%.1f ", round(-2.5)); + + printf("%ld ", lrint(1.4)); + printf("%ld ", lrint(1.6)); + printf("%ld ", lrint(-1.4)); + printf("%ld ", lrint(-1.6)); + + printf("%ld ", lrint(1.5)); + printf("%ld ", lrint(2.5)); + printf("%ld ", lrint(-1.5)); + printf("%ld ", lrint(-2.5)); + + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_rounding.out b/tests/core/test_rounding.out new file mode 100644 index 00000000..b826ceab --- /dev/null +++ b/tests/core/test_rounding.out @@ -0,0 +1 @@ +1.0 2.0 -1.0 -2.0 2.0 3.0 -2.0 -3.0 1 2 -1 -2 2 2 -2 -2
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index 3610ca6a..580c5c8f 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -825,37 +825,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co self.do_run_from_file(src, output) def test_rounding(self): - src = ''' - #include <stdio.h> - #include <math.h> - - int main() - { - printf("%.1f ", round(1.4)); - printf("%.1f ", round(1.6)); - printf("%.1f ", round(-1.4)); - printf("%.1f ", round(-1.6)); - - printf("%.1f ", round(1.5)); - printf("%.1f ", round(2.5)); - printf("%.1f ", round(-1.5)); - printf("%.1f ", round(-2.5)); - - printf("%ld ", lrint(1.4)); - printf("%ld ", lrint(1.6)); - printf("%ld ", lrint(-1.4)); - printf("%ld ", lrint(-1.6)); - - printf("%ld ", lrint(1.5)); - printf("%ld ", lrint(2.5)); - printf("%ld ", lrint(-1.5)); - printf("%ld ", lrint(-2.5)); + test_path = path_from_root('tests', 'core', 'test_rounding') + src, output = (test_path + s for s in ('.in', '.out')) - return 0; - } - ''' - self.do_run(src, "1.0 2.0 -1.0 -2.0 2.0 3.0 -2.0 -3.0 " - "1 2 -1 -2 2 2 -2 -2") + self.do_run_from_file(src, output) # This example borrowed from MSDN documentation def test_fcvt(self): |