mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-10 19:24:04 +02:00
test-gvariant: Add and use assert_cmpstrv helper
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
@@ -2956,6 +2956,18 @@ test_varargs_empty_array (void)
|
|||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
assert_cmpstrv (const gchar **strv1, const gchar **strv2)
|
||||||
|
{
|
||||||
|
gsize i;
|
||||||
|
|
||||||
|
for (i = 0; strv1[i] != NULL && strv2[i] != NULL; i++)
|
||||||
|
g_assert_cmpstr (strv1[i], ==, strv2[i]);
|
||||||
|
|
||||||
|
g_assert_null (strv1[i]);
|
||||||
|
g_assert_null (strv2[i]);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_varargs (void)
|
test_varargs (void)
|
||||||
{
|
{
|
||||||
@@ -3105,12 +3117,8 @@ test_varargs (void)
|
|||||||
g_variant_iter_next (&tuple, "^a&s", &strv);
|
g_variant_iter_next (&tuple, "^a&s", &strv);
|
||||||
g_variant_iter_next (&tuple, "^as", &my_strv);
|
g_variant_iter_next (&tuple, "^as", &my_strv);
|
||||||
|
|
||||||
g_assert_cmpstr (strv[0], ==, "/hello");
|
assert_cmpstrv (strv, strvector);
|
||||||
g_assert_cmpstr (strv[1], ==, "/world");
|
assert_cmpstrv ((const char **)my_strv, strvector);
|
||||||
g_assert_null (strv[2]);
|
|
||||||
g_assert_cmpstr (my_strv[0], ==, "/hello");
|
|
||||||
g_assert_cmpstr (my_strv[1], ==, "/world");
|
|
||||||
g_assert_null (my_strv[2]);
|
|
||||||
|
|
||||||
g_variant_unref (value);
|
g_variant_unref (value);
|
||||||
g_strfreev (my_strv);
|
g_strfreev (my_strv);
|
||||||
@@ -3179,12 +3187,8 @@ test_varargs (void)
|
|||||||
g_variant_iter_next (&tuple, "^a&ay", &strv);
|
g_variant_iter_next (&tuple, "^a&ay", &strv);
|
||||||
g_variant_iter_next (&tuple, "^aay", &my_strv);
|
g_variant_iter_next (&tuple, "^aay", &my_strv);
|
||||||
|
|
||||||
g_assert_cmpstr (strv[0], ==, "/hello");
|
assert_cmpstrv (strv, strvector);
|
||||||
g_assert_cmpstr (strv[1], ==, "/world");
|
assert_cmpstrv ((const char **)my_strv, strvector);
|
||||||
g_assert_null (strv[2]);
|
|
||||||
g_assert_cmpstr (my_strv[0], ==, "/hello");
|
|
||||||
g_assert_cmpstr (my_strv[1], ==, "/world");
|
|
||||||
g_assert_null (my_strv[2]);
|
|
||||||
|
|
||||||
g_variant_unref (value);
|
g_variant_unref (value);
|
||||||
g_strfreev (my_strv);
|
g_strfreev (my_strv);
|
||||||
@@ -3232,12 +3236,8 @@ test_varargs (void)
|
|||||||
g_variant_iter_next (&tuple, "^a&o", &strv);
|
g_variant_iter_next (&tuple, "^a&o", &strv);
|
||||||
g_variant_iter_next (&tuple, "^ao", &my_strv);
|
g_variant_iter_next (&tuple, "^ao", &my_strv);
|
||||||
|
|
||||||
g_assert_cmpstr (strv[0], ==, "/hello");
|
assert_cmpstrv (strv, strvector);
|
||||||
g_assert_cmpstr (strv[1], ==, "/world");
|
assert_cmpstrv ((const char **)my_strv, strvector);
|
||||||
g_assert_null (strv[2]);
|
|
||||||
g_assert_cmpstr (my_strv[0], ==, "/hello");
|
|
||||||
g_assert_cmpstr (my_strv[1], ==, "/world");
|
|
||||||
g_assert_null (my_strv[2]);
|
|
||||||
|
|
||||||
g_variant_unref (value);
|
g_variant_unref (value);
|
||||||
g_strfreev (my_strv);
|
g_strfreev (my_strv);
|
||||||
|
Reference in New Issue
Block a user