timeloop-closure: Fix leaks in test
[platform/upstream/glib.git] / tests / gobject / paramspec-test.c
index 6de850f..5b2e834 100644 (file)
@@ -36,7 +36,7 @@ static void
 test_param_spec_char (void)
 {
   GParamSpec *pspec;
-  GValue value = { 0, };
+  GValue value = G_VALUE_INIT;
   gboolean modified;
  
   pspec = g_param_spec_char ("char", "nick", "blurb",
@@ -67,6 +67,22 @@ test_param_spec_char (void)
   modified = g_param_value_validate (pspec, &value);
   g_assert (modified && g_value_get_char (&value) == 40);
 
+  g_value_set_schar (&value, 0);
+  modified = g_param_value_validate (pspec, &value);
+  g_assert (modified && g_value_get_schar (&value) == 20);
+
+  g_value_set_schar (&value, 20);
+  modified = g_param_value_validate (pspec, &value);
+  g_assert (!modified && g_value_get_schar (&value) == 20);
+
+  g_value_set_schar (&value, 40);
+  modified = g_param_value_validate (pspec, &value);
+  g_assert (!modified && g_value_get_schar (&value) == 40);
+
+  g_value_set_schar (&value, 60);
+  modified = g_param_value_validate (pspec, &value);
+  g_assert (modified && g_value_get_schar (&value) == 40);
+
   g_param_spec_unref (pspec);
 }
 
@@ -74,7 +90,7 @@ static void
 test_param_spec_string (void)
 {
   GParamSpec *pspec;
-  GValue value = { 0, };
+  GValue value = G_VALUE_INIT;
   gboolean modified;
 
   pspec = g_param_spec_string ("string", "nick", "blurb",
@@ -146,7 +162,7 @@ static void
 test_param_spec_override (void)
 {
   GParamSpec *ospec, *pspec;
-  GValue value = { 0, };
+  GValue value = G_VALUE_INIT;
   gboolean modified;
  
   ospec = g_param_spec_char ("char", "nick", "blurb",
@@ -180,13 +196,14 @@ test_param_spec_override (void)
   g_assert (modified && g_value_get_char (&value) == 40);
 
   g_param_spec_unref (pspec);
+  g_param_spec_unref (ospec);
 }
 
 static void
 test_param_spec_gtype (void)
 {
   GParamSpec *pspec;
-  GValue value = { 0, };
+  GValue value = G_VALUE_INIT;
   gboolean modified;
   
   pspec = g_param_spec_gtype ("gtype", "nick", "blurb",
@@ -204,13 +221,15 @@ test_param_spec_gtype (void)
   g_value_set_gtype (&value, G_TYPE_PARAM_INT);
   modified = g_param_value_validate (pspec, &value);
   g_assert (!modified && g_value_get_gtype (&value) == G_TYPE_PARAM_INT);
+
+  g_param_spec_unref (pspec);
 }
 
 static void
 test_param_spec_variant (void)
 {
   GParamSpec *pspec;
-  GValue value = { 0, };
+  GValue value = G_VALUE_INIT;
   gboolean modified;
 
   pspec = g_param_spec_variant ("variant", "nick", "blurb",
@@ -240,7 +259,6 @@ int
 main (int argc, char *argv[])
 {
   g_test_init (&argc, &argv, NULL);
-  g_type_init ();
 
   g_test_add_func ("/paramspec/char", test_param_spec_char);
   g_test_add_func ("/paramspec/string", test_param_spec_string);