diff options
author | Markus Armbruster <armbru@redhat.com> | 2017-02-17 21:38:13 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2017-02-22 19:51:48 +0100 |
commit | ff9d38963e55598b40237735426225c35de6c7e5 (patch) | |
tree | c1ed47885294583eb3da4fbd36431a7a6084dd10 /tests | |
parent | b25f23e7dbc6bc0dcda010222a4f178669d1aedc (diff) |
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check-qdict.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/tests/check-qdict.c b/tests/check-qdict.c index 07b1c798d8..14e942aaba 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -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); |