mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
Add fundamental type and pspec for GVariant
Make G_TYPE_VARIANT a fundamental type instead of boxed, and add g_variant_{set,get,dup}_variant. Add GParamSpecVariant. Bug #610863.
This commit is contained in:
@@ -219,6 +219,15 @@ test_collection (void)
|
||||
error = collect (&value, G_TYPE_BOXED);
|
||||
g_assert (error == NULL);
|
||||
g_assert (g_value_get_gtype (&value) == G_TYPE_BOXED);
|
||||
|
||||
g_value_unset (&value);
|
||||
g_value_init (&value, G_TYPE_VARIANT);
|
||||
error = collect (&value, g_variant_new_uint32 (42));
|
||||
g_assert (error == NULL);
|
||||
g_assert (g_variant_is_of_type (g_value_get_variant (&value), G_VARIANT_TYPE ("u")));
|
||||
g_assert_cmpuint (g_variant_get_uint32 (g_value_get_variant (&value)), ==, 42);
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -357,18 +366,33 @@ test_copying (void)
|
||||
g_assert (error == NULL);
|
||||
g_assert (c == G_TYPE_BOXED);
|
||||
}
|
||||
|
||||
{
|
||||
GVariant *c = NULL;
|
||||
|
||||
g_value_unset (&value);
|
||||
g_value_init (&value, G_TYPE_VARIANT);
|
||||
g_value_set_variant (&value, g_variant_new_uint32 (42));
|
||||
error = lcopy (&value, &c);
|
||||
g_assert (error == NULL);
|
||||
g_assert (c != NULL);
|
||||
g_assert (g_variant_is_of_type (c, G_VARIANT_TYPE ("u")));
|
||||
g_assert_cmpuint (g_variant_get_uint32 (c), ==, 42);
|
||||
g_variant_unref (c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
g_type_init ();
|
||||
|
||||
test_enum_transformation ();
|
||||
test_gtype_value ();
|
||||
test_collection ();
|
||||
test_copying ();
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_type_init ();
|
||||
|
||||
return 0;
|
||||
g_test_add_func ("/gvalue/enum-transformation", test_enum_transformation);
|
||||
g_test_add_func ("/gvalue/gtype", test_gtype_value);
|
||||
g_test_add_func ("/gvalue/collection", test_collection);
|
||||
g_test_add_func ("/gvalue/copying", test_copying);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Reference in New Issue
Block a user