Commit 6f9838a8 authored by Simon McVittie's avatar Simon McVittie
Browse files

test: Compare strings with g_assert_cmpstr()



Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
parent 0cf441eb
......@@ -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');
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment