GVariant: support comparing booleans

g_variant_compare() is documented as working on booleans but somehow
this case was missed.  Add it and test it.

Problem discovered by Charles Kerr.
This commit is contained in:
Ryan Lortie 2012-07-06 17:27:54 -04:00
parent b79fbc5c3f
commit f66052fc87
2 changed files with 9 additions and 0 deletions

View File

@ -2748,6 +2748,10 @@ g_variant_compare (gconstpointer one,
switch (g_variant_classify (a))
{
case G_VARIANT_CLASS_BOOLEAN:
return g_variant_get_boolean (a) -
g_variant_get_boolean (b);
case G_VARIANT_CLASS_BYTE:
return ((gint) g_variant_get_byte (a)) -
((gint) g_variant_get_byte (b));

View File

@ -4079,6 +4079,11 @@ test_compare (void)
g_assert (g_variant_compare (a, b) < 0);
g_variant_unref (a);
g_variant_unref (b);
a = g_variant_new_boolean (FALSE);
b = g_variant_new_boolean (TRUE);
g_assert (g_variant_compare (a, b) < 0);
g_variant_unref (a);
g_variant_unref (b);
}
static void