From 3dcf71f632a0a41ff8c9a27f7cf967c647806c07 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 22 Mar 2012 12:51:03 +0100 Subject: [PATCH] qapi: add a test case for type errors There is no test case for parse errors, add one. Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori Signed-off-by: Luiz Capitulino --- test-qmp-input-visitor.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test-qmp-input-visitor.c b/test-qmp-input-visitor.c index 1996e49576..c30fdc4e59 100644 --- a/test-qmp-input-visitor.c +++ b/test-qmp-input-visitor.c @@ -258,6 +258,23 @@ static void input_visitor_test_add(const char *testpath, visitor_input_teardown); } +static void test_visitor_in_errors(TestInputVisitorData *data, + const void *unused) +{ + TestStruct *p = NULL; + Error *errp = NULL; + Visitor *v; + + v = visitor_input_test_init(data, "{ 'integer': false, 'boolean': 'foo', 'string': -42 }"); + + visit_type_TestStruct(v, &p, NULL, &errp); + g_assert(error_is_set(&errp)); + g_assert(p->string == NULL); + + g_free(p->string); + g_free(p); +} + int main(int argc, char **argv) { TestInputVisitorData in_visitor_data; @@ -282,6 +299,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/errors", + &in_visitor_data, test_visitor_in_errors); g_test_run(); -- 2.34.1