mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
Add boxed GType for GRand
Signed-off-by: Tanmay Patil <tanmaynpatil105@gmail.com>
This commit is contained in:
parent
eddd04add1
commit
dbbd9c60ba
@ -140,6 +140,7 @@ G_DEFINE_BOXED_TYPE (GMappedFile, g_mapped_file, g_mapped_file_ref, g_mapped_fil
|
||||
G_DEFINE_BOXED_TYPE (GBookmarkFile, g_bookmark_file, g_bookmark_file_copy, g_bookmark_file_free)
|
||||
G_DEFINE_BOXED_TYPE (GHmac, g_hmac, g_hmac_ref, g_hmac_unref)
|
||||
G_DEFINE_BOXED_TYPE (GDir, g_dir, g_dir_ref, g_dir_unref)
|
||||
G_DEFINE_BOXED_TYPE (GRand, g_rand, g_rand_copy, g_rand_free)
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GMainLoop, g_main_loop, g_main_loop_ref, g_main_loop_unref)
|
||||
G_DEFINE_BOXED_TYPE (GMainContext, g_main_context, g_main_context_ref, g_main_context_unref)
|
||||
|
@ -354,6 +354,15 @@ typedef gsize GType;
|
||||
*/
|
||||
#define G_TYPE_DIR (g_dir_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_RAND:
|
||||
*
|
||||
* The #GType for a boxed type holding a #GRand.
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
#define G_TYPE_RAND (g_rand_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_STRV_BUILDER:
|
||||
*
|
||||
@ -432,6 +441,8 @@ GType g_hmac_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_80
|
||||
GType g_dir_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_80
|
||||
GType g_rand_get_type (void) G_GNUC_CONST;
|
||||
GOBJECT_AVAILABLE_IN_2_80
|
||||
GType g_strv_builder_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GOBJECT_DEPRECATED_FOR('G_TYPE_VARIANT')
|
||||
|
@ -668,6 +668,28 @@ test_boxed_pattern_spec (void)
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
static void
|
||||
test_boxed_rand (void)
|
||||
{
|
||||
GRand *r, *r2;
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value, G_TYPE_RAND);
|
||||
g_assert_true (G_VALUE_HOLDS_BOXED (&value));
|
||||
|
||||
r = g_rand_new ();
|
||||
g_value_take_boxed (&value, r);
|
||||
|
||||
r2 = g_value_get_boxed (&value);
|
||||
g_assert_true (r == r2);
|
||||
|
||||
r2 = g_value_dup_boxed (&value);
|
||||
g_assert_true (r != r2);
|
||||
g_rand_free (r2);
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -699,6 +721,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/boxed/checksum", test_boxed_checksum);
|
||||
g_test_add_func ("/boxed/tree", test_boxed_tree);
|
||||
g_test_add_func ("/boxed/patternspec", test_boxed_pattern_spec);
|
||||
g_test_add_func ("/boxed/rand", test_boxed_rand);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user