diff options
author | Felipe Sateler <fsateler@debian.org> | 2019-02-20 21:24:33 -0300 |
---|---|---|
committer | Felipe Sateler <fsateler@debian.org> | 2019-02-20 21:24:33 -0300 |
commit | 7c20daf69c4411979b7f8902f3601d1cdc56cc07 (patch) | |
tree | d59b9989ce55ed23693e80974d94c856f1c2c8b1 /src/test/test-json.c | |
parent | 6e866b331d7cd4a5e0759dd160dea6edabd3678e (diff) | |
download | systemd-8334ea1698549f336631f37714499a91b140a271.tar.gz |
New upstream version 241upstream/241
Diffstat (limited to 'src/test/test-json.c')
-rw-r--r-- | src/test/test-json.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/test/test-json.c b/src/test/test-json.c index 5aa4d19dbe..fdf1b4f40c 100644 --- a/src/test/test-json.c +++ b/src/test/test-json.c @@ -1,9 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #include <math.h> -#if HAVE_VALGRIND_VALGRIND_H -#include <valgrind/valgrind.h> -#endif #include "alloc-util.h" #include "fd-util.h" @@ -45,12 +42,13 @@ static void test_tokenizer(const char *data, ...) { d = va_arg(ap, long double); -#if HAVE_VALGRIND_VALGRIND_H - if (!RUNNING_ON_VALGRIND) -#endif - /* Valgrind doesn't support long double calculations and automatically downgrades to 80bit: - * http://www.valgrind.org/docs/manual/manual-core.html#manual-core.limits */ - assert_se(fabsl(d - v.real) < 0.001L); + /* Valgrind doesn't support long double calculations and automatically downgrades to 80bit: + * http://www.valgrind.org/docs/manual/manual-core.html#manual-core.limits. + * Some architectures might not support long double either. + */ + + assert_se(fabsl(d - v.real) < 1e-10 || + fabsl((d - v.real) / v.real) < 1e-10); } else if (t == JSON_TOKEN_INTEGER) { intmax_t i; @@ -211,7 +209,6 @@ static void test_2(JsonVariant *v) { assert_se(p && json_variant_type(p) == JSON_VARIANT_REAL && fabsl(json_variant_real(p) - 1.27) < 0.001); } - static void test_zeroes(JsonVariant *v) { size_t i; @@ -285,6 +282,7 @@ static void test_build(void) { a = json_variant_unref(a); b = json_variant_unref(b); + const char* arr_1234[] = {"one", "two", "three", "four", NULL}; assert_se(json_build(&a, JSON_BUILD_ARRAY(JSON_BUILD_OBJECT(JSON_BUILD_PAIR("x", JSON_BUILD_BOOLEAN(true)), JSON_BUILD_PAIR("y", JSON_BUILD_OBJECT(JSON_BUILD_PAIR("this", JSON_BUILD_NULL)))), JSON_BUILD_VARIANT(NULL), @@ -292,8 +290,9 @@ static void test_build(void) { JSON_BUILD_STRING(NULL), JSON_BUILD_NULL, JSON_BUILD_INTEGER(77), - JSON_BUILD_ARRAY(JSON_BUILD_VARIANT(JSON_VARIANT_STRING_CONST("foobar")), JSON_BUILD_VARIANT(JSON_VARIANT_STRING_CONST("zzz"))), - JSON_BUILD_STRV(STRV_MAKE("one", "two", "three", "four")))) >= 0); + JSON_BUILD_ARRAY(JSON_BUILD_VARIANT(JSON_VARIANT_STRING_CONST("foobar")), + JSON_BUILD_VARIANT(JSON_VARIANT_STRING_CONST("zzz"))), + JSON_BUILD_STRV((char**) arr_1234))) >= 0); assert_se(json_variant_format(a, 0, &s) >= 0); log_info("GOT: %s\n", s); |