summaryrefslogtreecommitdiff
path: root/tests/gvariant-iter.c
blob: cebe522f64f9bd440ec1e6640b7aff918246cced (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* Template: gvariant */

/*
 * No error
 */
{
	GVariant *dictionary;
	GVariantIter iter;
	GVariant *value;
	gchar *key;

	g_variant_iter_init (&iter, dictionary);
	while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
		/* Something */
	}
}

/*
 *  Expected a GVariant variadic argument of type ‘GVariant **’ but saw one of type ‘gchar **’.
 *         while (g_variant_iter_loop (&iter, "{sv}", &key, &not_a_value)) {
 *                                                          ^
 */
{
	GVariant *dictionary;
	GVariantIter iter;
	gchar *not_a_value;
	gchar *key;

	g_variant_iter_init (&iter, dictionary);
	while (g_variant_iter_loop (&iter, "{sv}", &key, &not_a_value)) {
		/* Something */
	}
}

/*
 * No error
 */
{
	GVariant *dictionary;
	GVariantIter iter;
	GVariant *value;
	gchar *key;

	g_variant_iter_init (&iter, dictionary);
	while (g_variant_iter_next (&iter, "{sv}", &key, &value)) {
		/* Something */

		g_variant_unref (value);
		g_free (key);
	}
}

/*
 * Expected a GVariant variadic argument of type ‘GVariant **’ but saw one of type ‘gchar **’.
 *         while (g_variant_iter_next (&iter, "{sv}", &key, &not_a_value)) {
 *                                                          ^
 */
{
	GVariant *dictionary;
	GVariantIter iter;
	gchar *not_a_value;
	gchar *key;

	g_variant_iter_init (&iter, dictionary);
	while (g_variant_iter_next (&iter, "{sv}", &key, &not_a_value)) {
		/* Something */

		g_free (not_a_value);
		g_free (key);
	}
}