aboutsummaryrefslogtreecommitdiff
path: root/tests/test-string-input-visitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-03-03 13:32:43 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-03-05 09:14:20 +0100
commit9cb8ef36681b9645af1f7bd8fb64656e65de8a03 (patch)
tree8e5703f5c7fb6821eeb5496406cedf4e5e2a3e28 /tests/test-string-input-visitor.c
parent3d089cea0d32e2cb63604a98f4aa2028860502f0 (diff)
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 <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1488544368-30622-24-git-send-email-armbru@redhat.com>
Diffstat (limited to 'tests/test-string-input-visitor.c')
-rw-r--r--tests/test-string-input-visitor.c22
1 files changed, 22 insertions, 0 deletions
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,