[json-glib] tests: Improve coverage
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [json-glib] tests: Improve coverage
- Date: Fri, 26 Oct 2012 10:14:41 +0000 (UTC)
commit b0c087d1cc88938bc7e6bb1350a175b1ed103e62
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri Oct 26 11:06:26 2012 +0100
tests: Improve coverage
json-glib/tests/array.c | 30 ++++++++++++++++++++++++++++++
json-glib/tests/object.c | 13 +++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/json-glib/tests/array.c b/json-glib/tests/array.c
index ce8242b..eab67d6 100644
--- a/json-glib/tests/array.c
+++ b/json-glib/tests/array.c
@@ -29,6 +29,36 @@ test_add_element (void)
node = json_array_get_element (array, 0);
g_assert_cmpint (JSON_NODE_TYPE (node), ==, JSON_NODE_NULL);
+ g_assert (json_array_get_null_element (array, 0));
+
+ json_array_add_int_element (array, 42);
+ g_assert_cmpint (json_array_get_length (array), ==, 2);
+ g_assert_cmpint (json_array_get_int_element (array, 1), ==, 42);
+
+ json_array_add_double_element (array, 3.14);
+ g_assert_cmpint (json_array_get_length (array), ==, 3);
+ g_assert_cmpfloat (json_array_get_double_element (array, 2), ==, 3.14);
+
+ json_array_add_boolean_element (array, TRUE);
+ g_assert_cmpint (json_array_get_length (array), ==, 4);
+ g_assert (json_array_get_boolean_element (array, 3));
+
+ json_array_add_string_element (array, "Hello");
+ g_assert_cmpint (json_array_get_length (array), ==, 5);
+ g_assert_cmpstr (json_array_get_string_element (array, 4), ==, "Hello");
+
+ json_array_add_string_element (array, NULL);
+ g_assert_cmpint (json_array_get_length (array), ==, 6);
+ g_assert (json_array_get_string_element (array, 5) == NULL);
+ g_assert (json_array_get_element (array, 5) != NULL);
+ g_assert (json_array_get_null_element (array, 5));
+
+ json_array_add_array_element (array, NULL);
+ g_assert (json_array_get_array_element (array, 6) == NULL);
+ g_assert (json_array_get_null_element (array, 6));
+
+ json_array_add_object_element (array, json_object_new ());
+ g_assert (json_array_get_object_element (array, 7) != NULL);
json_array_unref (array);
}
diff --git a/json-glib/tests/object.c b/json-glib/tests/object.c
index 513e6b8..80ed739 100644
--- a/json-glib/tests/object.c
+++ b/json-glib/tests/object.c
@@ -58,6 +58,12 @@ test_set_member (void)
json_object_set_string_member (object, "String", "Goodbye");
g_assert_cmpstr (json_object_get_string_member (object, "String"), ==, "Goodbye");
+ json_object_set_array_member (object, "Array", NULL);
+ g_assert_cmpint (JSON_NODE_TYPE (json_object_get_member (object, "Array")), ==, JSON_NODE_NULL);
+
+ json_object_set_object_member (object, "Object", NULL);
+ g_assert (json_object_get_null_member (object, "Object") == TRUE);
+
json_object_unref (object);
}
@@ -146,6 +152,13 @@ test_empty_member (void)
g_assert (json_object_has_member (object, "null"));
g_assert (json_object_get_string_member (object, "null") == NULL);
+ json_object_set_null_member (object, "array");
+ g_assert (json_object_get_array_member (object, "array") == NULL);
+
+ json_object_set_object_member (object, "object", NULL);
+ g_assert (json_object_get_member (object, "object") != NULL);
+ g_assert (json_object_get_object_member (object, "object") == NULL);
+
json_object_unref (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]