2 * QObject Output Visitor unit-tests.
4 * Copyright (C) 2011-2016 Red Hat Inc.
7 * Luiz Capitulino <lcapitulino@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
15 #include "qemu-common.h"
16 #include "qapi/error.h"
17 #include "qapi/qobject-output-visitor.h"
18 #include "test-qapi-visit.h"
19 #include "qapi/qmp/qbool.h"
20 #include "qapi/qmp/qdict.h"
21 #include "qapi/qmp/qlist.h"
22 #include "qapi/qmp/qnull.h"
23 #include "qapi/qmp/qnum.h"
24 #include "qapi/qmp/qstring.h"
26 typedef struct TestOutputVisitorData
{
29 } TestOutputVisitorData
;
31 static void visitor_output_setup(TestOutputVisitorData
*data
,
34 data
->ov
= qobject_output_visitor_new(&data
->obj
);
38 static void visitor_output_teardown(TestOutputVisitorData
*data
,
43 qobject_unref(data
->obj
);
47 static QObject
*visitor_get(TestOutputVisitorData
*data
)
49 visit_complete(data
->ov
, &data
->obj
);
54 static void visitor_reset(TestOutputVisitorData
*data
)
56 visitor_output_teardown(data
, NULL
);
57 visitor_output_setup(data
, NULL
);
60 static void test_visitor_out_int(TestOutputVisitorData
*data
,
67 visit_type_int(data
->ov
, NULL
, &value
, &error_abort
);
69 qnum
= qobject_to(QNum
, visitor_get(data
));
71 g_assert(qnum_get_try_int(qnum
, &val
));
72 g_assert_cmpint(val
, ==, value
);
75 static void test_visitor_out_bool(TestOutputVisitorData
*data
,
81 visit_type_bool(data
->ov
, NULL
, &value
, &error_abort
);
83 qbool
= qobject_to(QBool
, visitor_get(data
));
85 g_assert(qbool_get_bool(qbool
) == value
);
88 static void test_visitor_out_number(TestOutputVisitorData
*data
,
94 visit_type_number(data
->ov
, NULL
, &value
, &error_abort
);
96 qnum
= qobject_to(QNum
, visitor_get(data
));
98 g_assert(qnum_get_double(qnum
) == value
);
101 static void test_visitor_out_string(TestOutputVisitorData
*data
,
104 char *string
= (char *) "Q E M U";
107 visit_type_str(data
->ov
, NULL
, &string
, &error_abort
);
109 qstr
= qobject_to(QString
, visitor_get(data
));
111 g_assert_cmpstr(qstring_get_str(qstr
), ==, string
);
114 static void test_visitor_out_no_string(TestOutputVisitorData
*data
,
120 /* A null string should return "" */
121 visit_type_str(data
->ov
, NULL
, &string
, &error_abort
);
123 qstr
= qobject_to(QString
, visitor_get(data
));
125 g_assert_cmpstr(qstring_get_str(qstr
), ==, "");
128 static void test_visitor_out_enum(TestOutputVisitorData
*data
,
134 for (i
= 0; i
< ENUM_ONE__MAX
; i
++) {
135 visit_type_EnumOne(data
->ov
, "unused", &i
, &error_abort
);
137 qstr
= qobject_to(QString
, visitor_get(data
));
139 g_assert_cmpstr(qstring_get_str(qstr
), ==, EnumOne_str(i
));
144 static void test_visitor_out_struct(TestOutputVisitorData
*data
,
147 TestStruct test_struct
= { .integer
= 42,
149 .string
= (char *) "foo"};
150 TestStruct
*p
= &test_struct
;
153 visit_type_TestStruct(data
->ov
, NULL
, &p
, &error_abort
);
155 qdict
= qobject_to(QDict
, visitor_get(data
));
157 g_assert_cmpint(qdict_size(qdict
), ==, 3);
158 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, 42);
159 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, false);
160 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, "foo");
163 static void test_visitor_out_struct_nested(TestOutputVisitorData
*data
,
168 QDict
*qdict
, *dict1
, *dict2
, *dict3
, *userdef
;
169 const char *string
= "user def string";
170 const char *strings
[] = { "forty two", "forty three", "forty four",
173 ud2
= g_malloc0(sizeof(*ud2
));
174 ud2
->string0
= g_strdup(strings
[0]);
176 ud2
->dict1
= g_malloc0(sizeof(*ud2
->dict1
));
177 ud2
->dict1
->string1
= g_strdup(strings
[1]);
179 ud2
->dict1
->dict2
= g_malloc0(sizeof(*ud2
->dict1
->dict2
));
180 ud2
->dict1
->dict2
->userdef
= g_new0(UserDefOne
, 1);
181 ud2
->dict1
->dict2
->userdef
->string
= g_strdup(string
);
182 ud2
->dict1
->dict2
->userdef
->integer
= value
;
183 ud2
->dict1
->dict2
->string
= g_strdup(strings
[2]);
185 ud2
->dict1
->dict3
= g_malloc0(sizeof(*ud2
->dict1
->dict3
));
186 ud2
->dict1
->has_dict3
= true;
187 ud2
->dict1
->dict3
->userdef
= g_new0(UserDefOne
, 1);
188 ud2
->dict1
->dict3
->userdef
->string
= g_strdup(string
);
189 ud2
->dict1
->dict3
->userdef
->integer
= value
;
190 ud2
->dict1
->dict3
->string
= g_strdup(strings
[3]);
192 visit_type_UserDefTwo(data
->ov
, "unused", &ud2
, &error_abort
);
194 qdict
= qobject_to(QDict
, visitor_get(data
));
196 g_assert_cmpint(qdict_size(qdict
), ==, 2);
197 g_assert_cmpstr(qdict_get_str(qdict
, "string0"), ==, strings
[0]);
199 dict1
= qdict_get_qdict(qdict
, "dict1");
200 g_assert_cmpint(qdict_size(dict1
), ==, 3);
201 g_assert_cmpstr(qdict_get_str(dict1
, "string1"), ==, strings
[1]);
203 dict2
= qdict_get_qdict(dict1
, "dict2");
204 g_assert_cmpint(qdict_size(dict2
), ==, 2);
205 g_assert_cmpstr(qdict_get_str(dict2
, "string"), ==, strings
[2]);
206 userdef
= qdict_get_qdict(dict2
, "userdef");
207 g_assert_cmpint(qdict_size(userdef
), ==, 2);
208 g_assert_cmpint(qdict_get_int(userdef
, "integer"), ==, value
);
209 g_assert_cmpstr(qdict_get_str(userdef
, "string"), ==, string
);
211 dict3
= qdict_get_qdict(dict1
, "dict3");
212 g_assert_cmpint(qdict_size(dict3
), ==, 2);
213 g_assert_cmpstr(qdict_get_str(dict3
, "string"), ==, strings
[3]);
214 userdef
= qdict_get_qdict(dict3
, "userdef");
215 g_assert_cmpint(qdict_size(userdef
), ==, 2);
216 g_assert_cmpint(qdict_get_int(userdef
, "integer"), ==, value
);
217 g_assert_cmpstr(qdict_get_str(userdef
, "string"), ==, string
);
219 qapi_free_UserDefTwo(ud2
);
222 static void test_visitor_out_list(TestOutputVisitorData
*data
,
225 const char *value_str
= "list value";
227 TestStructList
*head
= NULL
;
228 const int max_items
= 10;
229 bool value_bool
= true;
235 /* Build the list in reverse order... */
236 for (i
= 0; i
< max_items
; i
++) {
237 value
= g_malloc0(sizeof(*value
));
238 value
->integer
= value_int
+ (max_items
- i
- 1);
239 value
->boolean
= value_bool
;
240 value
->string
= g_strdup(value_str
);
242 QAPI_LIST_PREPEND(head
, value
);
245 visit_type_TestStructList(data
->ov
, NULL
, &head
, &error_abort
);
247 qlist
= qobject_to(QList
, visitor_get(data
));
249 g_assert(!qlist_empty(qlist
));
251 /* ...and ensure that the visitor sees it in order */
253 QLIST_FOREACH_ENTRY(qlist
, entry
) {
256 qdict
= qobject_to(QDict
, entry
->value
);
258 g_assert_cmpint(qdict_size(qdict
), ==, 3);
259 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, value_int
+ i
);
260 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, value_bool
);
261 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, value_str
);
264 g_assert_cmpint(i
, ==, max_items
);
266 qapi_free_TestStructList(head
);
269 static void test_visitor_out_list_qapi_free(TestOutputVisitorData
*data
,
273 UserDefTwoList
*head
= NULL
;
274 const char string
[] = "foo bar";
275 int i
, max_count
= 1024;
277 for (i
= 0; i
< max_count
; i
++) {
278 value
= g_malloc0(sizeof(*value
));
280 value
->string0
= g_strdup(string
);
281 value
->dict1
= g_new0(UserDefTwoDict
, 1);
282 value
->dict1
->string1
= g_strdup(string
);
283 value
->dict1
->dict2
= g_new0(UserDefTwoDictDict
, 1);
284 value
->dict1
->dict2
->userdef
= g_new0(UserDefOne
, 1);
285 value
->dict1
->dict2
->userdef
->string
= g_strdup(string
);
286 value
->dict1
->dict2
->userdef
->integer
= 42;
287 value
->dict1
->dict2
->string
= g_strdup(string
);
288 value
->dict1
->has_dict3
= false;
290 QAPI_LIST_PREPEND(head
, value
);
293 qapi_free_UserDefTwoList(head
);
296 static void test_visitor_out_any(TestOutputVisitorData
*data
,
306 qobj
= QOBJECT(qnum_from_int(-42));
307 visit_type_any(data
->ov
, NULL
, &qobj
, &error_abort
);
308 qnum
= qobject_to(QNum
, visitor_get(data
));
310 g_assert(qnum_get_try_int(qnum
, &val
));
311 g_assert_cmpint(val
, ==, -42);
316 qdict_put_int(qdict
, "integer", -42);
317 qdict_put_bool(qdict
, "boolean", true);
318 qdict_put_str(qdict
, "string", "foo");
319 qobj
= QOBJECT(qdict
);
320 visit_type_any(data
->ov
, NULL
, &qobj
, &error_abort
);
322 qdict
= qobject_to(QDict
, visitor_get(data
));
324 qnum
= qobject_to(QNum
, qdict_get(qdict
, "integer"));
326 g_assert(qnum_get_try_int(qnum
, &val
));
327 g_assert_cmpint(val
, ==, -42);
328 qbool
= qobject_to(QBool
, qdict_get(qdict
, "boolean"));
330 g_assert(qbool_get_bool(qbool
) == true);
331 qstring
= qobject_to(QString
, qdict_get(qdict
, "string"));
333 g_assert_cmpstr(qstring_get_str(qstring
), ==, "foo");
336 static void test_visitor_out_union_flat(TestOutputVisitorData
*data
,
341 UserDefFlatUnion
*tmp
= g_malloc0(sizeof(UserDefFlatUnion
));
342 tmp
->enum1
= ENUM_ONE_VALUE1
;
343 tmp
->string
= g_strdup("str");
345 tmp
->u
.value1
.boolean
= true;
347 visit_type_UserDefFlatUnion(data
->ov
, NULL
, &tmp
, &error_abort
);
348 qdict
= qobject_to(QDict
, visitor_get(data
));
350 g_assert_cmpstr(qdict_get_str(qdict
, "enum1"), ==, "value1");
351 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, "str");
352 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, 41);
353 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, true);
355 qapi_free_UserDefFlatUnion(tmp
);
358 static void test_visitor_out_alternate(TestOutputVisitorData
*data
,
361 UserDefAlternate
*tmp
;
367 tmp
= g_new0(UserDefAlternate
, 1);
368 tmp
->type
= QTYPE_QNUM
;
371 visit_type_UserDefAlternate(data
->ov
, NULL
, &tmp
, &error_abort
);
372 qnum
= qobject_to(QNum
, visitor_get(data
));
374 g_assert(qnum_get_try_int(qnum
, &val
));
375 g_assert_cmpint(val
, ==, 42);
377 qapi_free_UserDefAlternate(tmp
);
380 tmp
= g_new0(UserDefAlternate
, 1);
381 tmp
->type
= QTYPE_QSTRING
;
382 tmp
->u
.e
= ENUM_ONE_VALUE1
;
384 visit_type_UserDefAlternate(data
->ov
, NULL
, &tmp
, &error_abort
);
385 qstr
= qobject_to(QString
, visitor_get(data
));
387 g_assert_cmpstr(qstring_get_str(qstr
), ==, "value1");
389 qapi_free_UserDefAlternate(tmp
);
392 tmp
= g_new0(UserDefAlternate
, 1);
393 tmp
->type
= QTYPE_QNULL
;
396 visit_type_UserDefAlternate(data
->ov
, NULL
, &tmp
, &error_abort
);
397 g_assert_cmpint(qobject_type(visitor_get(data
)), ==, QTYPE_QNULL
);
399 qapi_free_UserDefAlternate(tmp
);
402 tmp
= g_new0(UserDefAlternate
, 1);
403 tmp
->type
= QTYPE_QDICT
;
404 tmp
->u
.udfu
.integer
= 1;
405 tmp
->u
.udfu
.string
= g_strdup("str");
406 tmp
->u
.udfu
.enum1
= ENUM_ONE_VALUE1
;
407 tmp
->u
.udfu
.u
.value1
.boolean
= true;
409 visit_type_UserDefAlternate(data
->ov
, NULL
, &tmp
, &error_abort
);
410 qdict
= qobject_to(QDict
, visitor_get(data
));
412 g_assert_cmpint(qdict_size(qdict
), ==, 4);
413 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, 1);
414 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, "str");
415 g_assert_cmpstr(qdict_get_str(qdict
, "enum1"), ==, "value1");
416 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, true);
418 qapi_free_UserDefAlternate(tmp
);
421 static void test_visitor_out_null(TestOutputVisitorData
*data
,
428 visit_start_struct(data
->ov
, NULL
, NULL
, 0, &error_abort
);
429 visit_type_null(data
->ov
, "a", &null
, &error_abort
);
430 visit_check_struct(data
->ov
, &error_abort
);
431 visit_end_struct(data
->ov
, NULL
);
432 qdict
= qobject_to(QDict
, visitor_get(data
));
434 g_assert_cmpint(qdict_size(qdict
), ==, 1);
435 nil
= qdict_get(qdict
, "a");
437 g_assert(qobject_type(nil
) == QTYPE_QNULL
);
440 static void init_list_union(UserDefListUnion
*cvalue
)
443 switch (cvalue
->type
) {
444 case USER_DEF_LIST_UNION_KIND_INTEGER
: {
445 intList
**tail
= &cvalue
->u
.integer
.data
;
446 for (i
= 0; i
< 32; i
++) {
447 QAPI_LIST_APPEND(tail
, i
);
451 case USER_DEF_LIST_UNION_KIND_S8
: {
452 int8List
**tail
= &cvalue
->u
.s8
.data
;
453 for (i
= 0; i
< 32; i
++) {
454 QAPI_LIST_APPEND(tail
, i
);
458 case USER_DEF_LIST_UNION_KIND_S16
: {
459 int16List
**tail
= &cvalue
->u
.s16
.data
;
460 for (i
= 0; i
< 32; i
++) {
461 QAPI_LIST_APPEND(tail
, i
);
465 case USER_DEF_LIST_UNION_KIND_S32
: {
466 int32List
**tail
= &cvalue
->u
.s32
.data
;
467 for (i
= 0; i
< 32; i
++) {
468 QAPI_LIST_APPEND(tail
, i
);
472 case USER_DEF_LIST_UNION_KIND_S64
: {
473 int64List
**tail
= &cvalue
->u
.s64
.data
;
474 for (i
= 0; i
< 32; i
++) {
475 QAPI_LIST_APPEND(tail
, i
);
479 case USER_DEF_LIST_UNION_KIND_U8
: {
480 uint8List
**tail
= &cvalue
->u
.u8
.data
;
481 for (i
= 0; i
< 32; i
++) {
482 QAPI_LIST_APPEND(tail
, i
);
486 case USER_DEF_LIST_UNION_KIND_U16
: {
487 uint16List
**tail
= &cvalue
->u
.u16
.data
;
488 for (i
= 0; i
< 32; i
++) {
489 QAPI_LIST_APPEND(tail
, i
);
493 case USER_DEF_LIST_UNION_KIND_U32
: {
494 uint32List
**tail
= &cvalue
->u
.u32
.data
;
495 for (i
= 0; i
< 32; i
++) {
496 QAPI_LIST_APPEND(tail
, i
);
500 case USER_DEF_LIST_UNION_KIND_U64
: {
501 uint64List
**tail
= &cvalue
->u
.u64
.data
;
502 for (i
= 0; i
< 32; i
++) {
503 QAPI_LIST_APPEND(tail
, i
);
507 case USER_DEF_LIST_UNION_KIND_BOOLEAN
: {
508 boolList
**tail
= &cvalue
->u
.boolean
.data
;
509 for (i
= 0; i
< 32; i
++) {
510 QAPI_LIST_APPEND(tail
, QEMU_IS_ALIGNED(i
, 3));
514 case USER_DEF_LIST_UNION_KIND_STRING
: {
515 strList
**tail
= &cvalue
->u
.string
.data
;
516 for (i
= 0; i
< 32; i
++) {
517 QAPI_LIST_APPEND(tail
, g_strdup_printf("%d", i
));
521 case USER_DEF_LIST_UNION_KIND_NUMBER
: {
522 numberList
**tail
= &cvalue
->u
.number
.data
;
523 for (i
= 0; i
< 32; i
++) {
524 QAPI_LIST_APPEND(tail
, (double)i
/ 3);
529 g_assert_not_reached();
533 static void check_list_union(QObject
*qobj
,
534 UserDefListUnionKind kind
)
540 qdict
= qobject_to(QDict
, qobj
);
542 g_assert(qdict_haskey(qdict
, "data"));
543 qlist
= qlist_copy(qobject_to(QList
, qdict_get(qdict
, "data")));
546 case USER_DEF_LIST_UNION_KIND_U8
:
547 case USER_DEF_LIST_UNION_KIND_U16
:
548 case USER_DEF_LIST_UNION_KIND_U32
:
549 case USER_DEF_LIST_UNION_KIND_U64
:
550 for (i
= 0; i
< 32; i
++) {
555 tmp
= qlist_peek(qlist
);
557 qvalue
= qobject_to(QNum
, tmp
);
558 g_assert(qnum_get_try_uint(qvalue
, &val
));
559 g_assert_cmpint(val
, ==, i
);
560 qobject_unref(qlist_pop(qlist
));
564 case USER_DEF_LIST_UNION_KIND_S8
:
565 case USER_DEF_LIST_UNION_KIND_S16
:
566 case USER_DEF_LIST_UNION_KIND_S32
:
567 case USER_DEF_LIST_UNION_KIND_S64
:
569 * All integer elements in JSON arrays get stored into QNums
570 * when we convert to QObjects, so we can check them all in
571 * the same fashion, so simply fall through here.
573 case USER_DEF_LIST_UNION_KIND_INTEGER
:
574 for (i
= 0; i
< 32; i
++) {
579 tmp
= qlist_peek(qlist
);
581 qvalue
= qobject_to(QNum
, tmp
);
582 g_assert(qnum_get_try_int(qvalue
, &val
));
583 g_assert_cmpint(val
, ==, i
);
584 qobject_unref(qlist_pop(qlist
));
587 case USER_DEF_LIST_UNION_KIND_BOOLEAN
:
588 for (i
= 0; i
< 32; i
++) {
591 tmp
= qlist_peek(qlist
);
593 qvalue
= qobject_to(QBool
, tmp
);
594 g_assert_cmpint(qbool_get_bool(qvalue
), ==, i
% 3 == 0);
595 qobject_unref(qlist_pop(qlist
));
598 case USER_DEF_LIST_UNION_KIND_STRING
:
599 for (i
= 0; i
< 32; i
++) {
603 tmp
= qlist_peek(qlist
);
605 qvalue
= qobject_to(QString
, tmp
);
606 sprintf(str
, "%d", i
);
607 g_assert_cmpstr(qstring_get_str(qvalue
), ==, str
);
608 qobject_unref(qlist_pop(qlist
));
611 case USER_DEF_LIST_UNION_KIND_NUMBER
:
612 for (i
= 0; i
< 32; i
++) {
615 GString
*double_expected
= g_string_new("");
616 GString
*double_actual
= g_string_new("");
618 tmp
= qlist_peek(qlist
);
620 qvalue
= qobject_to(QNum
, tmp
);
621 g_string_printf(double_expected
, "%.6f", (double)i
/ 3);
622 g_string_printf(double_actual
, "%.6f", qnum_get_double(qvalue
));
623 g_assert_cmpstr(double_actual
->str
, ==, double_expected
->str
);
625 qobject_unref(qlist_pop(qlist
));
626 g_string_free(double_expected
, true);
627 g_string_free(double_actual
, true);
631 g_assert_not_reached();
633 qobject_unref(qlist
);
636 static void test_list_union(TestOutputVisitorData
*data
,
638 UserDefListUnionKind kind
)
640 UserDefListUnion
*cvalue
= g_new0(UserDefListUnion
, 1);
644 init_list_union(cvalue
);
646 visit_type_UserDefListUnion(data
->ov
, NULL
, &cvalue
, &error_abort
);
648 obj
= visitor_get(data
);
649 check_list_union(obj
, cvalue
->type
);
650 qapi_free_UserDefListUnion(cvalue
);
653 static void test_visitor_out_list_union_int(TestOutputVisitorData
*data
,
656 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_INTEGER
);
659 static void test_visitor_out_list_union_int8(TestOutputVisitorData
*data
,
662 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_S8
);
665 static void test_visitor_out_list_union_int16(TestOutputVisitorData
*data
,
668 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_S16
);
671 static void test_visitor_out_list_union_int32(TestOutputVisitorData
*data
,
674 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_S32
);
677 static void test_visitor_out_list_union_int64(TestOutputVisitorData
*data
,
680 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_S64
);
683 static void test_visitor_out_list_union_uint8(TestOutputVisitorData
*data
,
686 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_U8
);
689 static void test_visitor_out_list_union_uint16(TestOutputVisitorData
*data
,
692 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_U16
);
695 static void test_visitor_out_list_union_uint32(TestOutputVisitorData
*data
,
698 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_U32
);
701 static void test_visitor_out_list_union_uint64(TestOutputVisitorData
*data
,
704 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_U64
);
707 static void test_visitor_out_list_union_bool(TestOutputVisitorData
*data
,
710 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_BOOLEAN
);
713 static void test_visitor_out_list_union_str(TestOutputVisitorData
*data
,
716 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_STRING
);
719 static void test_visitor_out_list_union_number(TestOutputVisitorData
*data
,
722 test_list_union(data
, unused
, USER_DEF_LIST_UNION_KIND_NUMBER
);
725 static void output_visitor_test_add(const char *testpath
,
726 TestOutputVisitorData
*data
,
727 void (*test_func
)(TestOutputVisitorData
*data
, const void *user_data
))
729 g_test_add(testpath
, TestOutputVisitorData
, data
, visitor_output_setup
,
730 test_func
, visitor_output_teardown
);
733 int main(int argc
, char **argv
)
735 TestOutputVisitorData out_visitor_data
;
737 g_test_init(&argc
, &argv
, NULL
);
739 output_visitor_test_add("/visitor/output/int",
740 &out_visitor_data
, test_visitor_out_int
);
741 output_visitor_test_add("/visitor/output/bool",
742 &out_visitor_data
, test_visitor_out_bool
);
743 output_visitor_test_add("/visitor/output/number",
744 &out_visitor_data
, test_visitor_out_number
);
745 output_visitor_test_add("/visitor/output/string",
746 &out_visitor_data
, test_visitor_out_string
);
747 output_visitor_test_add("/visitor/output/no-string",
748 &out_visitor_data
, test_visitor_out_no_string
);
749 output_visitor_test_add("/visitor/output/enum",
750 &out_visitor_data
, test_visitor_out_enum
);
751 output_visitor_test_add("/visitor/output/struct",
752 &out_visitor_data
, test_visitor_out_struct
);
753 output_visitor_test_add("/visitor/output/struct-nested",
754 &out_visitor_data
, test_visitor_out_struct_nested
);
755 output_visitor_test_add("/visitor/output/list",
756 &out_visitor_data
, test_visitor_out_list
);
757 output_visitor_test_add("/visitor/output/any",
758 &out_visitor_data
, test_visitor_out_any
);
759 output_visitor_test_add("/visitor/output/list-qapi-free",
760 &out_visitor_data
, test_visitor_out_list_qapi_free
);
761 output_visitor_test_add("/visitor/output/union-flat",
762 &out_visitor_data
, test_visitor_out_union_flat
);
763 output_visitor_test_add("/visitor/output/alternate",
764 &out_visitor_data
, test_visitor_out_alternate
);
765 output_visitor_test_add("/visitor/output/null",
766 &out_visitor_data
, test_visitor_out_null
);
767 output_visitor_test_add("/visitor/output/list_union/int",
769 test_visitor_out_list_union_int
);
770 output_visitor_test_add("/visitor/output/list_union/int8",
772 test_visitor_out_list_union_int8
);
773 output_visitor_test_add("/visitor/output/list_union/int16",
775 test_visitor_out_list_union_int16
);
776 output_visitor_test_add("/visitor/output/list_union/int32",
778 test_visitor_out_list_union_int32
);
779 output_visitor_test_add("/visitor/output/list_union/int64",
781 test_visitor_out_list_union_int64
);
782 output_visitor_test_add("/visitor/output/list_union/uint8",
784 test_visitor_out_list_union_uint8
);
785 output_visitor_test_add("/visitor/output/list_union/uint16",
787 test_visitor_out_list_union_uint16
);
788 output_visitor_test_add("/visitor/output/list_union/uint32",
790 test_visitor_out_list_union_uint32
);
791 output_visitor_test_add("/visitor/output/list_union/uint64",
793 test_visitor_out_list_union_uint64
);
794 output_visitor_test_add("/visitor/output/list_union/bool",
796 test_visitor_out_list_union_bool
);
797 output_visitor_test_add("/visitor/output/list_union/string",
799 test_visitor_out_list_union_str
);
800 output_visitor_test_add("/visitor/output/list_union/number",
802 test_visitor_out_list_union_number
);