[json-glib] tests/serialize-complex: Modify the instance



commit 8c424cc133575282371bff8d17295662267049e9
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Wed Jun 1 12:48:20 2011 +0100

    tests/serialize-complex: Modify the instance
    
    Do not test the defaults: create the GObject instance with different
    values than the default ones from the GParamSpec.

 json-glib/tests/serialize-complex.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/json-glib/tests/serialize-complex.c b/json-glib/tests/serialize-complex.c
index f577761..86eca85 100644
--- a/json-glib/tests/serialize-complex.c
+++ b/json-glib/tests/serialize-complex.c
@@ -214,7 +214,7 @@ test_object_class_init (TestObjectClass *klass)
   g_object_class_install_property (gobject_class,
                                    PROP_BAR,
                                    g_param_spec_boolean ("bar", "Bar", "Bar",
-                                                         FALSE,
+                                                         TRUE,
                                                          G_PARAM_READWRITE));
   g_object_class_install_property (gobject_class,
                                    PROP_BAZ,
@@ -242,7 +242,11 @@ test_object_init (TestObject *object)
 static void
 test_serialize (void)
 {
-  TestObject *obj = g_object_new (TEST_TYPE_OBJECT, NULL);
+  TestObject *obj = g_object_new (TEST_TYPE_OBJECT,
+                                  "foo", 47,
+                                  "bar", FALSE,
+                                  "baz", "Hello, World!",
+                                  NULL);
   JsonParser *parser = json_parser_new ();
   GError *error = NULL;
   JsonObject *object;
@@ -264,16 +268,12 @@ test_serialize (void)
   g_assert (json_node_get_node_type (node) == JSON_NODE_OBJECT);
 
   object = json_node_get_object (node);
-  g_assert_cmpint (json_object_get_int_member (object, "foo"), ==, 42);
-  g_assert (json_object_get_boolean_member (object, "bar"));
-  g_assert_cmpstr (json_object_get_string_member (object, "baz"), ==, "Test");
+  g_assert_cmpint (json_object_get_int_member (object, "foo"), ==, 47);
+  g_assert (!json_object_get_boolean_member (object, "bar"));
+  g_assert_cmpstr (json_object_get_string_member (object, "baz"), ==, "Hello, World!");
 
-  node = json_object_get_member (object, "blah");
-  g_assert (json_node_get_node_type (node) == JSON_NODE_OBJECT);
-
-  object = json_node_get_object (node);
-  g_assert_cmpint (json_object_get_int_member (object, "foo"), ==, 42);
-  g_assert (json_object_get_boolean_member (object, "bar"));
+  /* blah is read-only */
+  g_assert (json_object_has_member (object, "blah"));
 
   g_free (data);
   g_object_unref (parser);



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