[json-glib] tests/parser: Check negative numeric values



commit 2dec8604ee58571ccc902aeb27004adf6a436ff5
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Oct 26 10:15:35 2012 +0100

    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 files changed, 15 insertions(+), 1 deletions(-)
---
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
@@ -20,6 +20,12 @@ verify_int_value (JsonNode *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)
 {
   g_assert_cmpint (TRUE, ==, json_node_get_boolean (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 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]