From 2dec8604ee58571ccc902aeb27004adf6a436ff5 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 26 Oct 2012 10:15:35 +0100 Subject: tests/parser: Check negative numeric values This is the positive equivalent of the test case inside the invalid test unit. --- json-glib/tests/parser.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/json-glib/tests/parser.c b/json-glib/tests/parser.c index 2a1ee58..3b1b049 100644 --- a/json-glib/tests/parser.c +++ b/json-glib/tests/parser.c @@ -19,6 +19,12 @@ verify_int_value (JsonNode *node) g_assert_cmpint (42, ==, json_node_get_int (node)); } +static void +verify_negative_int_value (JsonNode *node) +{ + g_assert_cmpint (-1, ==, json_node_get_int (node)); +} + static void verify_boolean_value (JsonNode *node) { @@ -37,6 +43,12 @@ verify_double_value (JsonNode *node) g_assert_cmpfloat (10.2e3, ==, json_node_get_double (node)); } +static void +verify_negative_double_value (JsonNode *node) +{ + g_assert_cmpfloat (-3.14, ==, json_node_get_double (node)); +} + static const struct { const gchar *str; JsonNodeType type; @@ -47,7 +59,9 @@ static const struct { { "42", JSON_NODE_VALUE, G_TYPE_INT64, verify_int_value }, { "true", JSON_NODE_VALUE, G_TYPE_BOOLEAN, verify_boolean_value }, { "\"string\"", JSON_NODE_VALUE, G_TYPE_STRING, verify_string_value }, - { "10.2e3", JSON_NODE_VALUE, G_TYPE_DOUBLE, verify_double_value } + { "10.2e3", JSON_NODE_VALUE, G_TYPE_DOUBLE, verify_double_value }, + { "-1", JSON_NODE_VALUE, G_TYPE_INT64, verify_negative_int_value }, + { "-3.14", JSON_NODE_VALUE, G_TYPE_DOUBLE, verify_negative_double_value }, }; static const struct { -- cgit v1.2.1