summaryrefslogtreecommitdiff
path: root/json-glib/tests/node-test.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@openedhand.com>2008-03-01 19:30:41 +0000
committerEmmanuele Bassi <ebassi@openedhand.com>2008-03-01 19:30:41 +0000
commite4be0d896359cc1d0ba99dd81a66855389ebd5df (patch)
tree281ffbfae9666a3b6c7d08d7bbdbfa51137e0bd2 /json-glib/tests/node-test.c
parent3a9ec8f1ca9bf525875c3fbfaf1ab2f3c708bf36 (diff)
downloadjson-glib-e4be0d896359cc1d0ba99dd81a66855389ebd5df.tar.gz
Add initial test suite support using GLib's new testing framework
GLib 2.15 added a new test unit framework to the GLib API. It allows integrating unit testing into GLib and GObject based libraries and applications. It requires a specially crafter Makefile holding a set of declarations, which must be included into the project own Makefile templates; then it is possible to drop tests inside a subdirectory, which will be built after the library or application, and executed upon "make check". At the moment, there is a simple test for the JsonNode API, with a single unit for the "null" node type.
Diffstat (limited to 'json-glib/tests/node-test.c')
-rw-r--r--json-glib/tests/node-test.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/json-glib/tests/node-test.c b/json-glib/tests/node-test.c
new file mode 100644
index 0000000..05bd169
--- /dev/null
+++ b/json-glib/tests/node-test.c
@@ -0,0 +1,27 @@
+#include <glib/gtestutils.h>
+#include <json-glib/json-types.h>
+#include <string.h>
+
+static void
+test_null (void)
+{
+ JsonNode *node = json_node_new (JSON_NODE_NULL);
+
+ g_assert_cmpint (node->type, ==, JSON_NODE_NULL);
+ g_assert_cmpint (json_node_get_value_type (node), ==, G_TYPE_INVALID);
+ g_assert_cmpstr (json_node_type_name (node), ==, "NULL");
+
+ json_node_free (node);
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ g_type_init ();
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/nodes/null-node", test_null);
+
+ return g_test_run ();
+}