From 2deb5dcfc01af0f2639a0033a30fcb3b33133af1 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 25 Sep 2024 10:04:28 -0700 Subject: [PATCH] glib/gvariant: add test for g_variant_type_hash() --- glib/tests/gvariant.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c index 2aa80d6da..d402e49a0 100644 --- a/glib/tests/gvariant.c +++ b/glib/tests/gvariant.c @@ -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 main (int argc, char **argv) { @@ -5935,5 +5953,8 @@ main (int argc, char **argv) g_test_add_func ("/gvariant/unaligned-construction", test_unaligned_construction); + g_test_add_func ("/gvarianttype/hash", + test_g_variant_type_hash); + return g_test_run (); }