mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 15:06:14 +01:00
tests: Port various tests to use g_assert_cmpvariant()
This should improve test error reporting a little. Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
8a2fa212e7
commit
d289ef449b
@ -515,7 +515,7 @@ test_parse_detailed (void)
|
||||
expected = g_variant_parse (NULL, testcases[i].expected_target, NULL, NULL, NULL);
|
||||
g_assert (expected);
|
||||
|
||||
g_assert (g_variant_equal (expected, target));
|
||||
g_assert_cmpvariant (expected, target);
|
||||
g_variant_unref (expected);
|
||||
g_variant_unref (target);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ message_copy (void)
|
||||
copy_val = g_dbus_message_get_header (m, m_headers[n]);
|
||||
g_assert (m_val != NULL);
|
||||
g_assert (copy_val != NULL);
|
||||
g_assert (g_variant_equal (m_val, copy_val));
|
||||
g_assert_cmpvariant (m_val, copy_val);
|
||||
}
|
||||
g_assert_cmpint (n, >, 0); /* make sure we actually compared headers etc. */
|
||||
g_assert_cmpint (copy_headers[n], ==, 0);
|
||||
|
@ -526,7 +526,6 @@ check_serialization (GVariant *value,
|
||||
GError *error;
|
||||
DBusError dbus_error;
|
||||
gchar *s;
|
||||
gchar *s1;
|
||||
guint n;
|
||||
|
||||
message = g_dbus_message_new ();
|
||||
@ -618,17 +617,7 @@ check_serialization (GVariant *value,
|
||||
else
|
||||
{
|
||||
g_assert (g_dbus_message_get_body (recovered_message) != NULL);
|
||||
if (!g_variant_equal (g_dbus_message_get_body (recovered_message), value))
|
||||
{
|
||||
s = g_variant_print (g_dbus_message_get_body (recovered_message), TRUE);
|
||||
s1 = g_variant_print (value, TRUE);
|
||||
g_printerr ("Recovered value:\n%s\ndoes not match given value\n%s\n",
|
||||
s,
|
||||
s1);
|
||||
g_free (s);
|
||||
g_free (s1);
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
g_assert_cmpvariant (g_dbus_message_get_body (recovered_message), value);
|
||||
}
|
||||
g_object_unref (recovered_message);
|
||||
g_free (blob);
|
||||
|
@ -933,7 +933,7 @@ check_bar_proxy (FooiGenBar *proxy,
|
||||
g_assert_cmpuint (g_strv_length ((gchar **) ret_array_of_objpaths), ==,
|
||||
g_strv_length ((gchar **) array_of_objpaths));
|
||||
g_assert_nonnull (ret_array_of_signatures);
|
||||
g_assert_true (g_variant_equal (ret_array_of_signatures, array_of_signatures));
|
||||
g_assert_cmpvariant (ret_array_of_signatures, array_of_signatures);
|
||||
g_assert_nonnull (ret_array_of_bytestrings);
|
||||
g_assert_cmpuint (g_strv_length ((gchar **) ret_array_of_bytestrings), ==,
|
||||
g_strv_length ((gchar **) array_of_bytestrings));
|
||||
|
@ -4406,67 +4406,67 @@ test_equal (void)
|
||||
|
||||
a = untrusted (g_variant_new_byte (5));
|
||||
b = g_variant_get_normal_form (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_int16 (G_MININT16));
|
||||
b = g_variant_get_normal_form (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_uint16 (0));
|
||||
b = g_variant_get_normal_form (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_int32 (G_MININT32));
|
||||
b = g_variant_get_normal_form (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_uint32 (0));
|
||||
b = g_variant_get_normal_form (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_int64 (G_MININT64));
|
||||
b = g_variant_get_normal_form (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_uint64 (0));
|
||||
b = g_variant_get_normal_form (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_double (G_MINDOUBLE));
|
||||
b = g_variant_get_normal_form (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_string ("abc"));
|
||||
g_assert_true (g_variant_equal (a, a));
|
||||
g_assert_cmpvariant (a, a);
|
||||
b = g_variant_get_normal_form (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_object_path ("/abc"));
|
||||
g_assert_true (g_variant_equal (a, a));
|
||||
g_assert_cmpvariant (a, a);
|
||||
b = g_variant_get_normal_form (a);
|
||||
a = untrusted (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_signature ("g"));
|
||||
g_assert_true (g_variant_equal (a, a));
|
||||
g_assert_cmpvariant (a, a);
|
||||
b = g_variant_get_normal_form (a);
|
||||
a = untrusted (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
a = untrusted (g_variant_new_boolean (FALSE));
|
||||
b = g_variant_get_normal_form (a);
|
||||
g_assert_true (g_variant_equal (a, b));
|
||||
g_assert_cmpvariant (a, b);
|
||||
g_variant_unref (a);
|
||||
g_variant_unref (b);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user