[glib: 1/2] gobject/tests/param: Add unit test for handling invalid NULL param spec




commit 80cf66034b94496237f7cdfdc66fecbab8b872cd
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Mon Oct 10 20:55:24 2022 +0200

    gobject/tests/param: Add unit test for handling invalid NULL param spec
    
    This was fixed by !2921 but there was no test with the MR, so add one.

 gobject/tests/param.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/gobject/tests/param.c b/gobject/tests/param.c
index 1e037e6d36..08bc80ffff 100644
--- a/gobject/tests/param.c
+++ b/gobject/tests/param.c
@@ -349,6 +349,25 @@ test_param_spec_param (void)
   g_param_spec_unref (wrapped_pspec_uint);
 }
 
+static void
+test_param_spec_null_param (void)
+{
+  GParamSpec *pspec;
+  GValue value = G_VALUE_INIT;
+
+  pspec = g_param_spec_param ("param", NULL, NULL,
+                              G_TYPE_PARAM_POINTER, G_PARAM_READWRITE);
+
+  g_assert_cmpstr (g_param_spec_get_name (pspec), ==, "param");
+
+  g_value_init (&value, G_TYPE_PARAM_POINTER);
+  g_assert_false (g_param_value_is_valid (pspec, &value));
+  g_assert_false (g_param_value_validate (pspec, &value));
+
+  g_value_unset (&value);
+  g_param_spec_unref (pspec);
+}
+
 static void
 test_param_spec_string (void)
 {
@@ -1654,6 +1673,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/paramspec/double", test_param_spec_double);
   g_test_add_func ("/paramspec/unichar", test_param_spec_unichar);
   g_test_add_func ("/paramspec/param", test_param_spec_param);
+  g_test_add_func ("/paramspec/null-param", test_param_spec_null_param);
   g_test_add_func ("/paramspec/string", test_param_spec_string);
   g_test_add_func ("/paramspec/override", test_param_spec_override);
   g_test_add_func ("/paramspec/gtype", test_param_spec_gtype);


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