1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/*
* Copyright (C) 2019 Red Hat Inc.
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include <handy.h>
static void
test_hdy_value_object_init (void)
{
HdyValueObject *obj;
GValue value = G_VALUE_INIT;
gchar *str;
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, "asdfasdf");
obj = hdy_value_object_new (&value);
g_assert_cmpstr (hdy_value_object_get_string (obj), ==, "asdfasdf");
g_clear_object (&obj);
obj = hdy_value_object_new_string ("asdfasdf");
g_assert_cmpstr (hdy_value_object_get_string (obj), ==, "asdfasdf");
g_clear_object (&obj);
obj = hdy_value_object_new_take_string (g_strdup ("asdfasdf"));
g_assert_cmpstr (hdy_value_object_get_string (obj), ==, "asdfasdf");
g_clear_object (&obj);
obj = hdy_value_object_new_collect (G_TYPE_STRING, "asdfasdf");
g_assert_cmpstr (hdy_value_object_get_string (obj), ==, "asdfasdf");
/* And check that _dup_string works too */
str = hdy_value_object_dup_string (obj);
g_assert_cmpstr (str, ==, "asdfasdf");
g_clear_pointer (&str, g_free);
g_clear_object (&obj);
g_value_unset (&value);
}
gint
main (gint argc,
gchar *argv[])
{
gtk_test_init (&argc, &argv, NULL);
hdy_init ();
g_test_add_func("/Handy/ValueObject/init", test_hdy_value_object_init);
return g_test_run();
}
|