From 1ed199a881be99b3ce281418eee6d14c8c4b3ac7 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 12 Apr 2024 18:44:04 +0100 Subject: [PATCH] tests: Use g_assert_*() rather than g_assert() in gdbus-export tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It won’t get compiled out with `G_DISABLE_ASSERT`. Signed-off-by: Philip Withnall --- gio/tests/gdbus-export.c | 254 +++++++++++++++++++-------------------- 1 file changed, 127 insertions(+), 127 deletions(-) diff --git a/gio/tests/gdbus-export.c b/gio/tests/gdbus-export.c index f7efe8c03..af88dc442 100644 --- a/gio/tests/gdbus-export.c +++ b/gio/tests/gdbus-export.c @@ -336,7 +336,7 @@ introspect_callback (GDBusProxy *proxy, res, &error); g_assert_no_error (error); - g_assert (result != NULL); + g_assert_nonnull (result); g_variant_get (result, "(s)", xml_data); g_variant_unref (result); @@ -381,7 +381,7 @@ get_nodes_at (GDBusConnection *c, NULL, &error); g_assert_no_error (error); - g_assert (proxy != NULL); + g_assert_nonnull (proxy); /* do this async to avoid libdbus-1 deadlocks */ xml_data = NULL; @@ -394,11 +394,11 @@ get_nodes_at (GDBusConnection *c, (GAsyncReadyCallback) introspect_callback, &xml_data); g_main_loop_run (loop); - g_assert (xml_data != NULL); + g_assert_nonnull (xml_data); node_info = g_dbus_node_info_new_for_xml (xml_data, &error); g_assert_no_error (error); - g_assert (node_info != NULL); + g_assert_nonnull (node_info); p = g_ptr_array_new (); for (n = 0; node_info->nodes != NULL && node_info->nodes[n] != NULL; n++) @@ -440,7 +440,7 @@ has_interface (GDBusConnection *c, NULL, &error); g_assert_no_error (error); - g_assert (proxy != NULL); + g_assert_nonnull (proxy); /* do this async to avoid libdbus-1 deadlocks */ xml_data = NULL; @@ -453,11 +453,11 @@ has_interface (GDBusConnection *c, (GAsyncReadyCallback) introspect_callback, &xml_data); g_main_loop_run (loop); - g_assert (xml_data != NULL); + g_assert_nonnull (xml_data); node_info = g_dbus_node_info_new_for_xml (xml_data, &error); g_assert_no_error (error); - g_assert (node_info != NULL); + g_assert_nonnull (node_info); ret = (g_dbus_node_info_lookup_interface (node_info, interface_name) != NULL); @@ -489,7 +489,7 @@ count_interfaces (GDBusConnection *c, NULL, &error); g_assert_no_error (error); - g_assert (proxy != NULL); + g_assert_nonnull (proxy); /* do this async to avoid libdbus-1 deadlocks */ xml_data = NULL; @@ -502,11 +502,11 @@ count_interfaces (GDBusConnection *c, (GAsyncReadyCallback) introspect_callback, &xml_data); g_main_loop_run (loop); - g_assert (xml_data != NULL); + g_assert_nonnull (xml_data); node_info = g_dbus_node_info_new_for_xml (xml_data, &error); g_assert_no_error (error); - g_assert (node_info != NULL); + g_assert_nonnull (node_info); ret = 0; while (node_info->interfaces != NULL && node_info->interfaces[ret] != NULL) @@ -532,7 +532,7 @@ dyna_create_callback (GDBusProxy *proxy, res, &error); g_assert_no_error (error); - g_assert (result != NULL); + g_assert_nonnull (result); g_variant_unref (result); g_main_loop_quit (loop); @@ -560,7 +560,7 @@ dyna_create (GDBusConnection *c, NULL, &error); g_assert_no_error (error); - g_assert (proxy != NULL); + g_assert_nonnull (proxy); /* do this async to avoid libdbus-1 deadlocks */ g_dbus_proxy_call (proxy, @@ -773,7 +773,7 @@ test_dispatch_thread_func (gpointer user_data) "org.example.Foo", NULL, &error); - g_assert (foo_proxy != NULL); + g_assert_nonnull (foo_proxy); /* generic interfaces */ error = NULL; @@ -785,7 +785,7 @@ test_dispatch_thread_func (gpointer user_data) NULL, &error); g_assert_no_error (error); - g_assert (value != NULL); + g_assert_nonnull (value); g_variant_unref (value); /* user methods */ @@ -798,8 +798,8 @@ test_dispatch_thread_func (gpointer user_data) NULL, &error); g_assert_no_error (error); - g_assert (value != NULL); - g_assert (g_variant_is_of_type (value, G_VARIANT_TYPE ("(s)"))); + g_assert_nonnull (value); + g_assert_true (g_variant_is_of_type (value, G_VARIANT_TYPE ("(s)"))); g_variant_get (value, "(&s)", &value_str); g_assert_cmpstr (value_str, ==, "You passed the string 'winwinwin'. Jolly good!"); g_variant_unref (value); @@ -815,7 +815,7 @@ test_dispatch_thread_func (gpointer user_data) g_assert_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR); g_assert_cmpstr (error->message, ==, "GDBus.Error:org.example.SomeError: How do you like them apples, buddy!"); g_error_free (error); - g_assert (value == NULL); + g_assert_null (value); error = NULL; value = g_dbus_proxy_call_sync (foo_proxy, @@ -828,7 +828,7 @@ test_dispatch_thread_func (gpointer user_data) g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS); g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: Type of message, “(s)”, does not match expected type “()”"); g_error_free (error); - g_assert (value == NULL); + g_assert_null (value); error = NULL; value = g_dbus_proxy_call_sync (foo_proxy, @@ -841,7 +841,7 @@ test_dispatch_thread_func (gpointer user_data) g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD); g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such method “NonExistantMethod”"); g_error_free (error); - g_assert (value == NULL); + g_assert_null (value); error = NULL; value = g_dbus_proxy_call_sync (foo_proxy, @@ -853,7 +853,7 @@ test_dispatch_thread_func (gpointer user_data) &error); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD); g_error_free (error); - g_assert (value == NULL); + g_assert_null (value); /* user properties */ error = NULL; @@ -867,10 +867,10 @@ test_dispatch_thread_func (gpointer user_data) NULL, &error); g_assert_no_error (error); - g_assert (value != NULL); - g_assert (g_variant_is_of_type (value, G_VARIANT_TYPE ("(v)"))); + g_assert_nonnull (value); + g_assert_true (g_variant_is_of_type (value, G_VARIANT_TYPE ("(v)"))); g_variant_get (value, "(v)", &inner); - g_assert (g_variant_is_of_type (inner, G_VARIANT_TYPE_STRING)); + g_assert_true (g_variant_is_of_type (inner, G_VARIANT_TYPE_STRING)); g_assert_cmpstr (g_variant_get_string (inner, NULL), ==, "Property 'PropertyUno' Is What It Is!"); g_variant_unref (value); g_variant_unref (inner); @@ -885,7 +885,7 @@ test_dispatch_thread_func (gpointer user_data) -1, NULL, &error); - g_assert (value == NULL); + g_assert_null (value); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS); g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: No such property “ThisDoesntExist”"); g_error_free (error); @@ -900,7 +900,7 @@ test_dispatch_thread_func (gpointer user_data) -1, NULL, &error); - g_assert (value == NULL); + g_assert_null (value); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS); g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: Property “NotReadable” is not readable"); g_error_free (error); @@ -916,14 +916,14 @@ test_dispatch_thread_func (gpointer user_data) -1, NULL, &error); - g_assert (value == NULL); + g_assert_null (value); if (args->check_remote_errors) { /* _with_closures variant doesn't support customizing error data. */ g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_FILE_INVALID); g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.Spawn.FileInvalid: Returning some error instead of writing the value ''But Writable you are!'' to the property 'NotReadable'"); } - g_assert (error != NULL && error->domain == G_DBUS_ERROR); + g_assert_true (error != NULL && error->domain == G_DBUS_ERROR); g_error_free (error); error = NULL; @@ -937,7 +937,7 @@ test_dispatch_thread_func (gpointer user_data) -1, NULL, &error); - g_assert (value == NULL); + g_assert_null (value); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS); g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: Property “NotWritable” is not writable"); g_error_free (error); @@ -952,8 +952,8 @@ test_dispatch_thread_func (gpointer user_data) NULL, &error); g_assert_no_error (error); - g_assert (value != NULL); - g_assert (g_variant_is_of_type (value, G_VARIANT_TYPE ("(a{sv})"))); + g_assert_nonnull (value); + g_assert_true (g_variant_is_of_type (value, G_VARIANT_TYPE ("(a{sv})"))); s = g_variant_print (value, TRUE); g_assert_cmpstr (s, ==, "({'PropertyUno': <\"Property 'PropertyUno' Is What It Is!\">, 'NotWritable': <\"Property 'NotWritable' Is What It Is!\">},)"); g_free (s); @@ -1015,7 +1015,7 @@ test_object_registration (void) error = NULL; c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); g_assert_no_error (error); - g_assert (c != NULL); + g_assert_nonnull (c); registration_id = g_dbus_connection_register_object (c, "/foo/boss", @@ -1025,7 +1025,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); boss_foo_reg_id = registration_id; num_successful_registrations++; @@ -1037,7 +1037,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); boss_bar_reg_id = registration_id; num_successful_registrations++; @@ -1049,7 +1049,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); worker1_foo_reg_id = registration_id; num_successful_registrations++; @@ -1061,7 +1061,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); worker1p1_foo_reg_id = registration_id; num_successful_registrations++; @@ -1073,7 +1073,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); worker2_bar_reg_id = registration_id; num_successful_registrations++; @@ -1085,7 +1085,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); intern1_foo_reg_id = registration_id; num_successful_registrations++; @@ -1098,7 +1098,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); intern2_bar_reg_id = registration_id; num_successful_registrations++; @@ -1112,10 +1112,10 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS); - g_assert (!g_dbus_error_is_remote_error (error)); + g_assert_false (g_dbus_error_is_remote_error (error)); g_error_free (error); error = NULL; - g_assert (registration_id == 0); + g_assert_cmpuint (registration_id, ==, 0); g_assert_cmpint (data.num_unregistered_calls, ==, 1); num_failed_registrations++; @@ -1128,12 +1128,12 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); intern2_foo_reg_id = registration_id; num_successful_registrations++; /* unregister it via the id */ - g_assert (g_dbus_connection_unregister_object (c, registration_id)); + g_assert_true (g_dbus_connection_unregister_object (c, registration_id)); g_main_context_iteration (NULL, FALSE); g_assert_cmpint (data.num_unregistered_calls, ==, 2); intern2_foo_reg_id = 0; @@ -1147,7 +1147,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); intern2_foo_reg_id = registration_id; num_successful_registrations++; @@ -1159,7 +1159,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); intern3_bar_reg_id = registration_id; num_successful_registrations++; @@ -1172,7 +1172,7 @@ test_object_registration (void) on_subtree_unregistered, &error); g_assert_no_error (error); - g_assert (subtree_registration_id > 0); + g_assert_cmpuint (subtree_registration_id, >, 0); /* try registering it again.. this should fail */ registration_id = g_dbus_connection_register_subtree (c, "/foo/boss/executives", @@ -1182,14 +1182,14 @@ test_object_registration (void) on_subtree_unregistered, &error); g_assert_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS); - g_assert (!g_dbus_error_is_remote_error (error)); + g_assert_false (g_dbus_error_is_remote_error (error)); g_error_free (error); error = NULL; - g_assert (registration_id == 0); + g_assert_cmpuint (registration_id, ==, 0); g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 1); /* unregister it, then register it again */ - g_assert (g_dbus_connection_unregister_subtree (c, subtree_registration_id)); + g_assert_true (g_dbus_connection_unregister_subtree (c, subtree_registration_id)); g_main_context_iteration (NULL, FALSE); g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 2); subtree_registration_id = g_dbus_connection_register_subtree (c, @@ -1200,7 +1200,7 @@ test_object_registration (void) on_subtree_unregistered, &error); g_assert_no_error (error); - g_assert (subtree_registration_id > 0); + g_assert_cmpuint (subtree_registration_id, >, 0); /* try to register something under /foo/boss/executives - this should work * because registered subtrees and registered objects can coexist. @@ -1216,7 +1216,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); non_subtree_object_path_bar_reg_id = registration_id; num_successful_registrations++; registration_id = g_dbus_connection_register_object (c, @@ -1227,7 +1227,7 @@ test_object_registration (void) on_object_unregistered, &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); non_subtree_object_path_foo_reg_id = registration_id; num_successful_registrations++; @@ -1241,11 +1241,11 @@ test_object_registration (void) (GDestroyNotify)g_ptr_array_unref, &error); g_assert_no_error (error); - g_assert (dyna_subtree_registration_id > 0); + g_assert_cmpuint (dyna_subtree_registration_id, >, 0); /* First assert that we have no nodes in the dynamic subtree */ nodes = get_nodes_at (c, "/foo/dyna"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 0); g_strfreev (nodes); g_assert_cmpint (count_interfaces (c, "/foo/dyna"), ==, 4); @@ -1256,7 +1256,7 @@ test_object_registration (void) g_ptr_array_add (dyna_data, g_strdup ("cat")); g_ptr_array_add (dyna_data, g_strdup ("cheezburger")); nodes = get_nodes_at (c, "/foo/dyna"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 3); g_assert_cmpstr (nodes[0], ==, "cat"); g_assert_cmpstr (nodes[1], ==, "cheezburger"); @@ -1269,7 +1269,7 @@ test_object_registration (void) /* Call a non-existing object path and assert that it has been created */ dyna_create (c, "dynamicallycreated"); nodes = get_nodes_at (c, "/foo/dyna"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 4); g_assert_cmpstr (nodes[0], ==, "cat"); g_assert_cmpstr (nodes[1], ==, "cheezburger"); @@ -1282,14 +1282,14 @@ test_object_registration (void) * perverse that we round-trip to the bus to introspect ourselves ;-) */ nodes = get_nodes_at (c, "/"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 1); g_assert_cmpstr (nodes[0], ==, "foo"); g_strfreev (nodes); g_assert_cmpint (count_interfaces (c, "/"), ==, 0); nodes = get_nodes_at (c, "/foo"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 2); g_assert_cmpstr (nodes[0], ==, "boss"); g_assert_cmpstr (nodes[1], ==, "dyna"); @@ -1297,25 +1297,25 @@ test_object_registration (void) g_assert_cmpint (count_interfaces (c, "/foo"), ==, 0); nodes = get_nodes_at (c, "/foo/boss"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 5); - g_assert (g_strv_contains ((const gchar* const *) nodes, "worker1")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "worker1p1")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "worker2")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "interns")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "executives")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "worker1")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "worker1p1")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "worker2")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "interns")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "executives")); g_strfreev (nodes); /* any registered object always implement org.freedesktop.DBus.[Peer,Introspectable,Properties] */ g_assert_cmpint (count_interfaces (c, "/foo/boss"), ==, 5); - g_assert (has_interface (c, "/foo/boss", foo_interface_info.name)); - g_assert (has_interface (c, "/foo/boss", bar_interface_info.name)); + g_assert_true (has_interface (c, "/foo/boss", foo_interface_info.name)); + g_assert_true (has_interface (c, "/foo/boss", bar_interface_info.name)); /* check subtree nodes - we should have only non_subtree_object in /foo/boss/executives * because data.num_subtree_nodes is 0 */ nodes = get_nodes_at (c, "/foo/boss/executives"); - g_assert (nodes != NULL); - g_assert (g_strv_contains ((const gchar* const *) nodes, "non_subtree_object")); + g_assert_nonnull (nodes); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "non_subtree_object")); g_assert_cmpint (g_strv_length (nodes), ==, 1); g_strfreev (nodes); g_assert_cmpint (count_interfaces (c, "/foo/boss/executives"), ==, 0); @@ -1323,41 +1323,41 @@ test_object_registration (void) /* now change data.num_subtree_nodes and check */ data.num_subtree_nodes = 2; nodes = get_nodes_at (c, "/foo/boss/executives"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 5); - g_assert (g_strv_contains ((const gchar* const *) nodes, "non_subtree_object")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "vp0")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "vp1")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "evp0")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "evp1")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "non_subtree_object")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "vp0")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "vp1")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "evp0")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "evp1")); /* check that /foo/boss/executives/non_subtree_object is not handled by the * subtree handlers - we can do this because objects from subtree handlers * has exactly one interface and non_subtree_object has two */ g_assert_cmpint (count_interfaces (c, "/foo/boss/executives/non_subtree_object"), ==, 5); - g_assert (has_interface (c, "/foo/boss/executives/non_subtree_object", foo_interface_info.name)); - g_assert (has_interface (c, "/foo/boss/executives/non_subtree_object", bar_interface_info.name)); + g_assert_true (has_interface (c, "/foo/boss/executives/non_subtree_object", foo_interface_info.name)); + g_assert_true (has_interface (c, "/foo/boss/executives/non_subtree_object", bar_interface_info.name)); /* check that the vp and evp objects are handled by the subtree handlers */ g_assert_cmpint (count_interfaces (c, "/foo/boss/executives/vp0"), ==, 4); g_assert_cmpint (count_interfaces (c, "/foo/boss/executives/vp1"), ==, 4); g_assert_cmpint (count_interfaces (c, "/foo/boss/executives/evp0"), ==, 4); g_assert_cmpint (count_interfaces (c, "/foo/boss/executives/evp1"), ==, 4); - g_assert (has_interface (c, "/foo/boss/executives/vp0", foo_interface_info.name)); - g_assert (has_interface (c, "/foo/boss/executives/vp1", foo_interface_info.name)); - g_assert (has_interface (c, "/foo/boss/executives/evp0", bar_interface_info.name)); - g_assert (has_interface (c, "/foo/boss/executives/evp1", bar_interface_info.name)); + g_assert_true (has_interface (c, "/foo/boss/executives/vp0", foo_interface_info.name)); + g_assert_true (has_interface (c, "/foo/boss/executives/vp1", foo_interface_info.name)); + g_assert_true (has_interface (c, "/foo/boss/executives/evp0", bar_interface_info.name)); + g_assert_true (has_interface (c, "/foo/boss/executives/evp1", bar_interface_info.name)); g_strfreev (nodes); data.num_subtree_nodes = 3; nodes = get_nodes_at (c, "/foo/boss/executives"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 7); - g_assert (g_strv_contains ((const gchar* const *) nodes, "non_subtree_object")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "vp0")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "vp1")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "vp2")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "evp0")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "evp1")); - g_assert (g_strv_contains ((const gchar* const *) nodes, "evp2")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "non_subtree_object")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "vp0")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "vp1")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "vp2")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "evp0")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "evp1")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "evp2")); g_strfreev (nodes); /* This is to check that a bug (rather, class of bugs) in gdbusconnection.c's @@ -1367,7 +1367,7 @@ test_object_registration (void) * where /foo/boss/worker1 reported a child '1', is now fixed. */ nodes = get_nodes_at (c, "/foo/boss/worker1"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 0); g_strfreev (nodes); @@ -1388,26 +1388,26 @@ test_object_registration (void) /* check that unregistering the subtree handler works */ g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 2); - g_assert (g_dbus_connection_unregister_subtree (c, subtree_registration_id)); + g_assert_true (g_dbus_connection_unregister_subtree (c, subtree_registration_id)); g_main_context_iteration (NULL, FALSE); g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 3); nodes = get_nodes_at (c, "/foo/boss/executives"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 1); - g_assert (g_strv_contains ((const gchar* const *) nodes, "non_subtree_object")); + g_assert_true (g_strv_contains ((const gchar* const *) nodes, "non_subtree_object")); g_strfreev (nodes); - g_assert (g_dbus_connection_unregister_object (c, boss_foo_reg_id)); - g_assert (g_dbus_connection_unregister_object (c, boss_bar_reg_id)); - g_assert (g_dbus_connection_unregister_object (c, worker1_foo_reg_id)); - g_assert (g_dbus_connection_unregister_object (c, worker1p1_foo_reg_id)); - g_assert (g_dbus_connection_unregister_object (c, worker2_bar_reg_id)); - g_assert (g_dbus_connection_unregister_object (c, intern1_foo_reg_id)); - g_assert (g_dbus_connection_unregister_object (c, intern2_bar_reg_id)); - g_assert (g_dbus_connection_unregister_object (c, intern2_foo_reg_id)); - g_assert (g_dbus_connection_unregister_object (c, intern3_bar_reg_id)); - g_assert (g_dbus_connection_unregister_object (c, non_subtree_object_path_bar_reg_id)); - g_assert (g_dbus_connection_unregister_object (c, non_subtree_object_path_foo_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, boss_foo_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, boss_bar_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, worker1_foo_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, worker1p1_foo_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, worker2_bar_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, intern1_foo_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, intern2_bar_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, intern2_foo_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, intern3_bar_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, non_subtree_object_path_bar_reg_id)); + g_assert_true (g_dbus_connection_unregister_object (c, non_subtree_object_path_foo_reg_id)); g_main_context_iteration (NULL, FALSE); g_assert_cmpint (data.num_unregistered_calls, ==, num_successful_registrations + num_failed_registrations); @@ -1417,7 +1417,7 @@ test_object_registration (void) */ #if 0 nodes = get_nodes_at (c, "/"); - g_assert (nodes != NULL); + g_assert_nonnull (nodes); g_assert_cmpint (g_strv_length (nodes), ==, 0); g_strfreev (nodes); #endif @@ -1434,7 +1434,7 @@ test_object_registration_with_closures (void) error = NULL; c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); g_assert_no_error (error); - g_assert (c != NULL); + g_assert_nonnull (c); registration_id = g_dbus_connection_register_object_with_closures (c, "/foo/boss", @@ -1444,11 +1444,11 @@ test_object_registration_with_closures (void) g_cclosure_new (G_CALLBACK (foo_set_property), NULL, NULL), &error); g_assert_no_error (error); - g_assert (registration_id > 0); + g_assert_cmpuint (registration_id, >, 0); test_dispatch ("/foo/boss", FALSE); - g_assert (g_dbus_connection_unregister_object (c, registration_id)); + g_assert_true (g_dbus_connection_unregister_object (c, registration_id)); g_object_unref (c); } @@ -1495,7 +1495,7 @@ check_interfaces (GDBusConnection *c, NULL, &error); g_assert_no_error (error); - g_assert (proxy != NULL); + g_assert_nonnull (proxy); /* do this async to avoid libdbus-1 deadlocks */ xml_data = NULL; @@ -1508,13 +1508,13 @@ check_interfaces (GDBusConnection *c, (GAsyncReadyCallback) introspect_callback, &xml_data); g_main_loop_run (loop); - g_assert (xml_data != NULL); + g_assert_nonnull (xml_data); node_info = g_dbus_node_info_new_for_xml (xml_data, &error); g_assert_no_error (error); - g_assert (node_info != NULL); + g_assert_nonnull (node_info); - g_assert (node_info->interfaces != NULL); + g_assert_nonnull (node_info->interfaces); for (i = 0; node_info->interfaces[i]; i++) ; #if 0 if (g_strv_length ((gchar**)interfaces) != i - 1) @@ -1563,7 +1563,7 @@ test_registered_interfaces (void) error = NULL; c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); g_assert_no_error (error); - g_assert (c != NULL); + g_assert_nonnull (c); id1 = g_dbus_connection_register_object (c, "/test", @@ -1573,7 +1573,7 @@ test_registered_interfaces (void) NULL, &error); g_assert_no_error (error); - g_assert (id1 > 0); + g_assert_cmpuint (id1, >, 0); id2 = g_dbus_connection_register_object (c, "/test", (GDBusInterfaceInfo *) &test_interface_info2, @@ -1582,12 +1582,12 @@ test_registered_interfaces (void) NULL, &error); g_assert_no_error (error); - g_assert (id2 > 0); + g_assert_cmpuint (id2, >, 0); check_interfaces (c, "/test", interfaces); - g_assert (g_dbus_connection_unregister_object (c, id1)); - g_assert (g_dbus_connection_unregister_object (c, id2)); + g_assert_true (g_dbus_connection_unregister_object (c, id1)); + g_assert_true (g_dbus_connection_unregister_object (c, id2)); g_object_unref (c); } @@ -1611,7 +1611,7 @@ test_async_method_call (GDBusConnection *connection, * but we don't do any during this testcase, so assert that. */ g_assert_cmpstr (interface_name, ==, "org.freedesktop.DBus.Properties"); - g_assert (g_dbus_method_invocation_get_method_info (invocation) == NULL); + g_assert_null (g_dbus_method_invocation_get_method_info (invocation)); property = g_dbus_method_invocation_get_property_info (invocation); @@ -1631,9 +1631,9 @@ test_async_method_call (GDBusConnection *connection, g_variant_get (parameters, "(&s&s)", &iface_name, &prop_name); g_assert_cmpstr (iface_name, ==, "org.example.Foo"); - g_assert (property != NULL); + g_assert_nonnull (property); g_assert_cmpstr (prop_name, ==, property->name); - g_assert (property->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE); + g_assert_true (property->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(v)", g_variant_new_string (prop_name))); } @@ -1644,10 +1644,10 @@ test_async_method_call (GDBusConnection *connection, g_variant_get (parameters, "(&s&sv)", &iface_name, &prop_name, &value); g_assert_cmpstr (iface_name, ==, "org.example.Foo"); - g_assert (property != NULL); + g_assert_nonnull (property); g_assert_cmpstr (prop_name, ==, property->name); - g_assert (property->flags & G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE); - g_assert (g_variant_is_of_type (value, G_VARIANT_TYPE (property->signature))); + g_assert_true (property->flags & G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE); + g_assert_true (g_variant_is_of_type (value, G_VARIANT_TYPE (property->signature))); g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); g_variant_unref (value); } @@ -1658,7 +1658,7 @@ test_async_method_call (GDBusConnection *connection, g_variant_get (parameters, "(&s)", &iface_name); g_assert_cmpstr (iface_name, ==, "org.example.Foo"); - g_assert (property == NULL); + g_assert_null (property); g_dbus_method_invocation_return_value (invocation, g_variant_new_parsed ("({ 'PropertyUno': < 'uno' >," " 'NotWritable': < 'notwrite' > },)")); @@ -1683,14 +1683,14 @@ ensure_result_cb (GObject *source, if (user_data == NULL) { /* Expected an error */ - g_assert (reply == NULL); + g_assert_null (reply); } else { /* Expected a reply of a particular format. */ gchar *str; - g_assert (reply != NULL); + g_assert_nonnull (reply); str = g_variant_print (reply, TRUE); g_assert_cmpstr (str, ==, (const gchar *) user_data); g_free (str); @@ -1733,20 +1733,20 @@ test_async_properties (void) c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); g_assert_no_error (error); - g_assert (c != NULL); + g_assert_nonnull (c); registration_id = g_dbus_connection_register_object (c, "/foo", (GDBusInterfaceInfo *) &foo_interface_info, &vtable, NULL, NULL, &error); g_assert_no_error (error); - g_assert (registration_id); + g_assert_cmpuint (registration_id, !=, 0); registration_id2 = g_dbus_connection_register_object (c, "/foo", (GDBusInterfaceInfo *) &foo2_interface_info, &vtable, NULL, NULL, &error); g_assert_no_error (error); - g_assert (registration_id); + g_assert_cmpuint (registration_id, !=, 0); test_async_case (c, NULL, "random", "()");