tests: Fix various unsigned/signed comparisons in gobject tests

Fix all the instances where `-Wsign-conversion` was pointing out that
`g_assert_cmpint()` had been used on unsigned inputs, or vice-versa.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3405
This commit is contained in:
Philip Withnall 2025-04-11 15:13:36 +01:00
parent 752c0787d6
commit b3ebef609f
No known key found for this signature in database
GPG Key ID: C5C42CFB268637CA
8 changed files with 21 additions and 21 deletions

View File

@ -100,7 +100,7 @@ test_object_test_iface_init (gpointer giface,
TestIfaceClass *iface = giface;
g_assert (iface_data == GUINT_TO_POINTER (42));
g_assert_cmpint (G_TYPE_FROM_INTERFACE (iface), ==, TEST_TYPE_IFACE);
g_assert_cmpuint (G_TYPE_FROM_INTERFACE (iface), ==, TEST_TYPE_IFACE);
/* assert iface_base_init() was already called */
g_assert_cmpuint (iface_base_init_count, >, 0);

View File

@ -166,7 +166,7 @@ check_flags_validation (void)
/* This check will fail in case of gint -> glong conversion
* in value_flags_enum_collect_value() */
g_assert_cmpint (flag_read, ==, flag_set);
g_assert_cmpuint (flag_read, ==, flag_set);
g_object_unref (test);
}

View File

@ -195,13 +195,13 @@ test_param_spec_ulong (void)
g_param_value_set_default (pspec, &value);
g_assert_true (G_VALUE_TYPE (&value) == G_TYPE_ULONG);
g_assert_cmpint (g_value_get_ulong (&value), ==, 30);
g_assert_cmpuint (g_value_get_ulong (&value), ==, 30);
g_assert_true (g_param_value_defaults (pspec, &value));
g_value_set_ulong (&value, 0);
g_assert_false (g_param_value_is_valid (pspec, &value));
g_assert_true (g_param_value_validate (pspec, &value));
g_assert_cmpint (g_value_get_ulong (&value), ==, 20);
g_assert_cmpuint (g_value_get_ulong (&value), ==, 20);
g_param_spec_unref (pspec);
}
@ -239,13 +239,13 @@ test_param_spec_uint64 (void)
g_param_value_set_default (pspec, &value);
g_assert_true (G_VALUE_TYPE (&value) == G_TYPE_UINT64);
g_assert_cmpint (g_value_get_uint64 (&value), ==, 30);
g_assert_cmpuint (g_value_get_uint64 (&value), ==, 30);
g_assert_true (g_param_value_defaults (pspec, &value));
g_value_set_uint64 (&value, 0);
g_assert_false (g_param_value_is_valid (pspec, &value));
g_assert_true (g_param_value_validate (pspec, &value));
g_assert_cmpint (g_value_get_uint64 (&value), ==, 20);
g_assert_cmpuint (g_value_get_uint64 (&value), ==, 20);
g_param_spec_unref (pspec);
}
@ -522,12 +522,12 @@ test_param_spec_gtype (void)
g_value_set_gtype (&value, G_TYPE_INT);
g_assert_false (g_param_value_is_valid (pspec, &value));
g_assert_true (g_param_value_validate (pspec, &value));
g_assert_cmpint (g_value_get_gtype (&value), ==, G_TYPE_PARAM);
g_assert_cmpuint (g_value_get_gtype (&value), ==, G_TYPE_PARAM);
g_value_set_gtype (&value, G_TYPE_PARAM_INT);
g_assert_true (g_param_value_is_valid (pspec, &value));
g_assert_false (g_param_value_validate (pspec, &value));
g_assert_cmpint (g_value_get_gtype (&value), ==, G_TYPE_PARAM_INT);
g_assert_cmpuint (g_value_get_gtype (&value), ==, G_TYPE_PARAM_INT);
g_param_spec_unref (pspec);
}
@ -834,7 +834,7 @@ test_value_transform (void)
* https://bugzilla.gnome.org/show_bug.cgi?id=659870
* for why it is broken.
*/
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpuint, char, 124)
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, char, 124)
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, -124)
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, 124)

