diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2014-08-15 13:20:18 +0200 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2014-08-15 13:25:15 +0200 |
commit | 926446f4aab62d5fa02840d39d661de61632292c (patch) | |
tree | f0d46e4dfd8fe9e56f3debc69bb72ebfa7ee53a2 | |
parent | db73295accbec0c6513817f0a64a92018592bb26 (diff) | |
download | systemd-926446f4aab62d5fa02840d39d661de61632292c.tar.gz systemd-926446f4aab62d5fa02840d39d661de61632292c.tar.bz2 systemd-926446f4aab62d5fa02840d39d661de61632292c.zip |
test: fix strtod test for real
The "0,5" syntax was actually right. The real problem is, the test should
only run if the local system has the de_DE.UTF-8 locale. Therefore, skip
the tests if setlocale() fails. This is kinda ugly, as it is done
silently, but we cannot skip partial tests with the current
infrastructure. Should be fine this way.
-rw-r--r-- | src/test/test-util.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c index 1850f97723..7d81b0b7be 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -202,20 +202,21 @@ static void test_safe_atod(void) { assert_se(*e == ','); /* Check if this really is locale independent */ - setlocale(LC_NUMERIC, "de_DE.utf8"); + if (setlocale(LC_NUMERIC, "de_DE.utf8")) { - r = safe_atod("0.2244", &d); - assert_se(r == 0); - assert_se(fabs(d - 0.2244) < 0.000001); + r = safe_atod("0.2244", &d); + assert_se(r == 0); + assert_se(fabs(d - 0.2244) < 0.000001); - r = safe_atod("0,5", &d); - assert_se(r == -EINVAL); + r = safe_atod("0,5", &d); + assert_se(r == -EINVAL); - errno = 0; - assert_se(fabs(strtod("0.5", &e) - 0.5) < 0.00001); + errno = 0; + assert_se(fabs(strtod("0,5", &e) - 0.5) < 0.00001); + } /* And check again, reset */ - setlocale(LC_NUMERIC, "C"); + assert_se(setlocale(LC_NUMERIC, "C")); r = safe_atod("0.2244", &d); assert_se(r == 0); |