diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2017-11-04 15:47:35 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2017-11-04 15:54:06 +0000 |
commit | 675e27505776a1d77fa1ffd1974284890caec1f4 (patch) | |
tree | 5779bd5d6c011f2b787f448a1c23ef2178797359 /json-glib/tests/parser.c | |
parent | 70e2648e02232c1a439a7418388f18fee9afb3fe (diff) | |
download | json-glib-675e27505776a1d77fa1ffd1974284890caec1f4.tar.gz |
Use fuzzy comparison for floating point values
Direct comparison should never be used for floating point values.
Fixes #27 and #28.
Diffstat (limited to 'json-glib/tests/parser.c')
-rw-r--r-- | json-glib/tests/parser.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/json-glib/tests/parser.c b/json-glib/tests/parser.c index f71584a..8c52a1d 100644 --- a/json-glib/tests/parser.c +++ b/json-glib/tests/parser.c @@ -1,11 +1,5 @@ -#include "config.h" - +#include "json-test-utils.h" #include <stdlib.h> -#include <stdio.h> - -#include <glib.h> - -#include <json-glib/json-glib.h> static const gchar *test_empty_string = ""; static const gchar *test_empty_array_string = "[ ]"; @@ -38,13 +32,13 @@ verify_string_value (JsonNode *node) static void verify_double_value (JsonNode *node) { - g_assert_cmpfloat (10.2e3, ==, json_node_get_double (node)); + json_assert_fuzzy_equals (10.2e3, json_node_get_double (node), 0.1); } static void verify_negative_double_value (JsonNode *node) { - g_assert_cmpfloat (-3.14, ==, json_node_get_double (node)); + json_assert_fuzzy_equals (-3.14, json_node_get_double (node), 0.01); } static const struct { |