diff options
author | Thomas Hindoe Paaboel Andersen <phomes@gmail.com> | 2014-08-04 23:13:31 +0200 |
---|---|---|
committer | Thomas Hindoe Paaboel Andersen <phomes@gmail.com> | 2014-08-04 23:28:02 +0200 |
commit | 8e211000025940b770794abf5754de61b4add0af (patch) | |
tree | 3d70a1ba4109361f8f3e61d36113ff894819a87e /src/test/test-util.c | |
parent | 21d73c87b09ec2b8642424bc714ce9af3da4fc40 (diff) |
test: use fabs on doubles
Diffstat (limited to 'src/test/test-util.c')
-rw-r--r-- | src/test/test-util.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c index 470475aa5d..16f89b4716 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -26,6 +26,7 @@ #include <locale.h> #include <errno.h> #include <signal.h> +#include <math.h> #include "util.h" #include "mkdir.h" @@ -191,7 +192,7 @@ static void test_safe_atod(void) { r = safe_atod("0.2244", &d); assert_se(r == 0); - assert_se(abs(d - 0.2244) < 0.000001); + assert_se(fabs(d - 0.2244) < 0.000001); r = safe_atod("0,5", &d); assert_se(r == -EINVAL); @@ -205,20 +206,20 @@ static void test_safe_atod(void) { r = safe_atod("0.2244", &d); assert_se(r == 0); - assert_se(abs(d - 0.2244) < 0.000001); + assert_se(fabs(d - 0.2244) < 0.000001); r = safe_atod("0,5", &d); assert_se(r == -EINVAL); errno = 0; - assert_se(abs(strtod("0,5", &e) - 0.5) < 0.00001); + assert_se(fabs(strtod("0,5", &e) - 0.5) < 0.00001); /* And check again, reset */ setlocale(LC_NUMERIC, "C"); r = safe_atod("0.2244", &d); assert_se(r == 0); - assert_se(abs(d - 0.2244) < 0.000001); + assert_se(fabs(d - 0.2244) < 0.000001); r = safe_atod("0,5", &d); assert_se(r == -EINVAL); |