aboutsummaryrefslogtreecommitdiff
path: root/tests/test-qmp-input-visitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-03-01 08:40:33 +0100
committerLuiz Capitulino <lcapitulino@redhat.com>2014-03-03 11:16:45 -0500
commit2fc00432830e42e3c24850a379194a61f09e3663 (patch)
tree05753100f6da40a39f11d52e3840b95b9530a6bf /tests/test-qmp-input-visitor.c
parent7ad993b480d3f4f1261d3374516effd9bff20bc6 (diff)
tests/qapi-schema: Cover flat union types
The test demonstrates a generator bug: the generated struct UserDefFlatUnion doesn't include members for the indirect base UserDefZero. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'tests/test-qmp-input-visitor.c')
-rw-r--r--tests/test-qmp-input-visitor.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c
index a0607cf271..2dffafc1f4 100644
--- a/tests/test-qmp-input-visitor.c
+++ b/tests/test-qmp-input-visitor.c
@@ -303,6 +303,24 @@ static void test_visitor_in_union(TestInputVisitorData *data,
qapi_free_UserDefUnion(tmp);
}
+static void test_visitor_in_union_flat(TestInputVisitorData *data,
+ const void *unused)
+{
+ Visitor *v;
+ Error *err = NULL;
+ UserDefFlatUnion *tmp;
+
+ v = visitor_input_test_init(data, "{ 'string': 'a', 'boolean': true }");
+ /* TODO when generator bug is fixed, add 'integer': 41 */
+
+ visit_type_UserDefFlatUnion(v, &tmp, NULL, &err);
+ g_assert(err == NULL);
+ g_assert_cmpint(tmp->kind, ==, USER_DEF_UNION_KIND_A);
+ /* TODO g_assert_cmpint(tmp->integer, ==, 41); */
+ g_assert_cmpint(tmp->a->boolean, ==, true);
+ qapi_free_UserDefFlatUnion(tmp);
+}
+
static void test_visitor_in_union_anon(TestInputVisitorData *data,
const void *unused)
{
@@ -652,6 +670,8 @@ int main(int argc, char **argv)
&in_visitor_data, test_visitor_in_list);
input_visitor_test_add("/visitor/input/union",
&in_visitor_data, test_visitor_in_union);
+ input_visitor_test_add("/visitor/input/union-flat",
+ &in_visitor_data, test_visitor_in_union_flat);
input_visitor_test_add("/visitor/input/union-anon",
&in_visitor_data, test_visitor_in_union_anon);
input_visitor_test_add("/visitor/input/errors",