glib/gvariant: add test for g_variant_type_hash()

This commit is contained in:
Christian Hergert 2024-09-25 10:04:28 -07:00
parent 1850b5c1ab
commit 2deb5dcfc0

View File

@ -5830,6 +5830,24 @@ test_unaligned_construction (void)
} }
} }
static void
test_g_variant_type_hash (void)
{
char mas[4] = {'m', 'a', 's', 0};
g_assert_cmpint (g_variant_type_hash (G_VARIANT_TYPE ("a(ay)")),
!=,
g_variant_type_hash (G_VARIANT_TYPE ("aay")));
g_assert_cmpint (g_variant_type_hash (G_VARIANT_TYPE ("a{sv}")),
!=,
g_variant_type_hash (G_VARIANT_TYPE ("a(sv)")));
g_assert_cmpint (g_variant_type_hash (G_VARIANT_TYPE ("mas")),
==,
g_variant_type_hash ((const GVariantType *)mas));
}
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
@ -5935,5 +5953,8 @@ main (int argc, char **argv)
g_test_add_func ("/gvariant/unaligned-construction", g_test_add_func ("/gvariant/unaligned-construction",
test_unaligned_construction); test_unaligned_construction);
g_test_add_func ("/gvarianttype/hash",
test_g_variant_type_hash);
return g_test_run (); return g_test_run ();
} }