check-qdict: Simplify qdict_crumple_test_recursive()

Use qdict_get_qdict(), qdict_get_qlist() instead of qdict_get()
followed by qobject_to_qdict(), qobject_to_qlist().

While there, drop some redundant code.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1487363905-9480-3-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Markus Armbruster 2017-02-17 21:38:13 +01:00
parent b25f23e7db
commit ff9d38963e

View File

@ -591,7 +591,7 @@ static void qdict_join_test(void)
static void qdict_crumple_test_recursive(void)
{
QDict *src, *dst, *rule, *vnc, *acl, *listen;
QObject *child, *res;
QObject *res;
QList *rules;
src = qdict_new();
@ -613,23 +613,19 @@ static void qdict_crumple_test_recursive(void)
g_assert_cmpint(qdict_size(dst), ==, 1);
child = qdict_get(dst, "vnc");
g_assert_cmpint(qobject_type(child), ==, QTYPE_QDICT);
vnc = qobject_to_qdict(child);
vnc = qdict_get_qdict(dst, "vnc");
g_assert(vnc);
child = qdict_get(vnc, "listen");
g_assert_cmpint(qobject_type(child), ==, QTYPE_QDICT);
listen = qobject_to_qdict(child);
listen = qdict_get_qdict(vnc, "listen");
g_assert(listen);
g_assert_cmpstr("127.0.0.1", ==, qdict_get_str(listen, "addr"));
g_assert_cmpstr("5901", ==, qdict_get_str(listen, "port"));
child = qdict_get(vnc, "acl");
g_assert_cmpint(qobject_type(child), ==, QTYPE_QDICT);
acl = qobject_to_qdict(child);
acl = qdict_get_qdict(vnc, "acl");
g_assert(acl);
child = qdict_get(acl, "rules");
g_assert_cmpint(qobject_type(child), ==, QTYPE_QLIST);
rules = qobject_to_qlist(child);
rules = qdict_get_qlist(acl, "rules");
g_assert(rules);
g_assert_cmpint(qlist_size(rules), ==, 2);
rule = qobject_to_qdict(qlist_pop(rules));
@ -646,9 +642,6 @@ static void qdict_crumple_test_recursive(void)
/* With recursive crumpling, we should see all names unescaped */
g_assert_cmpstr("acl0", ==, qdict_get_str(vnc, "acl.name"));
child = qdict_get(vnc, "acl");
g_assert_cmpint(qobject_type(child), ==, QTYPE_QDICT);
acl = qdict_get_qdict(vnc, "acl");
g_assert_cmpstr("acl0", ==, qdict_get_str(acl, "rule.name"));
QDECREF(src);