2 * QMP Output Visitor unit-tests.
4 * Copyright (C) 2011 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.
15 #include "qemu-common.h"
16 #include "qapi/qmp-output-visitor.h"
17 #include "test-qapi-types.h"
18 #include "test-qapi-visit.h"
19 #include "qapi/qmp/types.h"
21 typedef struct TestOutputVisitorData
{
22 QmpOutputVisitor
*qov
;
24 } TestOutputVisitorData
;
26 static void visitor_output_setup(TestOutputVisitorData
*data
,
29 data
->qov
= qmp_output_visitor_new();
30 g_assert(data
->qov
!= NULL
);
32 data
->ov
= qmp_output_get_visitor(data
->qov
);
33 g_assert(data
->ov
!= NULL
);
36 static void visitor_output_teardown(TestOutputVisitorData
*data
,
39 qmp_output_visitor_cleanup(data
->qov
);
44 static void test_visitor_out_int(TestOutputVisitorData
*data
,
51 visit_type_int(data
->ov
, &value
, NULL
, &errp
);
52 g_assert(error_is_set(&errp
) == 0);
54 obj
= qmp_output_get_qobject(data
->qov
);
55 g_assert(obj
!= NULL
);
56 g_assert(qobject_type(obj
) == QTYPE_QINT
);
57 g_assert_cmpint(qint_get_int(qobject_to_qint(obj
)), ==, value
);
62 static void test_visitor_out_bool(TestOutputVisitorData
*data
,
69 visit_type_bool(data
->ov
, &value
, NULL
, &errp
);
70 g_assert(error_is_set(&errp
) == 0);
72 obj
= qmp_output_get_qobject(data
->qov
);
73 g_assert(obj
!= NULL
);
74 g_assert(qobject_type(obj
) == QTYPE_QBOOL
);
75 g_assert(qbool_get_int(qobject_to_qbool(obj
)) == value
);
80 static void test_visitor_out_number(TestOutputVisitorData
*data
,
87 visit_type_number(data
->ov
, &value
, NULL
, &errp
);
88 g_assert(error_is_set(&errp
) == 0);
90 obj
= qmp_output_get_qobject(data
->qov
);
91 g_assert(obj
!= NULL
);
92 g_assert(qobject_type(obj
) == QTYPE_QFLOAT
);
93 g_assert(qfloat_get_double(qobject_to_qfloat(obj
)) == value
);
98 static void test_visitor_out_string(TestOutputVisitorData
*data
,
101 char *string
= (char *) "Q E M U";
105 visit_type_str(data
->ov
, &string
, NULL
, &errp
);
106 g_assert(error_is_set(&errp
) == 0);
108 obj
= qmp_output_get_qobject(data
->qov
);
109 g_assert(obj
!= NULL
);
110 g_assert(qobject_type(obj
) == QTYPE_QSTRING
);
111 g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj
)), ==, string
);
116 static void test_visitor_out_no_string(TestOutputVisitorData
*data
,
123 /* A null string should return "" */
124 visit_type_str(data
->ov
, &string
, NULL
, &errp
);
125 g_assert(error_is_set(&errp
) == 0);
127 obj
= qmp_output_get_qobject(data
->qov
);
128 g_assert(obj
!= NULL
);
129 g_assert(qobject_type(obj
) == QTYPE_QSTRING
);
130 g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj
)), ==, "");
135 static void test_visitor_out_enum(TestOutputVisitorData
*data
,
142 for (i
= 0; i
< ENUM_ONE_MAX
; i
++) {
143 visit_type_EnumOne(data
->ov
, &i
, "unused", &errp
);
144 g_assert(!error_is_set(&errp
));
146 obj
= qmp_output_get_qobject(data
->qov
);
147 g_assert(obj
!= NULL
);
148 g_assert(qobject_type(obj
) == QTYPE_QSTRING
);
149 g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj
)), ==,
155 static void test_visitor_out_enum_errors(TestOutputVisitorData
*data
,
158 EnumOne i
, bad_values
[] = { ENUM_ONE_MAX
, -1 };
161 for (i
= 0; i
< ARRAY_SIZE(bad_values
) ; i
++) {
163 visit_type_EnumOne(data
->ov
, &bad_values
[i
], "unused", &errp
);
164 g_assert(error_is_set(&errp
) == true);
169 typedef struct TestStruct
176 static void visit_type_TestStruct(Visitor
*v
, TestStruct
**obj
,
177 const char *name
, Error
**errp
)
179 visit_start_struct(v
, (void **)obj
, "TestStruct", name
, sizeof(TestStruct
),
182 visit_type_int(v
, &(*obj
)->integer
, "integer", errp
);
183 visit_type_bool(v
, &(*obj
)->boolean
, "boolean", errp
);
184 visit_type_str(v
, &(*obj
)->string
, "string", errp
);
186 visit_end_struct(v
, errp
);
189 static void test_visitor_out_struct(TestOutputVisitorData
*data
,
192 TestStruct test_struct
= { .integer
= 42,
194 .string
= (char *) "foo"};
195 TestStruct
*p
= &test_struct
;
200 visit_type_TestStruct(data
->ov
, &p
, NULL
, &errp
);
201 g_assert(!error_is_set(&errp
));
203 obj
= qmp_output_get_qobject(data
->qov
);
204 g_assert(obj
!= NULL
);
205 g_assert(qobject_type(obj
) == QTYPE_QDICT
);
207 qdict
= qobject_to_qdict(obj
);
208 g_assert_cmpint(qdict_size(qdict
), ==, 3);
209 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, 42);
210 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, 0);
211 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, "foo");
216 static void test_visitor_out_struct_nested(TestOutputVisitorData
*data
,
223 QDict
*qdict
, *dict1
, *dict2
, *dict3
, *userdef
;
224 const char *string
= "user def string";
225 const char *strings
[] = { "forty two", "forty three", "forty four",
228 ud2
= g_malloc0(sizeof(*ud2
));
229 ud2
->string0
= g_strdup(strings
[0]);
231 ud2
->dict1
.string1
= g_strdup(strings
[1]);
232 ud2
->dict1
.dict2
.userdef1
= g_malloc0(sizeof(UserDefOne
));
233 ud2
->dict1
.dict2
.userdef1
->string
= g_strdup(string
);
234 ud2
->dict1
.dict2
.userdef1
->integer
= value
;
235 ud2
->dict1
.dict2
.string2
= g_strdup(strings
[2]);
237 ud2
->dict1
.has_dict3
= true;
238 ud2
->dict1
.dict3
.userdef2
= g_malloc0(sizeof(UserDefOne
));
239 ud2
->dict1
.dict3
.userdef2
->string
= g_strdup(string
);
240 ud2
->dict1
.dict3
.userdef2
->integer
= value
;
241 ud2
->dict1
.dict3
.string3
= g_strdup(strings
[3]);
243 visit_type_UserDefNested(data
->ov
, &ud2
, "unused", &errp
);
244 g_assert(!error_is_set(&errp
));
246 obj
= qmp_output_get_qobject(data
->qov
);
247 g_assert(obj
!= NULL
);
248 g_assert(qobject_type(obj
) == QTYPE_QDICT
);
250 qdict
= qobject_to_qdict(obj
);
251 g_assert_cmpint(qdict_size(qdict
), ==, 2);
252 g_assert_cmpstr(qdict_get_str(qdict
, "string0"), ==, strings
[0]);
254 dict1
= qdict_get_qdict(qdict
, "dict1");
255 g_assert_cmpint(qdict_size(dict1
), ==, 3);
256 g_assert_cmpstr(qdict_get_str(dict1
, "string1"), ==, strings
[1]);
258 dict2
= qdict_get_qdict(dict1
, "dict2");
259 g_assert_cmpint(qdict_size(dict2
), ==, 2);
260 g_assert_cmpstr(qdict_get_str(dict2
, "string2"), ==, strings
[2]);
261 userdef
= qdict_get_qdict(dict2
, "userdef1");
262 g_assert_cmpint(qdict_size(userdef
), ==, 2);
263 g_assert_cmpint(qdict_get_int(userdef
, "integer"), ==, value
);
264 g_assert_cmpstr(qdict_get_str(userdef
, "string"), ==, string
);
266 dict3
= qdict_get_qdict(dict1
, "dict3");
267 g_assert_cmpint(qdict_size(dict3
), ==, 2);
268 g_assert_cmpstr(qdict_get_str(dict3
, "string3"), ==, strings
[3]);
269 userdef
= qdict_get_qdict(dict3
, "userdef2");
270 g_assert_cmpint(qdict_size(userdef
), ==, 2);
271 g_assert_cmpint(qdict_get_int(userdef
, "integer"), ==, value
);
272 g_assert_cmpstr(qdict_get_str(userdef
, "string"), ==, string
);
275 qapi_free_UserDefNested(ud2
);
278 static void test_visitor_out_struct_errors(TestOutputVisitorData
*data
,
281 EnumOne bad_values
[] = { ENUM_ONE_MAX
, -1 };
282 UserDefOne u
= { 0 }, *pu
= &u
;
286 for (i
= 0; i
< ARRAY_SIZE(bad_values
) ; i
++) {
289 u
.enum1
= bad_values
[i
];
290 visit_type_UserDefOne(data
->ov
, &pu
, "unused", &errp
);
291 g_assert(error_is_set(&errp
) == true);
296 typedef struct TestStructList
302 struct TestStructList
*next
;
305 static void visit_type_TestStructList(Visitor
*v
, TestStructList
**obj
,
306 const char *name
, Error
**errp
)
308 GenericList
*i
, **head
= (GenericList
**)obj
;
310 visit_start_list(v
, name
, errp
);
312 for (*head
= i
= visit_next_list(v
, head
, errp
); i
; i
= visit_next_list(v
, &i
, errp
)) {
313 TestStructList
*native_i
= (TestStructList
*)i
;
314 visit_type_TestStruct(v
, &native_i
->value
, NULL
, errp
);
317 visit_end_list(v
, errp
);
320 static void test_visitor_out_list(TestOutputVisitorData
*data
,
323 char *value_str
= (char *) "list value";
324 TestStructList
*p
, *head
= NULL
;
325 const int max_items
= 10;
326 bool value_bool
= true;
334 for (i
= 0; i
< max_items
; i
++) {
335 p
= g_malloc0(sizeof(*p
));
336 p
->value
= g_malloc0(sizeof(*p
->value
));
337 p
->value
->integer
= value_int
;
338 p
->value
->boolean
= value_bool
;
339 p
->value
->string
= value_str
;
345 visit_type_TestStructList(data
->ov
, &head
, NULL
, &errp
);
346 g_assert(!error_is_set(&errp
));
348 obj
= qmp_output_get_qobject(data
->qov
);
349 g_assert(obj
!= NULL
);
350 g_assert(qobject_type(obj
) == QTYPE_QLIST
);
352 qlist
= qobject_to_qlist(obj
);
353 g_assert(!qlist_empty(qlist
));
356 QLIST_FOREACH_ENTRY(qlist
, entry
) {
359 g_assert(qobject_type(entry
->value
) == QTYPE_QDICT
);
360 qdict
= qobject_to_qdict(entry
->value
);
361 g_assert_cmpint(qdict_size(qdict
), ==, 3);
362 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, value_int
);
363 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, value_bool
);
364 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, value_str
);
367 g_assert_cmpint(i
, ==, max_items
);
372 TestStructList
*tmp
= p
->next
;
379 static void test_visitor_out_list_qapi_free(TestOutputVisitorData
*data
,
382 UserDefNestedList
*p
, *head
= NULL
;
383 const char string
[] = "foo bar";
384 int i
, max_count
= 1024;
386 for (i
= 0; i
< max_count
; i
++) {
387 p
= g_malloc0(sizeof(*p
));
388 p
->value
= g_malloc0(sizeof(*p
->value
));
390 p
->value
->string0
= g_strdup(string
);
391 p
->value
->dict1
.string1
= g_strdup(string
);
392 p
->value
->dict1
.dict2
.userdef1
= g_malloc0(sizeof(UserDefOne
));
393 p
->value
->dict1
.dict2
.userdef1
->string
= g_strdup(string
);
394 p
->value
->dict1
.dict2
.userdef1
->integer
= 42;
395 p
->value
->dict1
.dict2
.string2
= g_strdup(string
);
396 p
->value
->dict1
.has_dict3
= false;
402 qapi_free_UserDefNestedList(head
);
405 static void test_visitor_out_union(TestOutputVisitorData
*data
,
408 QObject
*arg
, *qvalue
;
409 QDict
*qdict
, *value
;
413 UserDefUnion
*tmp
= g_malloc0(sizeof(UserDefUnion
));
414 tmp
->kind
= USER_DEF_UNION_KIND_A
;
415 tmp
->a
= g_malloc0(sizeof(UserDefA
));
416 tmp
->a
->boolean
= true;
418 visit_type_UserDefUnion(data
->ov
, &tmp
, NULL
, &err
);
419 g_assert(err
== NULL
);
420 arg
= qmp_output_get_qobject(data
->qov
);
422 g_assert(qobject_type(arg
) == QTYPE_QDICT
);
423 qdict
= qobject_to_qdict(arg
);
425 g_assert_cmpstr(qdict_get_str(qdict
, "type"), ==, "a");
427 qvalue
= qdict_get(qdict
, "data");
428 g_assert(data
!= NULL
);
429 g_assert(qobject_type(qvalue
) == QTYPE_QDICT
);
430 value
= qobject_to_qdict(qvalue
);
431 g_assert_cmpint(qdict_get_bool(value
, "boolean"), ==, true);
433 qapi_free_UserDefUnion(tmp
);
437 static void init_native_list(UserDefNativeListUnion
*cvalue
)
440 switch (cvalue
->kind
) {
441 case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER
: {
442 intList
**list
= &cvalue
->integer
;
443 for (i
= 0; i
< 32; i
++) {
444 *list
= g_new0(intList
, 1);
446 (*list
)->next
= NULL
;
447 list
= &(*list
)->next
;
451 case USER_DEF_NATIVE_LIST_UNION_KIND_S8
: {
452 int8List
**list
= &cvalue
->s8
;
453 for (i
= 0; i
< 32; i
++) {
454 *list
= g_new0(int8List
, 1);
456 (*list
)->next
= NULL
;
457 list
= &(*list
)->next
;
461 case USER_DEF_NATIVE_LIST_UNION_KIND_S16
: {
462 int16List
**list
= &cvalue
->s16
;
463 for (i
= 0; i
< 32; i
++) {
464 *list
= g_new0(int16List
, 1);
466 (*list
)->next
= NULL
;
467 list
= &(*list
)->next
;
471 case USER_DEF_NATIVE_LIST_UNION_KIND_S32
: {
472 int32List
**list
= &cvalue
->s32
;
473 for (i
= 0; i
< 32; i
++) {
474 *list
= g_new0(int32List
, 1);
476 (*list
)->next
= NULL
;
477 list
= &(*list
)->next
;
481 case USER_DEF_NATIVE_LIST_UNION_KIND_S64
: {
482 int64List
**list
= &cvalue
->s64
;
483 for (i
= 0; i
< 32; i
++) {
484 *list
= g_new0(int64List
, 1);
486 (*list
)->next
= NULL
;
487 list
= &(*list
)->next
;
491 case USER_DEF_NATIVE_LIST_UNION_KIND_U8
: {
492 uint8List
**list
= &cvalue
->u8
;
493 for (i
= 0; i
< 32; i
++) {
494 *list
= g_new0(uint8List
, 1);
496 (*list
)->next
= NULL
;
497 list
= &(*list
)->next
;
501 case USER_DEF_NATIVE_LIST_UNION_KIND_U16
: {
502 uint16List
**list
= &cvalue
->u16
;
503 for (i
= 0; i
< 32; i
++) {
504 *list
= g_new0(uint16List
, 1);
506 (*list
)->next
= NULL
;
507 list
= &(*list
)->next
;
511 case USER_DEF_NATIVE_LIST_UNION_KIND_U32
: {
512 uint32List
**list
= &cvalue
->u32
;
513 for (i
= 0; i
< 32; i
++) {
514 *list
= g_new0(uint32List
, 1);
516 (*list
)->next
= NULL
;
517 list
= &(*list
)->next
;
521 case USER_DEF_NATIVE_LIST_UNION_KIND_U64
: {
522 uint64List
**list
= &cvalue
->u64
;
523 for (i
= 0; i
< 32; i
++) {
524 *list
= g_new0(uint64List
, 1);
526 (*list
)->next
= NULL
;
527 list
= &(*list
)->next
;
531 case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN
: {
532 boolList
**list
= &cvalue
->boolean
;
533 for (i
= 0; i
< 32; i
++) {
534 *list
= g_new0(boolList
, 1);
535 (*list
)->value
= (i
% 3 == 0);
536 (*list
)->next
= NULL
;
537 list
= &(*list
)->next
;
541 case USER_DEF_NATIVE_LIST_UNION_KIND_STRING
: {
542 strList
**list
= &cvalue
->string
;
543 for (i
= 0; i
< 32; i
++) {
544 *list
= g_new0(strList
, 1);
545 (*list
)->value
= g_strdup_printf("%d", i
);
546 (*list
)->next
= NULL
;
547 list
= &(*list
)->next
;
551 case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER
: {
552 numberList
**list
= &cvalue
->number
;
553 for (i
= 0; i
< 32; i
++) {
554 *list
= g_new0(numberList
, 1);
555 (*list
)->value
= (double)i
/ 3;
556 (*list
)->next
= NULL
;
557 list
= &(*list
)->next
;
566 static void check_native_list(QObject
*qobj
,
567 UserDefNativeListUnionKind kind
)
574 g_assert(qobject_type(qobj
) == QTYPE_QDICT
);
575 qdict
= qobject_to_qdict(qobj
);
577 g_assert(qdict_haskey(qdict
, "data"));
578 qlist
= qlist_copy(qobject_to_qlist(qdict_get(qdict
, "data")));
581 case USER_DEF_NATIVE_LIST_UNION_KIND_S8
:
582 case USER_DEF_NATIVE_LIST_UNION_KIND_S16
:
583 case USER_DEF_NATIVE_LIST_UNION_KIND_S32
:
584 case USER_DEF_NATIVE_LIST_UNION_KIND_S64
:
585 case USER_DEF_NATIVE_LIST_UNION_KIND_U8
:
586 case USER_DEF_NATIVE_LIST_UNION_KIND_U16
:
587 case USER_DEF_NATIVE_LIST_UNION_KIND_U32
:
588 case USER_DEF_NATIVE_LIST_UNION_KIND_U64
:
589 /* all integer elements in JSON arrays get stored into QInts when
590 * we convert to QObjects, so we can check them all in the same
591 * fashion, so simply fall through here
593 case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER
:
594 for (i
= 0; i
< 32; i
++) {
597 tmp
= qlist_peek(qlist
);
599 qvalue
= qobject_to_qint(tmp
);
600 g_assert_cmpint(qint_get_int(qvalue
), ==, i
);
601 qobject_decref(qlist_pop(qlist
));
604 case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN
:
605 for (i
= 0; i
< 32; i
++) {
608 tmp
= qlist_peek(qlist
);
610 qvalue
= qobject_to_qbool(tmp
);
611 g_assert_cmpint(qbool_get_int(qvalue
), ==, (i
% 3 == 0) ? 1 : 0);
612 qobject_decref(qlist_pop(qlist
));
615 case USER_DEF_NATIVE_LIST_UNION_KIND_STRING
:
616 for (i
= 0; i
< 32; i
++) {
620 tmp
= qlist_peek(qlist
);
622 qvalue
= qobject_to_qstring(tmp
);
623 sprintf(str
, "%d", i
);
624 g_assert_cmpstr(qstring_get_str(qvalue
), ==, str
);
625 qobject_decref(qlist_pop(qlist
));
628 case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER
:
629 for (i
= 0; i
< 32; i
++) {
632 GString
*double_expected
= g_string_new("");
633 GString
*double_actual
= g_string_new("");
635 tmp
= qlist_peek(qlist
);
637 qvalue
= qobject_to_qfloat(tmp
);
638 g_string_printf(double_expected
, "%.6f", (double)i
/ 3);
639 g_string_printf(double_actual
, "%.6f", qfloat_get_double(qvalue
));
640 g_assert_cmpstr(double_actual
->str
, ==, double_expected
->str
);
642 qobject_decref(qlist_pop(qlist
));
643 g_string_free(double_expected
, true);
644 g_string_free(double_actual
, true);
653 static void test_native_list(TestOutputVisitorData
*data
,
655 UserDefNativeListUnionKind kind
)
657 UserDefNativeListUnion
*cvalue
= g_new0(UserDefNativeListUnion
, 1);
662 init_native_list(cvalue
);
664 visit_type_UserDefNativeListUnion(data
->ov
, &cvalue
, NULL
, &err
);
665 g_assert(err
== NULL
);
667 obj
= qmp_output_get_qobject(data
->qov
);
668 check_native_list(obj
, cvalue
->kind
);
669 qapi_free_UserDefNativeListUnion(cvalue
);
673 static void test_visitor_out_native_list_int(TestOutputVisitorData
*data
,
676 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER
);
679 static void test_visitor_out_native_list_int8(TestOutputVisitorData
*data
,
682 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S8
);
685 static void test_visitor_out_native_list_int16(TestOutputVisitorData
*data
,
688 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S16
);
691 static void test_visitor_out_native_list_int32(TestOutputVisitorData
*data
,
694 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S32
);
697 static void test_visitor_out_native_list_int64(TestOutputVisitorData
*data
,
700 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S64
);
703 static void test_visitor_out_native_list_uint8(TestOutputVisitorData
*data
,
706 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U8
);
709 static void test_visitor_out_native_list_uint16(TestOutputVisitorData
*data
,
712 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U16
);
715 static void test_visitor_out_native_list_uint32(TestOutputVisitorData
*data
,
718 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U32
);
721 static void test_visitor_out_native_list_uint64(TestOutputVisitorData
*data
,
724 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U64
);
727 static void test_visitor_out_native_list_bool(TestOutputVisitorData
*data
,
730 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN
);
733 static void test_visitor_out_native_list_str(TestOutputVisitorData
*data
,
736 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_STRING
);
739 static void test_visitor_out_native_list_number(TestOutputVisitorData
*data
,
742 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER
);
745 static void output_visitor_test_add(const char *testpath
,
746 TestOutputVisitorData
*data
,
747 void (*test_func
)(TestOutputVisitorData
*data
, const void *user_data
))
749 g_test_add(testpath
, TestOutputVisitorData
, data
, visitor_output_setup
,
750 test_func
, visitor_output_teardown
);
753 int main(int argc
, char **argv
)
755 TestOutputVisitorData out_visitor_data
;
757 g_test_init(&argc
, &argv
, NULL
);
759 output_visitor_test_add("/visitor/output/int",
760 &out_visitor_data
, test_visitor_out_int
);
761 output_visitor_test_add("/visitor/output/bool",
762 &out_visitor_data
, test_visitor_out_bool
);
763 output_visitor_test_add("/visitor/output/number",
764 &out_visitor_data
, test_visitor_out_number
);
765 output_visitor_test_add("/visitor/output/string",
766 &out_visitor_data
, test_visitor_out_string
);
767 output_visitor_test_add("/visitor/output/no-string",
768 &out_visitor_data
, test_visitor_out_no_string
);
769 output_visitor_test_add("/visitor/output/enum",
770 &out_visitor_data
, test_visitor_out_enum
);
771 output_visitor_test_add("/visitor/output/enum-errors",
772 &out_visitor_data
, test_visitor_out_enum_errors
);
773 output_visitor_test_add("/visitor/output/struct",
774 &out_visitor_data
, test_visitor_out_struct
);
775 output_visitor_test_add("/visitor/output/struct-nested",
776 &out_visitor_data
, test_visitor_out_struct_nested
);
777 output_visitor_test_add("/visitor/output/struct-errors",
778 &out_visitor_data
, test_visitor_out_struct_errors
);
779 output_visitor_test_add("/visitor/output/list",
780 &out_visitor_data
, test_visitor_out_list
);
781 output_visitor_test_add("/visitor/output/list-qapi-free",
782 &out_visitor_data
, test_visitor_out_list_qapi_free
);
783 output_visitor_test_add("/visitor/output/union",
784 &out_visitor_data
, test_visitor_out_union
);
785 output_visitor_test_add("/visitor/output/native_list/int",
786 &out_visitor_data
, test_visitor_out_native_list_int
);
787 output_visitor_test_add("/visitor/output/native_list/int8",
788 &out_visitor_data
, test_visitor_out_native_list_int8
);
789 output_visitor_test_add("/visitor/output/native_list/int16",
790 &out_visitor_data
, test_visitor_out_native_list_int16
);
791 output_visitor_test_add("/visitor/output/native_list/int32",
792 &out_visitor_data
, test_visitor_out_native_list_int32
);
793 output_visitor_test_add("/visitor/output/native_list/int64",
794 &out_visitor_data
, test_visitor_out_native_list_int64
);
795 output_visitor_test_add("/visitor/output/native_list/uint8",
796 &out_visitor_data
, test_visitor_out_native_list_uint8
);
797 output_visitor_test_add("/visitor/output/native_list/uint16",
798 &out_visitor_data
, test_visitor_out_native_list_uint16
);
799 output_visitor_test_add("/visitor/output/native_list/uint32",
800 &out_visitor_data
, test_visitor_out_native_list_uint32
);
801 output_visitor_test_add("/visitor/output/native_list/uint64",
802 &out_visitor_data
, test_visitor_out_native_list_uint64
);
803 output_visitor_test_add("/visitor/output/native_list/bool",
804 &out_visitor_data
, test_visitor_out_native_list_bool
);
805 output_visitor_test_add("/visitor/output/native_list/string",
806 &out_visitor_data
, test_visitor_out_native_list_str
);
807 output_visitor_test_add("/visitor/output/native_list/number",
808 &out_visitor_data
, test_visitor_out_native_list_number
);