From c93990ce8ef79e569e7d70b5ed6c29090bb33b5c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 26 Mar 2021 11:15:41 +0000 Subject: test: Replace all g_assert (x != NULL) with g_assert_nonnull (x) This avoids the assertions being removed by G_DISABLE_ASSERT, and gives somewhat better diagnostic messages if the assertion fails. Signed-off-by: Simon McVittie --- dbus/dbus-gvalue.c | 2 +- test/core/error-mapping.c | 6 ++--- test/core/manual/invalid-usage.c | 8 +++--- test/core/peer-client.c | 2 +- test/core/peer-on-bus.c | 4 +-- test/core/private.c | 2 +- test/core/proxy-noc.c | 6 ++--- test/core/proxy-peer.c | 8 +++--- test/core/registrations.c | 12 ++++----- test/core/shared-bus.c | 4 +-- test/core/test-dbus-glib.c | 56 ++++++++++++++++++++-------------------- test/core/test-service-glib.c | 2 +- test/errors.c | 2 +- test/interfaces/test-client.c | 2 +- test/specialized-types.c | 2 +- 15 files changed, 59 insertions(+), 59 deletions(-) diff --git a/dbus/dbus-gvalue.c b/dbus/dbus-gvalue.c index 5bb2b19..7220f50 100644 --- a/dbus/dbus-gvalue.c +++ b/dbus/dbus-gvalue.c @@ -2028,7 +2028,7 @@ assert_type_maps_to (GType gtype, const char *expected_sig) { char *sig; sig = _dbus_gtype_to_signature (gtype); - g_assert (sig != NULL); + g_assert_nonnull (sig); g_assert (!strcmp (expected_sig, sig)); g_free (sig); } diff --git a/test/core/error-mapping.c b/test/core/error-mapping.c index 84837fd..764275f 100644 --- a/test/core/error-mapping.c +++ b/test/core/error-mapping.c @@ -88,7 +88,7 @@ setup (Fixture *f, f->conn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error); g_assert_no_error (f->error); - g_assert (f->conn != NULL); + g_assert_nonnull (f->conn); f->object = g_object_new (MY_TYPE_OBJECT, NULL); g_assert (MY_IS_OBJECT (f->object)); @@ -98,7 +98,7 @@ setup (Fixture *f, f->proxy = dbus_g_proxy_new_for_name (f->conn, dbus_bus_get_unique_name (dbus_g_connection_get_connection (f->conn)), "/com/example/Test/Object", "org.freedesktop.DBus.GLib.Tests.MyObject"); - g_assert (f->proxy != NULL); + g_assert_nonnull (f->proxy); } static void @@ -108,7 +108,7 @@ throw_error_cb (DBusGProxy *proxy, { Fixture *f = user_data; - g_assert (error != NULL); + g_assert_nonnull (error); g_clear_error (&f->error); g_free (f->error_name); f->error = g_error_copy (error); diff --git a/test/core/manual/invalid-usage.c b/test/core/manual/invalid-usage.c index 6ca4b1f..8d3302a 100644 --- a/test/core/manual/invalid-usage.c +++ b/test/core/manual/invalid-usage.c @@ -68,11 +68,11 @@ setup (Fixture *f, f->conn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error); g_assert_no_error (f->error); - g_assert (f->conn != NULL); + g_assert_nonnull (f->conn); f->proxy = dbus_g_proxy_new_for_name (f->conn, "com.example.Test", "/com/example/Test/Object", "com.example.Test.Fallible"); - g_assert (f->proxy != NULL); + g_assert_nonnull (f->proxy); f->object = g_object_new (MY_TYPE_OBJECT, NULL); g_assert (MY_IS_OBJECT (f->object)); @@ -82,7 +82,7 @@ setup (Fixture *f, f->proxy_for_self = dbus_g_proxy_new_for_name (f->conn, dbus_bus_get_unique_name (dbus_g_connection_get_connection (f->conn)), "/com/example/Test/Object", "org.freedesktop.DBus.GLib.Tests.MyObject"); - g_assert (f->proxy_for_self != NULL); + g_assert_nonnull (f->proxy_for_self); } static void @@ -194,7 +194,7 @@ throw_error_cb (DBusGProxy *proxy, { GError **error_out = user_data; - g_assert (error != NULL); + g_assert_nonnull (error); *error_out = g_error_copy (error); } diff --git a/test/core/peer-client.c b/test/core/peer-client.c index 836f6c4..a81c364 100644 --- a/test/core/peer-client.c +++ b/test/core/peer-client.c @@ -95,7 +95,7 @@ main (int argc, char **argv) g_error ("Cannot open connection: %s", error->message); proxy = dbus_g_proxy_new_for_peer (conn, "/", "org.freedesktop.DBus.GLib.Tests.MyObject"); - g_assert (proxy); + g_assert_nonnull (proxy); if (!dbus_g_proxy_call (proxy, "DoNothing", &error, G_TYPE_INVALID, G_TYPE_INVALID)) diff --git a/test/core/peer-on-bus.c b/test/core/peer-on-bus.c index 4a62420..87ff2d8 100644 --- a/test/core/peer-on-bus.c +++ b/test/core/peer-on-bus.c @@ -56,10 +56,10 @@ setup (Fixture *f, gconstpointer path_to_use) { f->bus = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL); - g_assert (f->bus != NULL); + g_assert_nonnull (f->bus); f->bus2 = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL); - g_assert (f->bus2 != NULL); + g_assert_nonnull (f->bus2); } static void diff --git a/test/core/private.c b/test/core/private.c index b37ae20..7969ce8 100644 --- a/test/core/private.c +++ b/test/core/private.c @@ -91,7 +91,7 @@ setup (Fixture *f, f->in_flight = 0; f->bus = dbus_g_bus_get_private (DBUS_BUS_SESSION, f->context, NULL); - g_assert (f->bus != NULL); + g_assert_nonnull (f->bus); f->object = g_object_new (MY_TYPE_OBJECT, NULL); g_assert (MY_IS_OBJECT (f->object)); diff --git a/test/core/proxy-noc.c b/test/core/proxy-noc.c index 3f10eb3..d6a026a 100644 --- a/test/core/proxy-noc.c +++ b/test/core/proxy-noc.c @@ -101,14 +101,14 @@ setup (Fixture *f, f->service_gconn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error); g_assert_no_error (f->error); - g_assert (f->service_gconn != NULL); + g_assert_nonnull (f->service_gconn); f->service_conn = dbus_g_connection_get_connection (f->service_gconn); /* An attacker that intends to pretend to be that service. */ f->attacker_gconn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error); g_assert_no_error (f->error); - g_assert (f->attacker_gconn != NULL); + g_assert_nonnull (f->attacker_gconn); f->attacker_conn = dbus_g_connection_get_connection (f->attacker_gconn); /* The service owns a well-known name. */ @@ -120,7 +120,7 @@ setup (Fixture *f, /* The victim of the attack. */ f->client_gconn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error); g_assert_no_error (f->error); - g_assert (f->client_gconn != NULL); + g_assert_nonnull (f->client_gconn); f->client_conn = dbus_g_connection_get_connection (f->client_gconn); f->proxy = dbus_g_proxy_new_for_name (f->client_gconn, WELL_KNOWN_NAME, diff --git a/test/core/proxy-peer.c b/test/core/proxy-peer.c index b225d94..6cead4e 100644 --- a/test/core/proxy-peer.c +++ b/test/core/proxy-peer.c @@ -94,7 +94,7 @@ setup (Fixture *f, f->server = dbus_server_listen (addr, &f->e); assert_no_error (&f->e); - g_assert (f->server != NULL); + g_assert_nonnull (f->server); dbus_server_set_new_connection_function (f->server, new_conn_cb, f, NULL); @@ -105,7 +105,7 @@ setup (Fixture *f, f->client_conn = dbus_connection_open_private ( dbus_server_get_address (f->server), &f->e); assert_no_error (&f->e); - g_assert (f->client_conn != NULL); + g_assert_nonnull (f->client_conn); dbus_connection_setup_with_g_main (f->client_conn, NULL); f->client_gconn = dbus_connection_get_g_connection (f->client_conn); @@ -123,7 +123,7 @@ setup (Fixture *f, f->proxy = dbus_g_proxy_new_for_peer (f->client_gconn, "/org/freedesktop/DBus/GLib/Tests/MyTestObject", "org.freedesktop.DBus.GLib.Tests.MyObject"); - g_assert (f->proxy != NULL); + g_assert_nonnull (f->proxy); g_assert (DBUS_IS_G_PROXY (f->proxy)); g_signal_connect (f->proxy, "destroy", G_CALLBACK (destroy_cb), f); @@ -155,7 +155,7 @@ test_method (Fixture *f, call = dbus_g_proxy_begin_call (f->proxy, "DoNothing", call_cb, f, NULL, G_TYPE_INVALID); - g_assert (call != NULL); + g_assert_nonnull (call); g_hash_table_insert (f->in_flight, call, call); while (g_hash_table_size (f->in_flight) > 0) diff --git a/test/core/registrations.c b/test/core/registrations.c index 2c32e5a..3b2d01b 100644 --- a/test/core/registrations.c +++ b/test/core/registrations.c @@ -76,10 +76,10 @@ setup (Fixture *f, dbus_error_init (&f->dbus_error); f->bus = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL); - g_assert (f->bus != NULL); + g_assert_nonnull (f->bus); f->bus2 = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL); - g_assert (f->bus2 != NULL); + g_assert_nonnull (f->bus2); f->object = g_object_new (MY_TYPE_OBJECT, NULL); g_assert (MY_IS_OBJECT (f->object)); @@ -214,8 +214,8 @@ frobnicate_cb (DBusConnection *conn, const char *sender = dbus_message_get_sender (message); const char *path = dbus_message_get_path (message); - g_assert (sender != NULL); - g_assert (path != NULL); + g_assert_nonnull (sender); + g_assert_nonnull (path); if (g_strcmp0 (path, "/foo") == 0) { @@ -368,8 +368,8 @@ objectified_cb (DBusConnection *conn, dbus_error_init (&e); - g_assert (sender != NULL); - g_assert (path != NULL); + g_assert_nonnull (sender); + g_assert_nonnull (path); g_assert_cmpstr (path, ==, "/foo"); g_assert_cmpstr (sender, ==, dbus_bus_get_unique_name ( diff --git a/test/core/shared-bus.c b/test/core/shared-bus.c index 0f18880..a69094d 100644 --- a/test/core/shared-bus.c +++ b/test/core/shared-bus.c @@ -106,7 +106,7 @@ test_shared_bus (Fixture *f, { f->bus = dbus_g_bus_get (DBUS_BUS_SESSION, &f->error); g_assert_no_error (f->error); - g_assert (f->bus != NULL); + g_assert_nonnull (f->bus); dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (f->bus), FALSE); @@ -116,7 +116,7 @@ test_shared_bus (Fixture *f, f->priv = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error); g_assert_no_error (f->error); - g_assert (f->priv != NULL); + g_assert_nonnull (f->priv); g_assert (f->priv != f->bus); dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (f->priv), FALSE); diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c index 4e050b2..0910ccb 100644 --- a/test/core/test-dbus-glib.c +++ b/test/core/test-dbus-glib.c @@ -251,9 +251,9 @@ sig2_signal_handler (DBusGProxy *proxy, g_assert (g_hash_table_size (table) == 2); - g_assert (g_hash_table_lookup (table, "baz") != NULL); + g_assert_nonnull (g_hash_table_lookup (table, "baz")); g_assert (!strcmp (g_hash_table_lookup (table, "baz"), "cow")); - g_assert (g_hash_table_lookup (table, "bar") != NULL); + g_assert_nonnull (g_hash_table_lookup (table, "bar")); g_assert (!strcmp (g_hash_table_lookup (table, "bar"), "foo")); g_print ("Got Sig2 signal\n"); @@ -284,7 +284,7 @@ echo_received_cb (DBusGProxy *proxy, &echo_data, G_TYPE_INVALID)) lose_gerror ("Failed to complete async Echo", error); - g_assert (echo_data != NULL); + g_assert_nonnull (echo_data); g_print ("Async echo gave \"%s\"\n", echo_data); g_free (echo_data); g_main_loop_quit (loop); @@ -343,8 +343,8 @@ test_base_class_get_all (DBusGConnection *connection, /* g_test_bug (19145); */ - g_assert (expected_string_value != NULL); - g_assert (object_path != NULL); + g_assert_nonnull (expected_string_value); + g_assert_nonnull (object_path); /* Test GetAll with interfaces on the base class */ @@ -352,7 +352,7 @@ test_base_class_get_all (DBusGConnection *connection, "org.freedesktop.DBus.GLib.TestService", object_path, DBUS_INTERFACE_PROPERTIES); - g_assert (proxy != NULL); + g_assert_nonnull (proxy); g_print ("%s: Calling GetAll for unknown interface\n", object_path); { @@ -434,7 +434,7 @@ test_subclass_get_all (DBusGConnection *connection, /* g_test_bug (19145); */ - g_assert (object_path != NULL); + g_assert_nonnull (object_path); /* Test GetAll with interfaces on the subclass */ @@ -442,7 +442,7 @@ test_subclass_get_all (DBusGConnection *connection, "org.freedesktop.DBus.GLib.TestService", object_path, DBUS_INTERFACE_PROPERTIES); - g_assert (proxy != NULL); + g_assert_nonnull (proxy); g_print ("%s: Calling GetAll for subclass interface\n", object_path); { @@ -600,7 +600,7 @@ main (int argc, char **argv) name_list_len = g_strv_length (name_list); while (i < name_list_len) { - g_assert (name_list[i] != NULL); + g_assert_nonnull (name_list[i]); g_print (" %s\n", name_list[i]); ++i; } @@ -1112,7 +1112,7 @@ main (int argc, char **argv) g_print ("Calling (wrapped) many_uppercase\n"); if (!org_freedesktop_DBus_GLib_Tests_MyObject_many_uppercase (proxy, strs, &strs_ret, &error)) lose_gerror ("Failed to complete (wrapped) ManyUppercase call", error); - g_assert (strs_ret != NULL); + g_assert_nonnull (strs_ret); if (strcmp ("HELLO", strs_ret[0]) != 0) lose ("(wrapped) ManyUppercase call returned unexpected string %s", strs_ret[0]); if (strcmp ("HELLO", strs_ret[1]) != 0) @@ -1199,7 +1199,7 @@ main (int argc, char **argv) G_TYPE_INVALID)) lose_gerror ("Failed to complete SendCar call", error); - g_assert (vals_ret != NULL); + g_assert_nonnull (vals_ret); g_assert (vals_ret->n_values == 2); g_assert (G_VALUE_HOLDS_UINT (g_value_array_get_nth (vals_ret, 0))); @@ -1260,16 +1260,16 @@ main (int argc, char **argv) G_TYPE_INVALID)) lose_gerror ("Failed to complete ManyStringify call", error); - g_assert (ret_table != NULL); + g_assert_nonnull (ret_table); g_assert (g_hash_table_size (ret_table) == 2); val = g_hash_table_lookup (ret_table, "foo"); - g_assert (val != NULL); + g_assert_nonnull (val); g_assert (G_VALUE_HOLDS_STRING (val)); g_assert (!strcmp ("42", g_value_get_string (val))); val = g_hash_table_lookup (ret_table, "bar"); - g_assert (val != NULL); + g_assert_nonnull (val); g_assert (G_VALUE_HOLDS_STRING (val)); g_assert (!strcmp ("hello", g_value_get_string (val))); @@ -1312,17 +1312,17 @@ main (int argc, char **argv) g_free (g_ptr_array_index (in_array, 1)); g_ptr_array_free (in_array, TRUE); - g_assert (out_array); + g_assert_nonnull (out_array); g_assert (out_array->len == 2); uints = g_ptr_array_index (out_array, 0); - g_assert (uints); + g_assert_nonnull (uints); g_assert (uints->len == 3); g_assert (g_array_index (uints, guint, 0) == 10); g_assert (g_array_index (uints, guint, 1) == 42); g_assert (g_array_index (uints, guint, 2) == 27); g_array_free (uints, TRUE); uints = g_ptr_array_index (out_array, 1); - g_assert (uints); + g_assert_nonnull (uints); g_assert (uints->len == 1); g_assert (g_array_index (uints, guint, 0) == 30); g_array_free (uints, TRUE); @@ -1520,39 +1520,39 @@ main (int argc, char **argv) G_TYPE_INVALID)) lose_gerror ("Failed to complete DictOfDicts call", error); - g_assert (ret_table != NULL); + g_assert_nonnull (ret_table); g_assert (g_hash_table_size (ret_table) == 2); subtable = g_hash_table_lookup (ret_table, "dict1"); - g_assert(subtable); + g_assert_nonnull (subtable); g_assert (g_hash_table_size (subtable) == 3); val = g_hash_table_lookup (subtable, "foo"); - g_assert (val != NULL); + g_assert_nonnull (val); g_assert (!strcmp ("dict1 1", val)); val = g_hash_table_lookup (subtable, "bar"); - g_assert (val != NULL); + g_assert_nonnull (val); g_assert (!strcmp ("dict1 2", val)); val = g_hash_table_lookup (subtable, "baz"); - g_assert (val != NULL); + g_assert_nonnull (val); g_assert (!strcmp ("dict1 3", val)); subtable = g_hash_table_lookup (ret_table, "dict2"); - g_assert(subtable); + g_assert_nonnull (subtable); g_assert (g_hash_table_size (subtable) == 3); val = g_hash_table_lookup (subtable, "foo"); - g_assert (val != NULL); + g_assert_nonnull (val); g_assert (!strcmp ("dict2 4", val)); val = g_hash_table_lookup (subtable, "bar"); - g_assert (val != NULL); + g_assert_nonnull (val); g_assert (!strcmp ("dict2 5", val)); val = g_hash_table_lookup (subtable, "baz"); - g_assert (val != NULL); + g_assert_nonnull (val); g_assert (!strcmp ("dict2 6", val)); g_hash_table_destroy (table); @@ -1809,7 +1809,7 @@ main (int argc, char **argv) "org.freedesktop.DBus.GLib.TestService", "/org/freedesktop/DBus/GLib/Tests/MyTestObject", "org.freedesktop.DBus.GLib.Tests.MyObject"); - g_assert (proxy != NULL); + g_assert_nonnull (proxy); proxy_destroyed = FALSE; proxy_destroy_and_nameowner = FALSE; @@ -1912,7 +1912,7 @@ main (int argc, char **argv) "org.freedesktop.DBus.GLib.TestService", "/org/freedesktop/DBus/GLib/Tests/MyTestObject", "org.freedesktop.DBus.GLib.Tests.MyObject"); - g_assert (proxy2 != NULL); + g_assert_nonnull (proxy2); dbus_g_proxy_add_signal (proxy2, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID); diff --git a/test/core/test-service-glib.c b/test/core/test-service-glib.c index 8712b17..1b328f7 100644 --- a/test/core/test-service-glib.c +++ b/test/core/test-service-glib.c @@ -90,7 +90,7 @@ main (int argc, char **argv) TEST_SERVICE_NAME, 0, &request_name_ret, &error)) { - g_assert (error != NULL); + g_assert_nonnull (error); g_printerr ("Failed to get name: %s\n", error->message); g_clear_error (&error); diff --git a/test/errors.c b/test/errors.c index 468dec7..cf2110e 100644 --- a/test/errors.c +++ b/test/errors.c @@ -53,7 +53,7 @@ test_errors (Fixture *f G_GNUC_UNUSED, dbus_set_error_const (&err, DBUS_ERROR_NO_MEMORY, "Out of memory!"); dbus_set_g_error (&gerror, &err); - g_assert (gerror != NULL); + g_assert_nonnull (gerror); g_assert_error (gerror, DBUS_GERROR, DBUS_GERROR_NO_MEMORY); g_assert_cmpstr (gerror->message, ==, "Out of memory!"); diff --git a/test/interfaces/test-client.c b/test/interfaces/test-client.c index b2d0104..8fc60a0 100644 --- a/test/interfaces/test-client.c +++ b/test/interfaces/test-client.c @@ -134,7 +134,7 @@ main (int argc, proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_OBJECT_PATH, "org.freedesktop.DBus.GLib.Test.Interfaces.Hello"); - g_assert (proxy != NULL); + g_assert_nonnull (proxy); success = org_freedesktop_DBus_GLib_Test_Interfaces_Hello_say_hello (proxy, &str, &error); g_object_unref (proxy); diff --git a/test/specialized-types.c b/test/specialized-types.c index 7c8b0ed..e0e743a 100644 --- a/test/specialized-types.c +++ b/test/specialized-types.c @@ -246,7 +246,7 @@ test_ao_slist (Fixture *f G_GNUC_UNUSED, GValue eltval = { 0, }; GObject *obj = g_object_new (G_TYPE_OBJECT, NULL); - g_assert (obj != NULL); + g_assert_nonnull (obj); objects[i] = obj; g_object_add_weak_pointer (obj, (gpointer) (objects + i)); -- cgit v1.2.1 From 0cf441eb0ec42a7e9444932329b4fa954669d8cb Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 26 Mar 2021 12:07:50 +0000 Subject: test: Replace g_assert (x == NULL) with g_assert_null (x) Signed-off-by: Simon McVittie --- test/core/proxy-peer.c | 6 +++--- test/core/registrations.c | 20 ++++++++++---------- test/core/test-dbus-glib.c | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/core/proxy-peer.c b/test/core/proxy-peer.c index 6cead4e..656e704 100644 --- a/test/core/proxy-peer.c +++ b/test/core/proxy-peer.c @@ -69,7 +69,7 @@ new_conn_cb (DBusServer *server, { Fixture *f = data; - g_assert (f->server_conn == NULL); + g_assert_null (f->server_conn); f->server_conn = dbus_connection_ref (server_conn); dbus_connection_setup_with_g_main (server_conn, NULL); f->server_gconn = dbus_connection_get_g_connection (server_conn); @@ -100,7 +100,7 @@ setup (Fixture *f, new_conn_cb, f, NULL); dbus_server_setup_with_g_main (f->server, NULL); - g_assert (f->server_conn == NULL); + g_assert_null (f->server_conn); f->client_conn = dbus_connection_open_private ( dbus_server_get_address (f->server), &f->e); @@ -187,7 +187,7 @@ test_disconnect (Fixture *f, fail = dbus_g_proxy_begin_call (f->proxy, "DoNothing", call_cb, f, NULL, G_TYPE_INVALID); - g_assert (fail == NULL); + g_assert_null (fail); ok = dbus_g_proxy_end_call (f->proxy, fail, &error, G_TYPE_INVALID); diff --git a/test/core/registrations.c b/test/core/registrations.c index 3b2d01b..0c2fb55 100644 --- a/test/core/registrations.c +++ b/test/core/registrations.c @@ -127,7 +127,7 @@ test_lookup (Fixture *f, g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); /* this was briefly broken while fixing fd.o#5688 */ - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/bar") == NULL); + g_assert_null (dbus_g_connection_lookup_g_object (f->bus, "/bar")); } static void @@ -141,7 +141,7 @@ test_unregister (Fixture *f, g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); dbus_g_connection_unregister_g_object (f->bus, f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL); + g_assert_null (dbus_g_connection_lookup_g_object (f->bus, "/foo")); } static void @@ -160,9 +160,9 @@ test_unregister_on_last_unref (Fixture *f, g_object_unref (f->object); f->object = NULL; - g_assert (weak_pointer == NULL); + g_assert_null (weak_pointer); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL); + g_assert_null (dbus_g_connection_lookup_g_object (f->bus, "/foo")); } static void @@ -176,7 +176,7 @@ test_unregister_on_forced_dispose (Fixture *f, * this at home) */ g_object_run_dispose (f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL); + g_assert_null (dbus_g_connection_lookup_g_object (f->bus, "/foo")); } static void @@ -198,7 +198,7 @@ test_reregister (Fixture *f, /* This would critical in 0.84. */ dbus_g_connection_unregister_g_object (f->bus, f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL); + g_assert_null (dbus_g_connection_lookup_g_object (f->bus, "/foo")); } static DBusHandlerResult @@ -222,7 +222,7 @@ frobnicate_cb (DBusConnection *conn, g_assert_cmpstr (sender, ==, dbus_bus_get_unique_name ( dbus_g_connection_get_connection (f->bus))); - g_assert (f->frobnicate1_message == NULL); + g_assert_null (f->frobnicate1_message); f->frobnicate1_message = dbus_message_ref (message); } else @@ -231,7 +231,7 @@ frobnicate_cb (DBusConnection *conn, g_assert_cmpstr (sender, ==, dbus_bus_get_unique_name ( dbus_g_connection_get_connection (f->bus2))); - g_assert (f->frobnicate2_message == NULL); + g_assert_null (f->frobnicate2_message); f->frobnicate2_message = dbus_message_ref (message); } } @@ -283,7 +283,7 @@ test_twice (Fixture *f, while (f->frobnicate2_message == NULL) g_main_context_iteration (NULL, TRUE); - g_assert (f->frobnicate1_message == NULL); + g_assert_null (f->frobnicate1_message); dbus_message_unref (f->frobnicate2_message); f->frobnicate2_message = NULL; } @@ -345,7 +345,7 @@ test_clean_slate (Fixture *f, /* check that this wasn't received anyway, which would indicate that * either unregistration from /foo was unsuccessful, or the double * emission mentioned above was seen */ - g_assert (f->frobnicate1_message == NULL); + g_assert_null (f->frobnicate1_message); dbus_message_unref (f->frobnicate2_message); f->frobnicate2_message = NULL; diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c index 0910ccb..0d84310 100644 --- a/test/core/test-dbus-glib.c +++ b/test/core/test-dbus-glib.c @@ -273,7 +273,7 @@ echo_received_cb (DBusGProxy *proxy, char *echo_data; g_assert (call == echo_call); - g_assert (data == NULL); + g_assert_null (data); error = NULL; echo_data = NULL; @@ -604,7 +604,7 @@ main (int argc, char **argv) g_print (" %s\n", name_list[i]); ++i; } - g_assert (name_list[i] == NULL); + g_assert_null (name_list[i]); g_strfreev (name_list); @@ -2278,7 +2278,7 @@ main (int argc, char **argv) /* Now, call disable_legacy_property_access */ - g_assert (proxy == NULL); + g_assert_null (proxy); proxy = dbus_g_proxy_new_for_name_owner (connection, "org.freedesktop.DBus.GLib.TestService", "/org/freedesktop/DBus/GLib/Tests/MyTestObject", -- cgit v1.2.1 From 6f9838a8736557534c06f1abc7e2ac4f4ab4bf89 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 26 Mar 2021 12:11:06 +0000 Subject: test: Compare strings with g_assert_cmpstr() Signed-off-by: Simon McVittie --- dbus/dbus-gobject.c | 40 ++++++++++++++++++++-------------------- dbus/dbus-gvalue.c | 6 +++--- test/core/test-dbus-glib.c | 38 +++++++++++++++++++------------------- test/specialized-types.c | 4 ++-- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c index 4925cd8..f0942e8 100644 --- a/dbus/dbus-gobject.c +++ b/dbus/dbus-gobject.c @@ -3340,14 +3340,14 @@ _dbus_gobject_test (const char *test_data_dir) &(dbus_glib_internal_test_methods[1])); g_assert (*arg != '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); - g_assert (!strcmp (arg_name, "x")); + g_assert_cmpstr (arg_name, ==, "x"); g_assert (arg_in == TRUE); - g_assert (!strcmp (arg_signature, "u")); + g_assert_cmpstr (arg_signature, ==, "u"); g_assert (*arg != '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert (arg_in == FALSE); g_assert (retval == RETVAL_NONE); - g_assert (!strcmp (arg_signature, "u")); + g_assert_cmpstr (arg_signature, ==, "u"); g_assert (*arg == '\0'); /* IncrementRetval */ @@ -3355,14 +3355,14 @@ _dbus_gobject_test (const char *test_data_dir) &(dbus_glib_internal_test_methods[2])); g_assert (*arg != '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); - g_assert (!strcmp (arg_name, "x")); + g_assert_cmpstr (arg_name, ==, "x"); g_assert (arg_in == TRUE); - g_assert (!strcmp (arg_signature, "u")); + g_assert_cmpstr (arg_signature, ==, "u"); g_assert (*arg != '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert (retval == RETVAL_NOERROR); g_assert (arg_in == FALSE); - g_assert (!strcmp (arg_signature, "u")); + g_assert_cmpstr (arg_signature, ==, "u"); g_assert (*arg == '\0'); /* IncrementRetvalError */ @@ -3370,14 +3370,14 @@ _dbus_gobject_test (const char *test_data_dir) &(dbus_glib_internal_test_methods[3])); g_assert (*arg != '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); - g_assert (!strcmp (arg_name, "x")); + g_assert_cmpstr (arg_name, ==, "x"); g_assert (arg_in == TRUE); - g_assert (!strcmp (arg_signature, "u")); + g_assert_cmpstr (arg_signature, ==, "u"); g_assert (*arg != '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert (retval == RETVAL_ERROR); g_assert (arg_in == FALSE); - g_assert (!strcmp (arg_signature, "u")); + g_assert_cmpstr (arg_signature, ==, "u"); g_assert (*arg == '\0'); /* Stringify */ @@ -3385,33 +3385,33 @@ _dbus_gobject_test (const char *test_data_dir) &(dbus_glib_internal_test_methods[8])); g_assert (*arg != '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); - g_assert (!strcmp (arg_name, "val")); + g_assert_cmpstr (arg_name, ==, "val"); g_assert (arg_in == TRUE); - g_assert (!strcmp (arg_signature, "v")); + g_assert_cmpstr (arg_signature, ==, "v"); g_assert (*arg != '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert (retval == RETVAL_NONE); g_assert (arg_in == FALSE); - g_assert (!strcmp (arg_signature, "s")); + g_assert_cmpstr (arg_signature, ==, "s"); g_assert (*arg == '\0'); sigdata = dbus_glib_internal_test_object_info.exported_signals; g_assert (*sigdata != '\0'); sigdata = signal_iterate (sigdata, &iface, &signame); - g_assert (!strcmp (iface, "org.freedesktop.DBus.Tests.MyObject")); - g_assert (!strcmp (signame, "Frobnicate")); + g_assert_cmpstr (iface, ==, "org.freedesktop.DBus.Tests.MyObject"); + g_assert_cmpstr (signame, ==, "Frobnicate"); g_assert (*sigdata != '\0'); sigdata = signal_iterate (sigdata, &iface, &signame); - g_assert (!strcmp (iface, "org.freedesktop.DBus.Tests.FooObject")); - g_assert (!strcmp (signame, "Sig0")); + g_assert_cmpstr (iface, ==, "org.freedesktop.DBus.Tests.FooObject"); + g_assert_cmpstr (signame, ==, "Sig0"); g_assert (*sigdata != '\0'); sigdata = signal_iterate (sigdata, &iface, &signame); - g_assert (!strcmp (iface, "org.freedesktop.DBus.Tests.FooObject")); - g_assert (!strcmp (signame, "Sig1")); + g_assert_cmpstr (iface, ==, "org.freedesktop.DBus.Tests.FooObject"); + g_assert_cmpstr (signame, ==, "Sig1"); g_assert (*sigdata != '\0'); sigdata = signal_iterate (sigdata, &iface, &signame); - g_assert (!strcmp (iface, "org.freedesktop.DBus.Tests.FooObject")); - g_assert (!strcmp (signame, "Sig2")); + g_assert_cmpstr (iface, ==, "org.freedesktop.DBus.Tests.FooObject"); + g_assert_cmpstr (signame, ==, "Sig2"); g_assert (*sigdata == '\0'); diff --git a/dbus/dbus-gvalue.c b/dbus/dbus-gvalue.c index 7220f50..bd97e65 100644 --- a/dbus/dbus-gvalue.c +++ b/dbus/dbus-gvalue.c @@ -2029,7 +2029,7 @@ assert_type_maps_to (GType gtype, const char *expected_sig) char *sig; sig = _dbus_gtype_to_signature (gtype); g_assert_nonnull (sig); - g_assert (!strcmp (expected_sig, sig)); + g_assert_cmpstr (expected_sig, ==, sig); g_free (sig); } @@ -2075,14 +2075,14 @@ _dbus_gvalue_test (const char *test_data_dir) rectype = dbus_g_type_get_collection ("GArray", G_TYPE_UINT); g_assert (rectype != G_TYPE_INVALID); - g_assert (!strcmp (g_type_name (rectype), "GArray_guint_")); + g_assert_cmpstr (g_type_name (rectype), ==, "GArray_guint_"); type = _dbus_gtype_from_signature ("au", TRUE); g_assert (type == rectype); rectype = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING); g_assert (rectype != G_TYPE_INVALID); - g_assert (!strcmp (g_type_name (rectype), "GHashTable_gchararray+gchararray_")); + g_assert_cmpstr (g_type_name (rectype), ==, "GHashTable_gchararray+gchararray_"); type = _dbus_gtype_from_signature ("a{ss}", TRUE); g_assert (type == rectype); diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c index 0d84310..6e2d657 100644 --- a/test/core/test-dbus-glib.c +++ b/test/core/test-dbus-glib.c @@ -210,11 +210,11 @@ sig0_signal_handler (DBusGProxy *proxy, { n_times_sig0_received += 1; - g_assert (!strcmp (str0, "foo")); + g_assert_cmpstr (str0, ==, "foo"); g_assert (val == 22); - g_assert (!strcmp (str1, "moo")); + g_assert_cmpstr (str1, ==, "moo"); g_print ("Got Sig0 signal\n"); @@ -230,11 +230,11 @@ sig1_signal_handler (DBusGProxy *proxy, { n_times_sig1_received += 1; - g_assert (!strcmp (str0, "baz")); + g_assert_cmpstr (str0, ==, "baz"); g_assert (G_VALUE_HOLDS_STRING (value)); - g_assert (!strcmp (g_value_get_string (value), "bar")); + g_assert_cmpstr (g_value_get_string (value), ==, "bar"); g_print ("Got Sig1 signal\n"); @@ -252,9 +252,9 @@ sig2_signal_handler (DBusGProxy *proxy, g_assert (g_hash_table_size (table) == 2); g_assert_nonnull (g_hash_table_lookup (table, "baz")); - g_assert (!strcmp (g_hash_table_lookup (table, "baz"), "cow")); + g_assert_cmpstr (g_hash_table_lookup (table, "baz"), ==, "cow"); g_assert_nonnull (g_hash_table_lookup (table, "bar")); - g_assert (!strcmp (g_hash_table_lookup (table, "bar"), "foo")); + g_assert_cmpstr (g_hash_table_lookup (table, "bar"), ==, "foo"); g_print ("Got Sig2 signal\n"); @@ -299,7 +299,7 @@ increment_received_cb (DBusGProxy *proxy, GError *error; guint val; - g_assert (!strcmp (data, "moo")); + g_assert_cmpstr (data, ==, "moo"); error = NULL; if (!dbus_g_proxy_end_call (proxy, call, &error, @@ -1206,8 +1206,8 @@ main (int argc, char **argv) g_assert (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)) == 43); g_assert (G_VALUE_TYPE (g_value_array_get_nth (vals_ret, 1)) == DBUS_TYPE_G_OBJECT_PATH); - g_assert (!strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2", - g_value_get_boxed (g_value_array_get_nth (vals_ret, 1)))); + g_assert_cmpstr ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2", ==, + g_value_get_boxed (g_value_array_get_nth (vals_ret, 1))); g_free (val); g_value_array_free (vals); @@ -1266,12 +1266,12 @@ main (int argc, char **argv) val = g_hash_table_lookup (ret_table, "foo"); g_assert_nonnull (val); g_assert (G_VALUE_HOLDS_STRING (val)); - g_assert (!strcmp ("42", g_value_get_string (val))); + g_assert_cmpstr ("42", ==, g_value_get_string (val)); val = g_hash_table_lookup (ret_table, "bar"); g_assert_nonnull (val); g_assert (G_VALUE_HOLDS_STRING (val)); - g_assert (!strcmp ("hello", g_value_get_string (val))); + g_assert_cmpstr ("hello", ==, g_value_get_string (val)); g_hash_table_destroy (table); g_hash_table_destroy (ret_table); @@ -1529,15 +1529,15 @@ main (int argc, char **argv) val = g_hash_table_lookup (subtable, "foo"); g_assert_nonnull (val); - g_assert (!strcmp ("dict1 1", val)); + g_assert_cmpstr ("dict1 1", ==, val); val = g_hash_table_lookup (subtable, "bar"); g_assert_nonnull (val); - g_assert (!strcmp ("dict1 2", val)); + g_assert_cmpstr ("dict1 2", ==, val); val = g_hash_table_lookup (subtable, "baz"); g_assert_nonnull (val); - g_assert (!strcmp ("dict1 3", val)); + g_assert_cmpstr ("dict1 3", ==, val); subtable = g_hash_table_lookup (ret_table, "dict2"); g_assert_nonnull (subtable); @@ -1545,15 +1545,15 @@ main (int argc, char **argv) val = g_hash_table_lookup (subtable, "foo"); g_assert_nonnull (val); - g_assert (!strcmp ("dict2 4", val)); + g_assert_cmpstr ("dict2 4", ==, val); val = g_hash_table_lookup (subtable, "bar"); g_assert_nonnull (val); - g_assert (!strcmp ("dict2 5", val)); + g_assert_cmpstr ("dict2 5", ==, val); val = g_hash_table_lookup (subtable, "baz"); g_assert_nonnull (val); - g_assert (!strcmp ("dict2 6", val)); + g_assert_cmpstr ("dict2 6", ==, val); g_hash_table_destroy (table); g_hash_table_destroy (ret_table); @@ -2075,7 +2075,7 @@ main (int argc, char **argv) G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty call", error); g_assert (G_VALUE_HOLDS (&value, G_TYPE_STRING)); - g_assert (!strcmp (g_value_get_string (&value), "")); + g_assert_cmpstr (g_value_get_string (&value), ==, ""); g_value_unset (&value); } @@ -2144,7 +2144,7 @@ main (int argc, char **argv) G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty call", error); g_assert (G_VALUE_HOLDS (&value, G_TYPE_STRING)); - g_assert (!strcmp (g_value_get_string (&value), "testing value")); + g_assert_cmpstr (g_value_get_string (&value), ==, "testing value"); g_value_unset (&value); } diff --git a/test/specialized-types.c b/test/specialized-types.c index e0e743a..ce5d82d 100644 --- a/test/specialized-types.c +++ b/test/specialized-types.c @@ -447,9 +447,9 @@ test_suo (Fixture *f G_GNUC_UNUSED, 2, &path, G_MAXUINT); - g_assert (0 == strcmp (string, "foo")); + g_assert_cmpstr (string, ==, "foo"); g_assert (intval == 42); - g_assert (0 == strcmp (path, "/bar/moo/foo/baz")); + g_assert_cmpstr (path, ==, "/bar/moo/foo/baz"); } g_value_unset (&val); -- cgit v1.2.1 From 97590d6071d8deb82e09794119c9e680a3488c49 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 26 Mar 2021 12:16:57 +0000 Subject: test: Compare integers using g_assert_cmpint(), g_assert_cmpuint() Signed-off-by: Simon McVittie --- dbus/dbus-gobject.c | 34 +++++++++++++++++----------------- dbus/dbus-gvalue.c | 16 ++++++++-------- test/core/peer-client.c | 2 +- test/core/test-dbus-glib.c | 40 ++++++++++++++++++++-------------------- test/core/test-profile.c | 4 ++-- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c index f0942e8..ad5ee8b 100644 --- a/dbus/dbus-gobject.c +++ b/dbus/dbus-gobject.c @@ -3333,67 +3333,67 @@ _dbus_gobject_test (const char *test_data_dir) /* DoNothing */ arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info, &(dbus_glib_internal_test_methods[0])); - g_assert (*arg == '\0'); + g_assert_cmpint (*arg, ==, '\0'); /* Increment */ arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info, &(dbus_glib_internal_test_methods[1])); - g_assert (*arg != '\0'); + g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpstr (arg_name, ==, "x"); g_assert (arg_in == TRUE); g_assert_cmpstr (arg_signature, ==, "u"); - g_assert (*arg != '\0'); + g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert (arg_in == FALSE); - g_assert (retval == RETVAL_NONE); + g_assert_cmpint (retval, ==, RETVAL_NONE); g_assert_cmpstr (arg_signature, ==, "u"); - g_assert (*arg == '\0'); + g_assert_cmpint (*arg, ==, '\0'); /* IncrementRetval */ arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info, &(dbus_glib_internal_test_methods[2])); - g_assert (*arg != '\0'); + g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpstr (arg_name, ==, "x"); g_assert (arg_in == TRUE); g_assert_cmpstr (arg_signature, ==, "u"); - g_assert (*arg != '\0'); + g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); - g_assert (retval == RETVAL_NOERROR); + g_assert_cmpint (retval, ==, RETVAL_NOERROR); g_assert (arg_in == FALSE); g_assert_cmpstr (arg_signature, ==, "u"); - g_assert (*arg == '\0'); + g_assert_cmpint (*arg, ==, '\0'); /* IncrementRetvalError */ arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info, &(dbus_glib_internal_test_methods[3])); - g_assert (*arg != '\0'); + g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpstr (arg_name, ==, "x"); g_assert (arg_in == TRUE); g_assert_cmpstr (arg_signature, ==, "u"); - g_assert (*arg != '\0'); + g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); - g_assert (retval == RETVAL_ERROR); + g_assert_cmpint (retval, ==, RETVAL_ERROR); g_assert (arg_in == FALSE); g_assert_cmpstr (arg_signature, ==, "u"); - g_assert (*arg == '\0'); + g_assert_cmpint (*arg, ==, '\0'); /* Stringify */ arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info, &(dbus_glib_internal_test_methods[8])); - g_assert (*arg != '\0'); + g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpstr (arg_name, ==, "val"); g_assert (arg_in == TRUE); g_assert_cmpstr (arg_signature, ==, "v"); - g_assert (*arg != '\0'); + g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); - g_assert (retval == RETVAL_NONE); + g_assert_cmpint (retval, ==, RETVAL_NONE); g_assert (arg_in == FALSE); g_assert_cmpstr (arg_signature, ==, "s"); - g_assert (*arg == '\0'); + g_assert_cmpint (*arg, ==, '\0'); sigdata = dbus_glib_internal_test_object_info.exported_signals; g_assert (*sigdata != '\0'); diff --git a/dbus/dbus-gvalue.c b/dbus/dbus-gvalue.c index bd97e65..534e90a 100644 --- a/dbus/dbus-gvalue.c +++ b/dbus/dbus-gvalue.c @@ -2036,7 +2036,7 @@ assert_type_maps_to (GType gtype, const char *expected_sig) static void assert_signature_maps_to (const char *sig, GType expected_gtype) { - g_assert (_dbus_gtype_from_signature (sig, TRUE) == expected_gtype); + g_assert_cmpuint (_dbus_gtype_from_signature (sig, TRUE), ==, expected_gtype); } static void @@ -2074,26 +2074,26 @@ _dbus_gvalue_test (const char *test_data_dir) DBUS_STRUCT_BEGIN_CHAR_AS_STRING DBUS_TYPE_INT32_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING DBUS_STRUCT_END_CHAR_AS_STRING ); rectype = dbus_g_type_get_collection ("GArray", G_TYPE_UINT); - g_assert (rectype != G_TYPE_INVALID); + g_assert_cmpuint (rectype, !=, G_TYPE_INVALID); g_assert_cmpstr (g_type_name (rectype), ==, "GArray_guint_"); type = _dbus_gtype_from_signature ("au", TRUE); - g_assert (type == rectype); + g_assert_cmpuint (type, ==, rectype); rectype = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING); - g_assert (rectype != G_TYPE_INVALID); + g_assert_cmpuint (rectype, !=, G_TYPE_INVALID); g_assert_cmpstr (g_type_name (rectype), ==, "GHashTable_gchararray+gchararray_"); type = _dbus_gtype_from_signature ("a{ss}", TRUE); - g_assert (type == rectype); + g_assert_cmpuint (type, ==, rectype); type = _dbus_gtype_from_signature ("o", FALSE); - g_assert (type == DBUS_TYPE_G_OBJECT_PATH); + g_assert_cmpuint (type, ==, DBUS_TYPE_G_OBJECT_PATH); type = _dbus_gtype_from_signature ("o", TRUE); - g_assert (type == DBUS_TYPE_G_OBJECT_PATH); + g_assert_cmpuint (type, ==, DBUS_TYPE_G_OBJECT_PATH); type = _dbus_gtype_from_signature ("g", TRUE); - g_assert (type == DBUS_TYPE_G_SIGNATURE); + g_assert_cmpuint (type, ==, DBUS_TYPE_G_SIGNATURE); return TRUE; } diff --git a/test/core/peer-client.c b/test/core/peer-client.c index a81c364..ba95616 100644 --- a/test/core/peer-client.c +++ b/test/core/peer-client.c @@ -50,7 +50,7 @@ frobnicate_signal_handler (DBusGProxy *proxy, int val, void *user_data) { n_times_frobnicate_received += 1; - g_assert (val == 42); + g_assert_cmpint (val, ==, 42); g_main_loop_quit (loop); g_source_remove (exit_timeout); diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c index 6e2d657..3633677 100644 --- a/test/core/test-dbus-glib.c +++ b/test/core/test-dbus-glib.c @@ -169,7 +169,7 @@ frobnicate_signal_handler (DBusGProxy *proxy, { n_times_frobnicate_received += 1; - g_assert (val == 42); + g_assert_cmpint (val, ==, 42); g_print ("Got Frobnicate signal\n"); g_main_loop_quit (loop); @@ -183,7 +183,7 @@ frobnicate_signal_handler_2 (DBusGProxy *proxy, { n_times_frobnicate_received_2 += 1; - g_assert (val == 42); + g_assert_cmpint (val, ==, 42); g_print ("Got Frobnicate signal (again)\n"); } @@ -194,7 +194,7 @@ frobnicate_signal_handler_compat (DBusGProxy *proxy, { n_times_compat_frobnicate_received += 1; - g_assert (val == 42); + g_assert_cmpint (val, ==, 42); g_print ("Got Frobnicate signal (compat)\n"); g_main_loop_quit (loop); @@ -212,7 +212,7 @@ sig0_signal_handler (DBusGProxy *proxy, g_assert_cmpstr (str0, ==, "foo"); - g_assert (val == 22); + g_assert_cmpint (val, ==, 22); g_assert_cmpstr (str1, ==, "moo"); @@ -249,7 +249,7 @@ sig2_signal_handler (DBusGProxy *proxy, { n_times_sig2_received += 1; - g_assert (g_hash_table_size (table) == 2); + g_assert_cmpuint (g_hash_table_size (table), ==, 2); g_assert_nonnull (g_hash_table_lookup (table, "baz")); g_assert_cmpstr (g_hash_table_lookup (table, "baz"), ==, "cow"); @@ -1200,10 +1200,10 @@ main (int argc, char **argv) lose_gerror ("Failed to complete SendCar call", error); g_assert_nonnull (vals_ret); - g_assert (vals_ret->n_values == 2); + g_assert_cmpuint (vals_ret->n_values, ==, 2); g_assert (G_VALUE_HOLDS_UINT (g_value_array_get_nth (vals_ret, 0))); - g_assert (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)) == 43); + g_assert_cmpuint (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)), ==, 43); g_assert (G_VALUE_TYPE (g_value_array_get_nth (vals_ret, 1)) == DBUS_TYPE_G_OBJECT_PATH); g_assert_cmpstr ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2", ==, @@ -1261,7 +1261,7 @@ main (int argc, char **argv) lose_gerror ("Failed to complete ManyStringify call", error); g_assert_nonnull (ret_table); - g_assert (g_hash_table_size (ret_table) == 2); + g_assert_cmpuint (g_hash_table_size (ret_table), ==, 2); val = g_hash_table_lookup (ret_table, "foo"); g_assert_nonnull (val); @@ -1313,18 +1313,18 @@ main (int argc, char **argv) g_ptr_array_free (in_array, TRUE); g_assert_nonnull (out_array); - g_assert (out_array->len == 2); + g_assert_cmpuint (out_array->len, ==, 2); uints = g_ptr_array_index (out_array, 0); g_assert_nonnull (uints); - g_assert (uints->len == 3); - g_assert (g_array_index (uints, guint, 0) == 10); - g_assert (g_array_index (uints, guint, 1) == 42); - g_assert (g_array_index (uints, guint, 2) == 27); + g_assert_cmpuint (uints->len, ==, 3); + g_assert_cmpuint (g_array_index (uints, guint, 0), ==, 10); + g_assert_cmpuint (g_array_index (uints, guint, 1), ==, 42); + g_assert_cmpuint (g_array_index (uints, guint, 2), ==, 27); g_array_free (uints, TRUE); uints = g_ptr_array_index (out_array, 1); g_assert_nonnull (uints); - g_assert (uints->len == 1); - g_assert (g_array_index (uints, guint, 0) == 30); + g_assert_cmpuint (uints->len, ==, 1); + g_assert_cmpuint (g_array_index (uints, guint, 0), ==, 30); g_array_free (uints, TRUE); g_ptr_array_free (out_array, TRUE); } @@ -1521,11 +1521,11 @@ main (int argc, char **argv) lose_gerror ("Failed to complete DictOfDicts call", error); g_assert_nonnull (ret_table); - g_assert (g_hash_table_size (ret_table) == 2); + g_assert_cmpuint (g_hash_table_size (ret_table), ==, 2); subtable = g_hash_table_lookup (ret_table, "dict1"); g_assert_nonnull (subtable); - g_assert (g_hash_table_size (subtable) == 3); + g_assert_cmpuint (g_hash_table_size (subtable), ==, 3); val = g_hash_table_lookup (subtable, "foo"); g_assert_nonnull (val); @@ -1541,7 +1541,7 @@ main (int argc, char **argv) subtable = g_hash_table_lookup (ret_table, "dict2"); g_assert_nonnull (subtable); - g_assert (g_hash_table_size (subtable) == 3); + g_assert_cmpuint (g_hash_table_size (subtable), ==, 3); val = g_hash_table_lookup (subtable, "foo"); g_assert_nonnull (val); @@ -2102,7 +2102,7 @@ main (int argc, char **argv) G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty no-touching call", error); g_assert (G_VALUE_HOLDS (&value, G_TYPE_UINT)); - g_assert (g_value_get_uint (&value) == 42); + g_assert_cmpuint (g_value_get_uint (&value), ==, 42); g_value_unset (&value); } @@ -2130,7 +2130,7 @@ main (int argc, char **argv) G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty call", error); g_assert (G_VALUE_HOLDS (&value, G_TYPE_UINT)); - g_assert (g_value_get_uint (&value) == 42); + g_assert_cmpuint (g_value_get_uint (&value), ==, 42); g_value_unset (&value); } diff --git a/test/core/test-profile.c b/test/core/test-profile.c index 015d200..5338e07 100644 --- a/test/core/test-profile.c +++ b/test/core/test-profile.c @@ -613,7 +613,7 @@ read_and_drop_on_floor (int fd, char *allocated; char not_allocated[512+PAYLOAD_SIZE]; - g_assert (count < (int) sizeof(not_allocated)); + g_assert_cmpint (count, <, (int) sizeof (not_allocated)); if (fake_malloc_overhead) { @@ -671,7 +671,7 @@ write_junk (int fd, char *allocated; char not_allocated[512+PAYLOAD_SIZE] = { '\0', }; - g_assert (count < (int) sizeof(not_allocated)); + g_assert_cmpint (count, <, (int) sizeof (not_allocated)); if (fake_malloc_overhead) { -- cgit v1.2.1 From 26620f4916f4e9bfe68c57e81ec58bd2ae1c7b9f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 26 Mar 2021 12:17:58 +0000 Subject: test: Use g_assert_true, g_assert_false for comparisons with TRUE, FALSE Signed-off-by: Simon McVittie --- dbus/dbus-gobject.c | 16 ++++++++-------- test/core/test-dbus-glib.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c index ad5ee8b..9c405d4 100644 --- a/dbus/dbus-gobject.c +++ b/dbus/dbus-gobject.c @@ -3341,11 +3341,11 @@ _dbus_gobject_test (const char *test_data_dir) g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpstr (arg_name, ==, "x"); - g_assert (arg_in == TRUE); + g_assert_true (arg_in); g_assert_cmpstr (arg_signature, ==, "u"); g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); - g_assert (arg_in == FALSE); + g_assert_false (arg_in); g_assert_cmpint (retval, ==, RETVAL_NONE); g_assert_cmpstr (arg_signature, ==, "u"); g_assert_cmpint (*arg, ==, '\0'); @@ -3356,12 +3356,12 @@ _dbus_gobject_test (const char *test_data_dir) g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpstr (arg_name, ==, "x"); - g_assert (arg_in == TRUE); + g_assert_true (arg_in); g_assert_cmpstr (arg_signature, ==, "u"); g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpint (retval, ==, RETVAL_NOERROR); - g_assert (arg_in == FALSE); + g_assert_false (arg_in); g_assert_cmpstr (arg_signature, ==, "u"); g_assert_cmpint (*arg, ==, '\0'); @@ -3371,12 +3371,12 @@ _dbus_gobject_test (const char *test_data_dir) g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpstr (arg_name, ==, "x"); - g_assert (arg_in == TRUE); + g_assert_true (arg_in); g_assert_cmpstr (arg_signature, ==, "u"); g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpint (retval, ==, RETVAL_ERROR); - g_assert (arg_in == FALSE); + g_assert_false (arg_in); g_assert_cmpstr (arg_signature, ==, "u"); g_assert_cmpint (*arg, ==, '\0'); @@ -3386,12 +3386,12 @@ _dbus_gobject_test (const char *test_data_dir) g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpstr (arg_name, ==, "val"); - g_assert (arg_in == TRUE); + g_assert_true (arg_in); g_assert_cmpstr (arg_signature, ==, "v"); g_assert_cmpint (*arg, !=, '\0'); arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature); g_assert_cmpint (retval, ==, RETVAL_NONE); - g_assert (arg_in == FALSE); + g_assert_false (arg_in); g_assert_cmpstr (arg_signature, ==, "s"); g_assert_cmpint (*arg, ==, '\0'); diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c index 3633677..0807193 100644 --- a/test/core/test-dbus-glib.c +++ b/test/core/test-dbus-glib.c @@ -2212,7 +2212,7 @@ main (int argc, char **argv) G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed GetProperty call of \"should-be-hidden\" property", error); g_assert (G_VALUE_HOLDS_BOOLEAN (&value)); - g_assert (g_value_get_boolean (&value) == FALSE); + g_assert_false (g_value_get_boolean (&value)); g_value_unset (&value); } @@ -2254,7 +2254,7 @@ main (int argc, char **argv) G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed GetProperty call of \"should-be-hidden\" property", error); g_assert (G_VALUE_HOLDS_BOOLEAN (&value)); - g_assert (g_value_get_boolean (&value) == FALSE); + g_assert_false (g_value_get_boolean (&value)); g_value_unset (&value); } -- cgit v1.2.1 From 344e005c7cdf86755f8c014bb87e2bd8123c5116 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 26 Mar 2021 12:19:20 +0000 Subject: test: Replace remaining g_assert (!x) with g_assert_false (x) Signed-off-by: Simon McVittie --- test/core/private.c | 2 +- test/core/proxy-peer.c | 2 +- test/core/test-gvariant.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/core/private.c b/test/core/private.c index 7969ce8..01c1c4f 100644 --- a/test/core/private.c +++ b/test/core/private.c @@ -239,7 +239,7 @@ test_timeout (Fixture *f, G_TYPE_INVALID); g_assert_error (error, DBUS_GERROR, DBUS_GERROR_NO_REPLY); - g_assert (!ok); + g_assert_false (ok); g_clear_error (&error); } diff --git a/test/core/proxy-peer.c b/test/core/proxy-peer.c index 656e704..085305b 100644 --- a/test/core/proxy-peer.c +++ b/test/core/proxy-peer.c @@ -192,7 +192,7 @@ test_disconnect (Fixture *f, ok = dbus_g_proxy_end_call (f->proxy, fail, &error, G_TYPE_INVALID); g_assert_error (error, DBUS_GERROR, DBUS_GERROR_DISCONNECTED); - g_assert (!ok); + g_assert_false (ok); g_clear_error (&error); while (!f->proxy_destroyed) diff --git a/test/core/test-gvariant.c b/test/core/test-gvariant.c index 6031afa..f12a46f 100644 --- a/test/core/test-gvariant.c +++ b/test/core/test-gvariant.c @@ -184,7 +184,7 @@ test_simple_not_equiv (void) v1 = g_variant_new_int32 (1982); v2 = g_variant_new_int32 (1984); - g_assert (!test_g_variant_equivalent (v1, v2)); + g_assert_false (test_g_variant_equivalent (v1, v2)); g_variant_unref (v1); g_variant_unref (v2); @@ -209,7 +209,7 @@ test_array_not_equiv (void) g_variant_builder_add (&b, "v", g_variant_new_object_path ("/cats/escher")); v2 = g_variant_builder_end (&b); - g_assert (!test_g_variant_equivalent (v1, v2)); + g_assert_false (test_g_variant_equivalent (v1, v2)); g_variant_unref (v1); g_variant_unref (v2); @@ -259,7 +259,7 @@ test_map_not_equiv1 (void) g_variant_builder_add (&b, "{os}", "/cats/rory", "Rory Cat"); v2 = g_variant_builder_end (&b); - g_assert (!test_g_variant_equivalent (v1, v2)); + g_assert_false (test_g_variant_equivalent (v1, v2)); g_variant_unref (v1); g_variant_unref (v2); @@ -283,7 +283,7 @@ test_map_not_equiv2 (void) g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Cat"); v2 = g_variant_builder_end (&b); - g_assert (!test_g_variant_equivalent (v1, v2)); + g_assert_false (test_g_variant_equivalent (v1, v2)); g_variant_unref (v1); g_variant_unref (v2); -- cgit v1.2.1 From a23a0a2e65329ee93e960c36ec2aec603fb8fd90 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 26 Mar 2021 12:21:45 +0000 Subject: test: Replace remaining assertions with g_assert_true() Signed-off-by: Simon McVittie --- test/core/error-mapping.c | 2 +- test/core/manual/invalid-usage.c | 2 +- test/core/private.c | 10 +++++----- test/core/proxy-noc.c | 4 ++-- test/core/proxy-peer.c | 10 +++++----- test/core/registrations.c | 34 +++++++++++++++++----------------- test/core/shared-bus.c | 8 ++++---- test/core/test-dbus-glib.c | 32 ++++++++++++++++---------------- test/core/test-gvariant.c | 30 +++++++++++++++--------------- 9 files changed, 66 insertions(+), 66 deletions(-) diff --git a/test/core/error-mapping.c b/test/core/error-mapping.c index 764275f..58306b4 100644 --- a/test/core/error-mapping.c +++ b/test/core/error-mapping.c @@ -91,7 +91,7 @@ setup (Fixture *f, g_assert_nonnull (f->conn); f->object = g_object_new (MY_TYPE_OBJECT, NULL); - g_assert (MY_IS_OBJECT (f->object)); + g_assert_true (MY_IS_OBJECT (f->object)); dbus_g_connection_register_g_object (f->conn, "/com/example/Test/Object", f->object); diff --git a/test/core/manual/invalid-usage.c b/test/core/manual/invalid-usage.c index 8d3302a..e87007d 100644 --- a/test/core/manual/invalid-usage.c +++ b/test/core/manual/invalid-usage.c @@ -75,7 +75,7 @@ setup (Fixture *f, g_assert_nonnull (f->proxy); f->object = g_object_new (MY_TYPE_OBJECT, NULL); - g_assert (MY_IS_OBJECT (f->object)); + g_assert_true (MY_IS_OBJECT (f->object)); dbus_g_connection_register_g_object (f->conn, "/com/example/Test/Object", f->object); diff --git a/test/core/private.c b/test/core/private.c index 01c1c4f..eb966b9 100644 --- a/test/core/private.c +++ b/test/core/private.c @@ -62,8 +62,8 @@ call_cb (DBusGProxy *proxy, { Fixture *f = user_data; - g_assert (proxy == f->proxy); - g_assert (call == f->call); + g_assert_true (proxy == f->proxy); + g_assert_true (call == f->call); f->in_flight--; } @@ -75,7 +75,7 @@ frobnicate_cb (DBusGProxy *proxy, { Fixture *f = user_data; - g_assert (proxy == f->proxy); + g_assert_true (proxy == f->proxy); f->in_flight--; @@ -94,7 +94,7 @@ setup (Fixture *f, g_assert_nonnull (f->bus); f->object = g_object_new (MY_TYPE_OBJECT, NULL); - g_assert (MY_IS_OBJECT (f->object)); + g_assert_true (MY_IS_OBJECT (f->object)); dbus_g_connection_register_g_object (f->bus, "/object", (GObject *) f->object); @@ -169,7 +169,7 @@ test_call (Fixture *f, G_TYPE_INVALID); g_assert_no_error (error); - g_assert (ok); + g_assert_true (ok); g_assert_cmpuint (result, ==, 667); } diff --git a/test/core/proxy-noc.c b/test/core/proxy-noc.c index d6a026a..843f1c3 100644 --- a/test/core/proxy-noc.c +++ b/test/core/proxy-noc.c @@ -84,7 +84,7 @@ auth_result_cb (DBusGProxy *proxy, { Fixture *f = user_data; - g_assert (proxy == f->proxy); + g_assert_true (proxy == f->proxy); g_ptr_array_add (f->auth_results, g_strdup (res)); } @@ -125,7 +125,7 @@ setup (Fixture *f, f->proxy = dbus_g_proxy_new_for_name (f->client_gconn, WELL_KNOWN_NAME, PATH, IFACE); - g_assert (DBUS_IS_G_PROXY (f->proxy)); + g_assert_true (DBUS_IS_G_PROXY (f->proxy)); /* The proxy is listening for the signal. */ f->auth_results = g_ptr_array_new_with_free_func (g_free); diff --git a/test/core/proxy-peer.c b/test/core/proxy-peer.c index 085305b..87d8d0a 100644 --- a/test/core/proxy-peer.c +++ b/test/core/proxy-peer.c @@ -81,7 +81,7 @@ destroy_cb (DBusGProxy *proxy, { Fixture *f = user_data; - g_assert (proxy == f->proxy); + g_assert_true (proxy == f->proxy); f->proxy_destroyed = TRUE; } @@ -124,7 +124,7 @@ setup (Fixture *f, "/org/freedesktop/DBus/GLib/Tests/MyTestObject", "org.freedesktop.DBus.GLib.Tests.MyObject"); g_assert_nonnull (f->proxy); - g_assert (DBUS_IS_G_PROXY (f->proxy)); + g_assert_true (DBUS_IS_G_PROXY (f->proxy)); g_signal_connect (f->proxy, "destroy", G_CALLBACK (destroy_cb), f); @@ -141,7 +141,7 @@ call_cb (DBusGProxy *proxy, gboolean found; found = g_hash_table_remove (f->in_flight, call); - g_assert (found); + g_assert_true (found); g_hash_table_insert (f->completed, call, call); } @@ -165,11 +165,11 @@ test_method (Fixture *f, } ok = g_hash_table_remove (f->completed, call); - g_assert (ok); + g_assert_true (ok); ok = dbus_g_proxy_end_call (f->proxy, call, &error, G_TYPE_INVALID); g_assert_no_error (error); - g_assert (ok); + g_assert_true (ok); } static void diff --git a/test/core/registrations.c b/test/core/registrations.c index 0c2fb55..621f9d1 100644 --- a/test/core/registrations.c +++ b/test/core/registrations.c @@ -82,7 +82,7 @@ setup (Fixture *f, g_assert_nonnull (f->bus2); f->object = g_object_new (MY_TYPE_OBJECT, NULL); - g_assert (MY_IS_OBJECT (f->object)); + g_assert_true (MY_IS_OBJECT (f->object)); } static void @@ -124,7 +124,7 @@ test_lookup (Fixture *f, g_test_bug ("5688"); dbus_g_connection_register_g_object (f->bus, "/foo", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); /* this was briefly broken while fixing fd.o#5688 */ g_assert_null (dbus_g_connection_lookup_g_object (f->bus, "/bar")); @@ -138,7 +138,7 @@ test_unregister (Fixture *f, g_test_bug ("21219"); dbus_g_connection_register_g_object (f->bus, "/foo", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); dbus_g_connection_unregister_g_object (f->bus, f->object); g_assert_null (dbus_g_connection_lookup_g_object (f->bus, "/foo")); @@ -154,7 +154,7 @@ test_unregister_on_last_unref (Fixture *f, g_object_add_weak_pointer (weak_pointer, &weak_pointer); dbus_g_connection_register_g_object (f->bus, "/foo", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); /* implicit unregistration by the last-unref of the object */ g_object_unref (f->object); @@ -170,7 +170,7 @@ test_unregister_on_forced_dispose (Fixture *f, gconstpointer test_data G_GNUC_UNUSED) { dbus_g_connection_register_g_object (f->bus, "/foo", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); /* implicit unregistration by dispose() of the object (don't try * this at home) */ @@ -184,7 +184,7 @@ test_reregister (Fixture *f, gconstpointer test_data G_GNUC_UNUSED) { dbus_g_connection_register_g_object (f->bus, "/foo", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); /* Before 0.82, re-registering the same object path was leaky but successful. @@ -193,7 +193,7 @@ test_reregister (Fixture *f, * record of the registrations (while leaving the object registered with * libdbus). */ dbus_g_connection_register_g_object (f->bus, "/foo", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); /* This would critical in 0.84. */ @@ -251,9 +251,9 @@ test_twice (Fixture *f, dbus_g_connection_register_g_object (f->bus2, "/bar", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus2, "/bar") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus2, "/bar") == f->object); dbus_bus_add_match (dbus_g_connection_get_connection (f->bus), @@ -261,7 +261,7 @@ test_twice (Fixture *f, assert_no_error (&f->dbus_error); mem = dbus_connection_add_filter (dbus_g_connection_get_connection (f->bus), frobnicate_cb, f, NULL); - g_assert (mem); + g_assert_true (mem); my_object_emit_frobnicate ((MyObject *) f->object, NULL); @@ -299,10 +299,10 @@ test_clean_slate (Fixture *f, assert_no_error (&f->dbus_error); mem = dbus_connection_add_filter (dbus_g_connection_get_connection (f->bus), frobnicate_cb, f, NULL); - g_assert (mem); + g_assert_true (mem); dbus_g_connection_register_g_object (f->bus, "/foo", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); my_object_emit_frobnicate ((MyObject *) f->object, NULL); @@ -317,7 +317,7 @@ test_clean_slate (Fixture *f, * in the same location */ dbus_g_connection_unregister_g_object (f->bus, f->object); dbus_g_connection_register_g_object (f->bus, "/foo", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); /* bug: in 0.92, this would be emitted twice because the hook was added @@ -334,7 +334,7 @@ test_clean_slate (Fixture *f, * at a different location */ dbus_g_connection_unregister_g_object (f->bus, f->object); dbus_g_connection_register_g_object (f->bus2, "/bar", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus2, "/bar") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus2, "/bar") == f->object); my_object_emit_frobnicate ((MyObject *) f->object, NULL); @@ -383,7 +383,7 @@ objectified_cb (DBusConnection *conn, if (dbus_error_is_set (&e)) g_error ("%s: %s", e.name, e.message); - g_assert (ok); + g_assert_true (ok); g_assert_cmpstr (path, ==, "/foo"); f->received_objectified = TRUE; @@ -401,7 +401,7 @@ test_marshal_object (Fixture *f, g_test_bug ("37852"); dbus_g_connection_register_g_object (f->bus, "/foo", f->object); - g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + g_assert_true (dbus_g_connection_lookup_g_object (f->bus, "/foo") == f->object); dbus_bus_add_match (dbus_g_connection_get_connection (f->bus), @@ -409,7 +409,7 @@ test_marshal_object (Fixture *f, assert_no_error (&f->dbus_error); mem = dbus_connection_add_filter (dbus_g_connection_get_connection (f->bus), objectified_cb, f, NULL); - g_assert (mem); + g_assert_true (mem); my_object_emit_objectified ((MyObject *) f->object, f->object); diff --git a/test/core/shared-bus.c b/test/core/shared-bus.c index a69094d..df998ed 100644 --- a/test/core/shared-bus.c +++ b/test/core/shared-bus.c @@ -110,14 +110,14 @@ test_shared_bus (Fixture *f, dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (f->bus), FALSE); - g_assert (f->bus == dbus_g_bus_get (DBUS_BUS_SESSION, NULL)); - g_assert (f->bus == dbus_g_bus_get (DBUS_BUS_SESSION, NULL)); - g_assert (f->bus == dbus_g_bus_get (DBUS_BUS_SESSION, NULL)); + g_assert_true (f->bus == dbus_g_bus_get (DBUS_BUS_SESSION, NULL)); + g_assert_true (f->bus == dbus_g_bus_get (DBUS_BUS_SESSION, NULL)); + g_assert_true (f->bus == dbus_g_bus_get (DBUS_BUS_SESSION, NULL)); f->priv = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error); g_assert_no_error (f->error); g_assert_nonnull (f->priv); - g_assert (f->priv != f->bus); + g_assert_true (f->priv != f->bus); dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (f->priv), FALSE); } diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c index 0807193..1a544d5 100644 --- a/test/core/test-dbus-glib.c +++ b/test/core/test-dbus-glib.c @@ -232,7 +232,7 @@ sig1_signal_handler (DBusGProxy *proxy, g_assert_cmpstr (str0, ==, "baz"); - g_assert (G_VALUE_HOLDS_STRING (value)); + g_assert_true (G_VALUE_HOLDS_STRING (value)); g_assert_cmpstr (g_value_get_string (value), ==, "bar"); @@ -272,7 +272,7 @@ echo_received_cb (DBusGProxy *proxy, GError *error; char *echo_data; - g_assert (call == echo_call); + g_assert_true (call == echo_call); g_assert_null (data); error = NULL; @@ -1202,10 +1202,10 @@ main (int argc, char **argv) g_assert_nonnull (vals_ret); g_assert_cmpuint (vals_ret->n_values, ==, 2); - g_assert (G_VALUE_HOLDS_UINT (g_value_array_get_nth (vals_ret, 0))); + g_assert_true (G_VALUE_HOLDS_UINT (g_value_array_get_nth (vals_ret, 0))); g_assert_cmpuint (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)), ==, 43); - g_assert (G_VALUE_TYPE (g_value_array_get_nth (vals_ret, 1)) == DBUS_TYPE_G_OBJECT_PATH); + g_assert_true (G_VALUE_TYPE (g_value_array_get_nth (vals_ret, 1)) == DBUS_TYPE_G_OBJECT_PATH); g_assert_cmpstr ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2", ==, g_value_get_boxed (g_value_array_get_nth (vals_ret, 1))); @@ -1265,12 +1265,12 @@ main (int argc, char **argv) val = g_hash_table_lookup (ret_table, "foo"); g_assert_nonnull (val); - g_assert (G_VALUE_HOLDS_STRING (val)); + g_assert_true (G_VALUE_HOLDS_STRING (val)); g_assert_cmpstr ("42", ==, g_value_get_string (val)); val = g_hash_table_lookup (ret_table, "bar"); g_assert_nonnull (val); - g_assert (G_VALUE_HOLDS_STRING (val)); + g_assert_true (G_VALUE_HOLDS_STRING (val)); g_assert_cmpstr ("hello", ==, g_value_get_string (val)); g_hash_table_destroy (table); @@ -2074,7 +2074,7 @@ main (int argc, char **argv) G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty call", error); - g_assert (G_VALUE_HOLDS (&value, G_TYPE_STRING)); + g_assert_true (G_VALUE_HOLDS (&value, G_TYPE_STRING)); g_assert_cmpstr (g_value_get_string (&value), ==, ""); g_value_unset (&value); } @@ -2101,7 +2101,7 @@ main (int argc, char **argv) G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty no-touching call", error); - g_assert (G_VALUE_HOLDS (&value, G_TYPE_UINT)); + g_assert_true (G_VALUE_HOLDS (&value, G_TYPE_UINT)); g_assert_cmpuint (g_value_get_uint (&value), ==, 42); g_value_unset (&value); } @@ -2129,7 +2129,7 @@ main (int argc, char **argv) G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty call", error); - g_assert (G_VALUE_HOLDS (&value, G_TYPE_UINT)); + g_assert_true (G_VALUE_HOLDS (&value, G_TYPE_UINT)); g_assert_cmpuint (g_value_get_uint (&value), ==, 42); g_value_unset (&value); } @@ -2143,7 +2143,7 @@ main (int argc, char **argv) G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty call", error); - g_assert (G_VALUE_HOLDS (&value, G_TYPE_STRING)); + g_assert_true (G_VALUE_HOLDS (&value, G_TYPE_STRING)); g_assert_cmpstr (g_value_get_string (&value), ==, "testing value"); g_value_unset (&value); } @@ -2157,7 +2157,7 @@ main (int argc, char **argv) G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty call", error); - g_assert (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE)); + g_assert_true (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE)); g_value_unset (&value); } @@ -2170,7 +2170,7 @@ main (int argc, char **argv) G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty call", error); - g_assert (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE)); + g_assert_true (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE)); g_value_unset (&value); } @@ -2183,7 +2183,7 @@ main (int argc, char **argv) G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetProperty call", error); - g_assert (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE)); + g_assert_true (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE)); g_value_unset (&value); } @@ -2211,7 +2211,7 @@ main (int argc, char **argv) G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed GetProperty call of \"should-be-hidden\" property", error); - g_assert (G_VALUE_HOLDS_BOOLEAN (&value)); + g_assert_true (G_VALUE_HOLDS_BOOLEAN (&value)); g_assert_false (g_value_get_boolean (&value)); g_value_unset (&value); } @@ -2253,7 +2253,7 @@ main (int argc, char **argv) G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) lose_gerror ("Failed GetProperty call of \"should-be-hidden\" property", error); - g_assert (G_VALUE_HOLDS_BOOLEAN (&value)); + g_assert_true (G_VALUE_HOLDS_BOOLEAN (&value)); g_assert_false (g_value_get_boolean (&value)); g_value_unset (&value); } @@ -2386,7 +2386,7 @@ main (int argc, char **argv) if (privconn == NULL) lose_gerror ("Failed to open private connection to bus", error); - g_assert (privconn != connection); + g_assert_true (privconn != connection); proxy = dbus_g_proxy_new_for_name (privconn, "org.freedesktop.DBus.GLib.TestService", diff --git a/test/core/test-gvariant.c b/test/core/test-gvariant.c index f12a46f..8a6bced 100644 --- a/test/core/test-gvariant.c +++ b/test/core/test-gvariant.c @@ -170,7 +170,7 @@ test_simple_equiv (void) v1 = g_variant_new_int32 (1984); v2 = g_variant_new_int32 (1984); - g_assert (test_g_variant_equivalent (v1, v2)); + g_assert_true (test_g_variant_equivalent (v1, v2)); g_variant_unref (v1); g_variant_unref (v2); @@ -234,7 +234,7 @@ test_map_equiv (void) g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith"); v2 = g_variant_builder_end (&b); - g_assert (test_g_variant_equivalent (v1, v2)); + g_assert_true (test_g_variant_equivalent (v1, v2)); g_variant_unref (v1); g_variant_unref (v2); @@ -304,7 +304,7 @@ test_i (void) varc = g_variant_new_int32 (1984); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -324,7 +324,7 @@ test_s (void) varc = g_variant_new_string ("Orwell"); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -344,7 +344,7 @@ test_o (void) varc = g_variant_new_object_path ("/cats/escher"); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -372,7 +372,7 @@ test_us (void) varc = g_variant_new ("(us)", 1984, "Orwell"); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -409,7 +409,7 @@ test_a_os (void) g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith"); varc = g_variant_builder_end (&b); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -453,7 +453,7 @@ test_av (void) g_variant_builder_add (&b, "v", g_variant_new_object_path ("/cats/escher")); varc = g_variant_builder_end (&b); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -486,7 +486,7 @@ test_ab (void) g_variant_builder_add (&b, "b", FALSE); varc = g_variant_builder_end (&b); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -519,7 +519,7 @@ test_ai (void) g_variant_builder_add (&b, "i", 1066); varc = g_variant_builder_end (&b); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -552,7 +552,7 @@ test_au (void) g_variant_builder_add (&b, "u", 1066); varc = g_variant_builder_end (&b); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -592,7 +592,7 @@ test_ax (void) g_variant_builder_add (&b, "x", G_GINT64_CONSTANT (1066)); varc = g_variant_builder_end (&b); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -631,7 +631,7 @@ test_at (void) g_variant_builder_add (&b, "t", G_GUINT64_CONSTANT (1066)); varc = g_variant_builder_end (&b); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -664,7 +664,7 @@ test_ay (void) g_variant_builder_add (&b, "y", 42); varc = g_variant_builder_end (&b); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); @@ -684,7 +684,7 @@ test_g (void) varc = g_variant_new_signature ("a{u(ua{sa{sv}})}"); - g_assert (test_g_variant_equivalent (var, varc)); + g_assert_true (test_g_variant_equivalent (var, varc)); g_variant_unref (var); g_variant_unref (varc); -- cgit v1.2.1