summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarkus Armbruster2017-03-20 13:55:44 +0100
committerMarkus Armbruster2017-03-21 10:41:43 +0100
commitb2cd5b925c529d91fae5fe8373490714e1a8fe6c (patch)
tree304e4a8870e56728392e5b5dbd3008376fca83e4 /tests
parentMerge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (diff)
downloadqemu-b2cd5b925c529d91fae5fe8373490714e1a8fe6c.tar.gz
qemu-b2cd5b925c529d91fae5fe8373490714e1a8fe6c.tar.xz
qemu-b2cd5b925c529d91fae5fe8373490714e1a8fe6c.zip
test-keyval: Tweaks to improve list coverage
We have a negative test case for a list index with leading zero. Add positive ones. Tweak the test case for list index greater or equal the number of elements: test "equal" instead of "greater" to guard against off-by-one mistakes. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1490014548-15083-2-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test-keyval.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/test-keyval.c b/tests/test-keyval.c
index 71288b082c..e97f6d554d 100644
--- a/tests/test-keyval.c
+++ b/tests/test-keyval.c
@@ -218,14 +218,14 @@ static void test_keyval_parse_list(void)
QDECREF(qdict);
/* Multiple indexes, last one wins */
- qdict = keyval_parse("list.1=goner,list.0=null,list.1=eins,list.2=zwei",
+ qdict = keyval_parse("list.1=goner,list.0=null,list.01=eins,list.2=zwei",
NULL, &error_abort);
g_assert_cmpint(qdict_size(qdict), ==, 1);
check_list012(qdict_get_qlist(qdict, "list"));
QDECREF(qdict);
/* List at deeper nesting */
- qdict = keyval_parse("a.list.1=eins,a.list.0=null,a.list.2=zwei",
+ qdict = keyval_parse("a.list.1=eins,a.list.00=null,a.list.2=zwei",
NULL, &error_abort);
g_assert_cmpint(qdict_size(qdict), ==, 1);
sub_qdict = qdict_get_qdict(qdict, "a");
@@ -242,7 +242,7 @@ static void test_keyval_parse_list(void)
g_assert(!qdict);
/* Missing list indexes */
- qdict = keyval_parse("list.2=lonely", NULL, &err);
+ qdict = keyval_parse("list.1=lonely", NULL, &err);
error_free_or_abort(&err);
g_assert(!qdict);
qdict = keyval_parse("list.0=null,list.2=eins,list.02=zwei", NULL, &err);