summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2021-03-26 12:27:57 +0000
committerSimon McVittie <smcv@collabora.com>2021-03-26 12:27:57 +0000
commit0383264db07b2bc4519719b34111bd6f939f0fe2 (patch)
tree57d04256496dd08f1e94b4b6674688155ac353ff
parent06a7fac32cfcd6c42fd6541a4d7770dc65588f68 (diff)
parenta23a0a2e65329ee93e960c36ec2aec603fb8fd90 (diff)
downloaddbus-glib-0383264db07b2bc4519719b34111bd6f939f0fe2.tar.gz
Merge branch 'wip/smcv/better-assertions' into 'master'
Use better assertions See merge request dbus/dbus-glib!3
-rw-r--r--dbus/dbus-gobject.c90
-rw-r--r--dbus/dbus-gvalue.c24
-rw-r--r--test/core/error-mapping.c8
-rw-r--r--test/core/manual/invalid-usage.c10
-rw-r--r--test/core/peer-client.c4
-rw-r--r--test/core/peer-on-bus.c4
-rw-r--r--test/core/private.c14
-rw-r--r--test/core/proxy-noc.c10
-rw-r--r--test/core/proxy-peer.c26
-rw-r--r--test/core/registrations.c66
-rw-r--r--test/core/shared-bus.c12
-rw-r--r--test/core/test-dbus-glib.c176
-rw-r--r--test/core/test-gvariant.c38
-rw-r--r--test/core/test-profile.c4
-rw-r--r--test/core/test-service-glib.c2
-rw-r--r--test/errors.c2
-rw-r--r--test/interfaces/test-client.c2
-rw-r--r--test/specialized-types.c6
18 files changed, 249 insertions, 249 deletions
diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c
index 4925cd8..9c405d4 100644
--- a/dbus/dbus-gobject.c
+++ b/dbus/dbus-gobject.c
@@ -3333,85 +3333,85 @@ _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 (!strcmp (arg_name, "x"));
- g_assert (arg_in == TRUE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg != '\0');
+ g_assert_cmpstr (arg_name, ==, "x");
+ 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 (retval == RETVAL_NONE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg == '\0');
+ g_assert_false (arg_in);
+ g_assert_cmpint (retval, ==, RETVAL_NONE);
+ g_assert_cmpstr (arg_signature, ==, "u");
+ 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 (!strcmp (arg_name, "x"));
- g_assert (arg_in == TRUE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg != '\0');
+ g_assert_cmpstr (arg_name, ==, "x");
+ 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 (retval == RETVAL_NOERROR);
- g_assert (arg_in == FALSE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg == '\0');
+ g_assert_cmpint (retval, ==, RETVAL_NOERROR);
+ g_assert_false (arg_in);
+ g_assert_cmpstr (arg_signature, ==, "u");
+ 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 (!strcmp (arg_name, "x"));
- g_assert (arg_in == TRUE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg != '\0');
+ g_assert_cmpstr (arg_name, ==, "x");
+ 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 (retval == RETVAL_ERROR);
- g_assert (arg_in == FALSE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg == '\0');
+ g_assert_cmpint (retval, ==, RETVAL_ERROR);
+ g_assert_false (arg_in);
+ g_assert_cmpstr (arg_signature, ==, "u");
+ 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 (!strcmp (arg_name, "val"));
- g_assert (arg_in == TRUE);
- g_assert (!strcmp (arg_signature, "v"));
- g_assert (*arg != '\0');
+ g_assert_cmpstr (arg_name, ==, "val");
+ 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 (retval == RETVAL_NONE);
- g_assert (arg_in == FALSE);
- g_assert (!strcmp (arg_signature, "s"));
- g_assert (*arg == '\0');
+ g_assert_cmpint (retval, ==, RETVAL_NONE);
+ g_assert_false (arg_in);
+ g_assert_cmpstr (arg_signature, ==, "s");
+ g_assert_cmpint (*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 5bb2b19..534e90a 100644
--- a/dbus/dbus-gvalue.c
+++ b/dbus/dbus-gvalue.c
@@ -2028,15 +2028,15 @@ assert_type_maps_to (GType gtype, const char *expected_sig)
{
char *sig;
sig = _dbus_gtype_to_signature (gtype);
- g_assert (sig != NULL);
- g_assert (!strcmp (expected_sig, sig));
+ g_assert_nonnull (sig);
+ g_assert_cmpstr (expected_sig, ==, sig);
g_free (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 (!strcmp (g_type_name (rectype), "GArray_guint_"));
+ 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 (!strcmp (g_type_name (rectype), "GHashTable_gchararray+gchararray_"));
+ 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/error-mapping.c b/test/core/error-mapping.c
index 84837fd..58306b4 100644
--- a/test/core/error-mapping.c
+++ b/test/core/error-mapping.c
@@ -88,17 +88,17 @@ 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));
+ g_assert_true (MY_IS_OBJECT (f->object));
dbus_g_connection_register_g_object (f->conn, "/com/example/Test/Object",
f->object);
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..e87007d 100644
--- a/test/core/manual/invalid-usage.c
+++ b/test/core/manual/invalid-usage.c
@@ -68,21 +68,21 @@ 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));
+ g_assert_true (MY_IS_OBJECT (f->object));
dbus_g_connection_register_g_object (f->conn, "/com/example/Test/Object",
f->object);
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..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);
@@ -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..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--;
@@ -91,10 +91,10 @@ 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));
+ 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);
}
@@ -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-noc.c b/test/core/proxy-noc.c
index 3f10eb3..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));
}
@@ -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,12 +120,12 @@ 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,
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 b225d94..87d8d0a 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);
@@ -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;
}
@@ -94,18 +94,18 @@ 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);
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);
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,8 +123,8 @@ 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 (DBUS_IS_G_PROXY (f->proxy));
+ g_assert_nonnull (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);
}
@@ -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)
@@ -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
@@ -187,12 +187,12 @@ 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);
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/registrations.c b/test/core/registrations.c
index 2c32e5a..621f9d1 100644
--- a/test/core/registrations.c
+++ b/test/core/registrations.c
@@ -76,13 +76,13 @@ 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));
+ g_assert_true (MY_IS_OBJECT (f->object));
}
static void
@@ -124,10 +124,10 @@ 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 (dbus_g_connection_lookup_g_object (f->bus, "/bar") == NULL);
+ g_assert_null (dbus_g_connection_lookup_g_object (f->bus, "/bar"));
}
static void
@@ -138,10 +138,10 @@ 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 (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL);
+ g_assert_null (dbus_g_connection_lookup_g_object (f->bus, "/foo"));
}
static void
@@ -154,15 +154,15 @@ 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);
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
@@ -170,13 +170,13 @@ 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) */
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
@@ -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,12 +193,12 @@ 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. */
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
@@ -214,15 +214,15 @@ 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)
{
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);
}
}
@@ -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);
@@ -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;
}
@@ -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);
@@ -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;
@@ -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 (
@@ -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 0f18880..df998ed 100644
--- a/test/core/shared-bus.c
+++ b/test/core/shared-bus.c
@@ -106,18 +106,18 @@ 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);
- 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 (f->priv != NULL);
- g_assert (f->priv != f->bus);
+ g_assert_nonnull (f->priv);
+ 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 4e050b2..1a544d5 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);
@@ -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_cmpint (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_true (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");
@@ -249,12 +249,12 @@ 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 (g_hash_table_lookup (table, "baz") != NULL);
- g_assert (!strcmp (g_hash_table_lookup (table, "baz"), "cow"));
- g_assert (g_hash_table_lookup (table, "bar") != NULL);
- g_assert (!strcmp (g_hash_table_lookup (table, "bar"), "foo"));
+ g_assert_nonnull (g_hash_table_lookup (table, "baz"));
+ g_assert_cmpstr (g_hash_table_lookup (table, "baz"), ==, "cow");
+ g_assert_nonnull (g_hash_table_lookup (table, "bar"));
+ g_assert_cmpstr (g_hash_table_lookup (table, "bar"), ==, "foo");
g_print ("Got Sig2 signal\n");
@@ -272,8 +272,8 @@ echo_received_cb (DBusGProxy *proxy,
GError *error;
char *echo_data;
- g_assert (call == echo_call);
- g_assert (data == NULL);
+ g_assert_true (call == echo_call);
+ g_assert_null (data);
error = NULL;
echo_data = NULL;
@@ -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);
@@ -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,
@@ -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,11 +600,11 @@ 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;
}
- g_assert (name_list[i] == NULL);
+ g_assert_null (name_list[i]);
g_strfreev (name_list);
@@ -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,15 +1199,15 @@ main (int argc, char **argv)
G_TYPE_INVALID))
lose_gerror ("Failed to complete SendCar call", error);
- g_assert (vals_ret != NULL);
- g_assert (vals_ret->n_values == 2);
+ 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 (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)) == 43);
+ 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 (!strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2",
- g_value_get_boxed (g_value_array_get_nth (vals_ret, 1))));
+ 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)));
g_free (val);
g_value_array_free (vals);
@@ -1260,18 +1260,18 @@ main (int argc, char **argv)
G_TYPE_INVALID))
lose_gerror ("Failed to complete ManyStringify call", error);
- g_assert (ret_table != NULL);
- g_assert (g_hash_table_size (ret_table) == 2);
+ g_assert_nonnull (ret_table);
+ g_assert_cmpuint (g_hash_table_size (ret_table), ==, 2);
val = g_hash_table_lookup (ret_table, "foo");
- g_assert (val != NULL);
- g_assert (G_VALUE_HOLDS_STRING (val));
- g_assert (!strcmp ("42", g_value_get_string (val)));
+ g_assert_nonnull (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 (val != NULL);
- g_assert (G_VALUE_HOLDS_STRING (val));
- g_assert (!strcmp ("hello", g_value_get_string (val)));
+ g_assert_nonnull (val);
+ g_assert_true (G_VALUE_HOLDS_STRING (val));
+ g_assert_cmpstr ("hello", ==, g_value_get_string (val));
g_hash_table_destroy (table);
g_hash_table_destroy (ret_table);
@@ -1312,19 +1312,19 @@ 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 (out_array->len == 2);
+ g_assert_nonnull (out_array);
+ g_assert_cmpuint (out_array->len, ==, 2);
uints = g_ptr_array_index (out_array, 0);
- g_assert (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_nonnull (uints);
+ 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 (uints);
- g_assert (uints->len == 1);
- g_assert (g_array_index (uints, guint, 0) == 30);
+ g_assert_nonnull (uints);
+ 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);
}
@@ -1520,40 +1520,40 @@ main (int argc, char **argv)
G_TYPE_INVALID))
lose_gerror ("Failed to complete DictOfDicts call", error);
- g_assert (ret_table != NULL);
- g_assert (g_hash_table_size (ret_table) == 2);
+ g_assert_nonnull (ret_table);
+ g_assert_cmpuint (g_hash_table_size (ret_table), ==, 2);
subtable = g_hash_table_lookup (ret_table, "dict1");
- g_assert(subtable);
- g_assert (g_hash_table_size (subtable) == 3);
+ g_assert_nonnull (subtable);
+ g_assert_cmpuint (g_hash_table_size (subtable), ==, 3);
val = g_hash_table_lookup (subtable, "foo");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict1 1", val));
+ g_assert_nonnull (val);
+ g_assert_cmpstr ("dict1 1", ==, val);
val = g_hash_table_lookup (subtable, "bar");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict1 2", val));
+ g_assert_nonnull (val);
+ g_assert_cmpstr ("dict1 2", ==, val);
val = g_hash_table_lookup (subtable, "baz");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict1 3", val));
+ g_assert_nonnull (val);
+ g_assert_cmpstr ("dict1 3", ==, val);
subtable = g_hash_table_lookup (ret_table, "dict2");
- g_assert(subtable);
- g_assert (g_hash_table_size (subtable) == 3);
+ g_assert_nonnull (subtable);
+ g_assert_cmpuint (g_hash_table_size (subtable), ==, 3);
val = g_hash_table_lookup (subtable, "foo");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict2 4", val));
+ g_assert_nonnull (val);
+ g_assert_cmpstr ("dict2 4", ==, val);
val = g_hash_table_lookup (subtable, "bar");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict2 5", val));
+ g_assert_nonnull (val);
+ g_assert_cmpstr ("dict2 5", ==, val);
val = g_hash_table_lookup (subtable, "baz");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict2 6", val));
+ g_assert_nonnull (val);
+ g_assert_cmpstr ("dict2 6", ==, val);
g_hash_table_destroy (table);
g_hash_table_destroy (ret_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);
@@ -2074,8 +2074,8 @@ 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 (!strcmp (g_value_get_string (&value), ""));
+ g_assert_true (G_VALUE_HOLDS (&value, G_TYPE_STRING));
+ g_assert_cmpstr (g_value_get_string (&value), ==, "");
g_value_unset (&value);
}
@@ -2101,8 +2101,8 @@ 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 (g_value_get_uint (&value) == 42);
+ g_assert_true (G_VALUE_HOLDS (&value, G_TYPE_UINT));
+ g_assert_cmpuint (g_value_get_uint (&value), ==, 42);
g_value_unset (&value);
}
@@ -2129,8 +2129,8 @@ 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 (g_value_get_uint (&value) == 42);
+ g_assert_true (G_VALUE_HOLDS (&value, G_TYPE_UINT));
+ g_assert_cmpuint (g_value_get_uint (&value), ==, 42);
g_value_unset (&value);
}
@@ -2143,8 +2143,8 @@ 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 (!strcmp (g_value_get_string (&value), "testing value"));
+ 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,8 +2211,8 @@ 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 (g_value_get_boolean (&value) == FALSE);
+ g_assert_true (G_VALUE_HOLDS_BOOLEAN (&value));
+ g_assert_false (g_value_get_boolean (&value));
g_value_unset (&value);
}
@@ -2253,8 +2253,8 @@ 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 (g_value_get_boolean (&value) == FALSE);
+ g_assert_true (G_VALUE_HOLDS_BOOLEAN (&value));
+ g_assert_false (g_value_get_boolean (&value));
g_value_unset (&value);
}
@@ -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",
@@ -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 6031afa..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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
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)
{
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..ce5d82d 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));
@@ -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);