From 9cb8ef36681b9645af1f7bd8fb64656e65de8a03 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 3 Mar 2017 13:32:43 +0100 Subject: tests: Cover partial input visit of list Demonstrates a design flaw: there is no way to for input visitors to report that a list visit didn't visit the complete input list. The generated list visits always do, but manual visits needn't. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <1488544368-30622-24-git-send-email-armbru@redhat.com> --- tests/test-string-input-visitor.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/test-string-input-visitor.c') diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c index 72f8732f97..70cee65cd0 100644 --- a/tests/test-string-input-visitor.c +++ b/tests/test-string-input-visitor.c @@ -121,6 +121,7 @@ static void test_visitor_in_intList(TestInputVisitorData *data, uint64_t expect4[] = { UINT64_MAX }; Error *err = NULL; int64List *res = NULL; + int64List *tail; Visitor *v; /* Valid lists */ @@ -151,6 +152,27 @@ static void test_visitor_in_intList(TestInputVisitorData *data, visit_type_int64List(v, NULL, &res, &err); error_free_or_abort(&err); g_assert(!res); + + /* Unvisited list tail */ + + v = visitor_input_test_init(data, "0,2-3"); + + /* Would be simpler if the visitor genuinely supported virtual walks */ + visit_start_list(v, NULL, (GenericList **)&res, sizeof(*res), + &error_abort); + tail = res; + visit_type_int64(v, NULL, &tail->value, &error_abort); + g_assert_cmpint(tail->value, ==, 0); + tail = (int64List *)visit_next_list(v, (GenericList *)tail, sizeof(*res)); + g_assert(tail); + visit_type_int64(v, NULL, &tail->value, &error_abort); + g_assert_cmpint(tail->value, ==, 2); + tail = (int64List *)visit_next_list(v, (GenericList *)tail, sizeof(*res)); + g_assert(tail); + visit_end_list(v, (void **)&res); + /* BUG: unvisited tail not reported; actually not reportable by design */ + + qapi_free_int64List(res); } static void test_visitor_in_bool(TestInputVisitorData *data, -- cgit 1.4.1