gvalue-test: Fix leaks in test
[platform/upstream/glib.git] / tests / gobject / gvalue-test.c
index bec3c64..b928d8b 100644 (file)
@@ -37,8 +37,8 @@ static void
 test_enum_transformation (void)
 { 
   GType type; 
-  GValue orig = { 0, };
-  GValue xform = { 0, }; 
+  GValue orig = G_VALUE_INIT;
+  GValue xform = G_VALUE_INIT;
   GEnumValue values[] = { {0,"0","0"}, {1,"1","1"}}; 
   
  type = g_enum_register_static ("TestEnum", values); 
@@ -93,8 +93,8 @@ static void
 test_gtype_value (void)
 {
   GType type;
-  GValue value = { 0, };
-  GValue copy = { 0, };
+  GValue value = G_VALUE_INIT;
+  GValue copy = G_VALUE_INIT;
 
   g_value_init (&value, G_TYPE_GTYPE);
 
@@ -141,7 +141,7 @@ lcopy (GValue *value, ...)
 static void
 test_collection (void)
 {
-  GValue value = { 0, };
+  GValue value = G_VALUE_INIT;
   gchar *error;
   
   g_value_init (&value, G_TYPE_CHAR);
@@ -234,7 +234,7 @@ test_collection (void)
 static void
 test_copying (void)
 {
-  GValue value = { 0, };
+  GValue value = G_VALUE_INIT;
   gchar *error;
 
   {
@@ -355,6 +355,7 @@ test_copying (void)
     error = lcopy (&value, &c);
     g_assert (error == NULL);
     g_assert (strcmp (c, "string ?") == 0);
+    g_free (c);
   }  
 
   {
@@ -380,6 +381,7 @@ test_copying (void)
     g_assert (g_variant_is_of_type (c, G_VARIANT_TYPE ("u")));
     g_assert_cmpuint (g_variant_get_uint32 (c), ==, 42);
     g_variant_unref (c);
+    g_value_unset (&value);
   }
 }
 
@@ -388,7 +390,6 @@ int
 main (int argc, char *argv[])
 {
   g_test_init (&argc, &argv, NULL);
-  g_type_init ();
 
   g_test_add_func ("/gvalue/enum-transformation", test_enum_transformation);
   g_test_add_func ("/gvalue/gtype", test_gtype_value);