summaryrefslogtreecommitdiff
path: root/tests/gvariant-builder.c
blob: c882829c7b12a1d19d988a28958c36d15855e684 (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
/* Template: gvariant */

/*
 * No error
 */
{
	GVariantBuilder *builder;
	int i;

	builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
	for (i = 0; i < 16; i++) {
		gchar buf[3];

		sprintf (buf, "%d", i);
		g_variant_builder_add (builder, "{is}", i, buf);
	}

	g_variant_builder_end (builder);
}

/*
 * Expected a GVariant variadic argument of type 'char *' but saw one of type 'int'.
 *         g_variant_builder_add (builder, "{ss}", "hi", 15);
 *                                                       ^
 */
{
	GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
	g_variant_builder_add (builder, "{ss}", "hi", 15);
	g_variant_builder_end (builder);
}

/*
 * Expected a GVariant variadic argument of type 'char *' but saw NULL instead.
 *         g_variant_builder_add (builder, "s", FALSE);
 *                                              ^
 */
{
	GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add (builder, "s", "hi");
	g_variant_builder_add (builder, "s", "hi");
	g_variant_builder_add (builder, "s", FALSE);
	g_variant_builder_end (builder);
}