View File

@ -48,10 +48,10 @@ test_type_query (void)
GTypeQuery query;
g_type_query (G_TYPE_ENUM, &query);
g_assert_cmpint (query.type, ==, G_TYPE_ENUM);
g_assert_cmpuint (query.type, ==, G_TYPE_ENUM);
g_assert_cmpstr (query.type_name, ==, "GEnum");
g_assert_cmpint (query.class_size, ==, sizeof (GEnumClass));
g_assert_cmpint (query.instance_size, ==, 0);
g_assert_cmpuint (query.class_size, ==, sizeof (GEnumClass));
g_assert_cmpuint (query.instance_size, ==, 0);
}
typedef struct _MyObject MyObject;

View File

@ -590,7 +590,7 @@ test_signal_group_properties (void)
"target", &target,
"target-type", &gtype,
NULL);
g_assert_cmpint (gtype, ==, signal_target_get_type ());
g_assert_cmpuint (gtype, ==, signal_target_get_type ());
g_assert_null (target);
target = g_object_new (signal_target_get_type (), NULL);

View File

@ -1509,7 +1509,7 @@ test_introspection (void)
g_assert_cmpstr (query.signal_name, ==, "simple");
g_assert_true (query.itype == test_get_type ());
g_assert_cmpint (query.signal_flags, ==, G_SIGNAL_RUN_LAST);
g_assert_cmpint (query.return_type, ==, G_TYPE_NONE);
g_assert_cmpuint (query.return_type, ==, G_TYPE_NONE);
g_assert_cmpuint (query.n_params, ==, 0);
g_free (ids);
@ -2074,11 +2074,11 @@ test_weak_ref_disconnect (void)
&state,
(GClosureNotify) weak_ref_disconnect_notify,
0);
g_assert_cmpint (state.handler, >, 0);
g_assert_cmpuint (state.handler, >, 0);
g_object_unref (test);
g_assert_cmpint (state.handler, ==, 0);
g_assert_cmpuint (state.handler, ==, 0);
g_assert_null (g_weak_ref_get (&state.wr));
g_weak_ref_clear (&state.wr);
}

View File

@ -118,10 +118,10 @@ test_interface_prerequisite (void)
g_free (prereqs);
g_assert_cmpint (g_type_interface_instantiatable_prerequisite (baa_get_type ()), ==, G_TYPE_INVALID);
g_assert_cmpint (g_type_interface_instantiatable_prerequisite (boo_get_type ()), ==, G_TYPE_INVALID);
g_assert_cmpuint (g_type_interface_instantiatable_prerequisite (baa_get_type ()), ==, G_TYPE_INVALID);
g_assert_cmpuint (g_type_interface_instantiatable_prerequisite (boo_get_type ()), ==, G_TYPE_INVALID);
g_assert_cmpint (g_type_interface_instantiatable_prerequisite (bozo_get_type ()), ==, G_TYPE_INITIALLY_UNOWNED);
g_assert_cmpuint (g_type_interface_instantiatable_prerequisite (bozo_get_type ()), ==, G_TYPE_INITIALLY_UNOWNED);
}
typedef struct {

View File

@ -72,7 +72,7 @@ test_enum_transformation (void)
memset (&xform, 0, sizeof (GValue));
g_value_init (&xform, G_TYPE_ULONG);
g_value_transform (&orig, &xform);
g_assert_cmpint (g_value_get_ulong (&xform), ==, 1);
g_assert_cmpuint (g_value_get_ulong (&xform), ==, 1);
memset (&xform, 0, sizeof (GValue));
g_value_init (&xform, G_TYPE_INT64);
@ -82,7 +82,7 @@ test_enum_transformation (void)
memset (&xform, 0, sizeof (GValue));
g_value_init (&xform, G_TYPE_UINT64);
g_value_transform (&orig, &xform);
g_assert_cmpint (g_value_get_uint64 (&xform), ==, 1);
g_assert_cmpuint (g_value_get_uint64 (&xform), ==, 1);
}