diff options
author | Markus Armbruster <armbru@redhat.com> | 2014-03-01 08:40:33 +0100 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2014-03-03 11:16:45 -0500 |
commit | 2fc00432830e42e3c24850a379194a61f09e3663 (patch) | |
tree | 05753100f6da40a39f11d52e3840b95b9530a6bf /tests/test-qmp-input-strict.c | |
parent | 7ad993b480d3f4f1261d3374516effd9bff20bc6 (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-strict.c')
-rw-r--r-- | tests/test-qmp-input-strict.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c index 9b99b48e87..64d72f6f05 100644 --- a/tests/test-qmp-input-strict.c +++ b/tests/test-qmp-input-strict.c @@ -139,6 +139,21 @@ static void test_validate_union(TestInputVisitorData *data, qapi_free_UserDefUnion(tmp); } +static void test_validate_union_flat(TestInputVisitorData *data, + const void *unused) +{ + UserDefFlatUnion *tmp = NULL; + Visitor *v; + Error *errp = NULL; + + v = validate_test_init(data, "{ 'string': 'a', 'boolean': true }"); + /* TODO when generator bug is fixed, add 'integer': 41 */ + + visit_type_UserDefFlatUnion(v, &tmp, NULL, &errp); + g_assert(!error_is_set(&errp)); + qapi_free_UserDefFlatUnion(tmp); +} + static void test_validate_union_anon(TestInputVisitorData *data, const void *unused) { @@ -212,6 +227,20 @@ static void test_validate_fail_union(TestInputVisitorData *data, qapi_free_UserDefUnion(tmp); } +static void test_validate_fail_union_flat(TestInputVisitorData *data, + const void *unused) +{ + UserDefFlatUnion *tmp = NULL; + Error *errp = NULL; + Visitor *v; + + v = validate_test_init(data, "{ 'string': 'c', 'integer': 41, 'boolean': true }"); + + visit_type_UserDefFlatUnion(v, &tmp, NULL, &errp); + g_assert(error_is_set(&errp)); + qapi_free_UserDefFlatUnion(tmp); +} + static void test_validate_fail_union_anon(TestInputVisitorData *data, const void *unused) { @@ -248,6 +277,8 @@ int main(int argc, char **argv) &testdata, test_validate_list); validate_test_add("/visitor/input-strict/pass/union", &testdata, test_validate_union); + validate_test_add("/visitor/input-strict/pass/union-flat", + &testdata, test_validate_union_flat); validate_test_add("/visitor/input-strict/pass/union-anon", &testdata, test_validate_union_anon); validate_test_add("/visitor/input-strict/fail/struct", @@ -258,6 +289,8 @@ int main(int argc, char **argv) &testdata, test_validate_fail_list); validate_test_add("/visitor/input-strict/fail/union", &testdata, test_validate_fail_union); + validate_test_add("/visitor/input-strict/fail/union-flat", + &testdata, test_validate_fail_union_flat); validate_test_add("/visitor/input-strict/fail/union-anon", &testdata, test_validate_fail_union_anon); |