mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
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:
parent
b79fbc5c3f
commit
f66052fc87
@ -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));
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user