summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/core/test_rounding.in29
-rw-r--r--tests/core/test_rounding.out1
-rw-r--r--tests/test_core.py33
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):