diff options
author | Eric Blake <eblake@redhat.com> | 2015-05-04 09:05:06 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2015-05-05 18:39:00 +0200 |
commit | 805017b7791200f1b72deef17dc98fd272b941eb (patch) | |
tree | 49bc07217955700c1dac29b6396f81a06a9506b9 /tests/test-qmp-input-strict.c | |
parent | 3d0c48292633260269cb21551d9bab006b2f2781 (diff) | |
download | qemu-805017b7791200f1b72deef17dc98fd272b941eb.zip qemu-805017b7791200f1b72deef17dc98fd272b941eb.tar.gz qemu-805017b7791200f1b72deef17dc98fd272b941eb.tar.bz2 |
qapi: Clean up test coverage of simple unions
The tests of UserDefNativeListUnion serve to validate code
generation of simple unions without a base type, except that it
did not have full coverage in the strict test. The next commits
will remove tests and support for simple unions with a base type,
so there is no real loss at repurposing that test here as
opposed to churn of adding a new test then deleting the old one.
Fix some indentation and long lines while at it.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests/test-qmp-input-strict.c')
-rw-r--r-- | tests/test-qmp-input-strict.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c index d5360c6..486848e 100644 --- a/tests/test-qmp-input-strict.c +++ b/tests/test-qmp-input-strict.c @@ -1,7 +1,7 @@ /* * QMP Input Visitor unit-tests (strict mode). * - * Copyright (C) 2011-2012 Red Hat Inc. + * Copyright (C) 2011-2012, 2015 Red Hat Inc. * * Authors: * Luiz Capitulino <lcapitulino@redhat.com> @@ -141,18 +141,18 @@ static void test_validate_list(TestInputVisitorData *data, qapi_free_UserDefOneList(head); } -static void test_validate_union(TestInputVisitorData *data, - const void *unused) +static void test_validate_union_native_list(TestInputVisitorData *data, + const void *unused) { - UserDefUnion *tmp = NULL; + UserDefNativeListUnion *tmp = NULL; Visitor *v; Error *err = NULL; - v = validate_test_init(data, "{ 'type': 'b', 'integer': 41, 'data' : { 'integer': 42 } }"); + v = validate_test_init(data, "{ 'type': 'integer', 'data' : [ 1, 2 ] }"); - visit_type_UserDefUnion(v, &tmp, NULL, &err); + visit_type_UserDefNativeListUnion(v, &tmp, NULL, &err); g_assert(!err); - qapi_free_UserDefUnion(tmp); + qapi_free_UserDefNativeListUnion(tmp); } static void test_validate_union_flat(TestInputVisitorData *data, @@ -232,18 +232,19 @@ static void test_validate_fail_list(TestInputVisitorData *data, qapi_free_UserDefOneList(head); } -static void test_validate_fail_union(TestInputVisitorData *data, - const void *unused) +static void test_validate_fail_union_native_list(TestInputVisitorData *data, + const void *unused) { - UserDefUnion *tmp = NULL; + UserDefNativeListUnion *tmp = NULL; Error *err = NULL; Visitor *v; - v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 } }"); + v = validate_test_init(data, + "{ 'type': 'integer', 'data' : [ 'string' ] }"); - visit_type_UserDefUnion(v, &tmp, NULL, &err); + visit_type_UserDefNativeListUnion(v, &tmp, NULL, &err); g_assert(err); - qapi_free_UserDefUnion(tmp); + qapi_free_UserDefNativeListUnion(tmp); } static void test_validate_fail_union_flat(TestInputVisitorData *data, @@ -304,31 +305,31 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); validate_test_add("/visitor/input-strict/pass/struct", - &testdata, test_validate_struct); + &testdata, test_validate_struct); validate_test_add("/visitor/input-strict/pass/struct-nested", - &testdata, test_validate_struct_nested); + &testdata, test_validate_struct_nested); validate_test_add("/visitor/input-strict/pass/list", - &testdata, test_validate_list); - validate_test_add("/visitor/input-strict/pass/union", - &testdata, test_validate_union); + &testdata, test_validate_list); validate_test_add("/visitor/input-strict/pass/union-flat", - &testdata, test_validate_union_flat); + &testdata, test_validate_union_flat); validate_test_add("/visitor/input-strict/pass/union-anon", - &testdata, test_validate_union_anon); + &testdata, test_validate_union_anon); + validate_test_add("/visitor/input-strict/pass/union-native-list", + &testdata, test_validate_union_native_list); validate_test_add("/visitor/input-strict/fail/struct", - &testdata, test_validate_fail_struct); + &testdata, test_validate_fail_struct); validate_test_add("/visitor/input-strict/fail/struct-nested", - &testdata, test_validate_fail_struct_nested); + &testdata, test_validate_fail_struct_nested); validate_test_add("/visitor/input-strict/fail/list", - &testdata, test_validate_fail_list); - validate_test_add("/visitor/input-strict/fail/union", - &testdata, test_validate_fail_union); + &testdata, test_validate_fail_list); validate_test_add("/visitor/input-strict/fail/union-flat", - &testdata, test_validate_fail_union_flat); + &testdata, test_validate_fail_union_flat); validate_test_add("/visitor/input-strict/fail/union-flat-no-discriminator", - &testdata, test_validate_fail_union_flat_no_discrim); + &testdata, test_validate_fail_union_flat_no_discrim); validate_test_add("/visitor/input-strict/fail/union-anon", - &testdata, test_validate_fail_union_anon); + &testdata, test_validate_fail_union_anon); + validate_test_add("/visitor/input-strict/fail/union-native-list", + &testdata, test_validate_fail_union_native_list); g_test_run(); |