tests: Don't check qobject_type() before qobject_to_qlist()
authorMarkus Armbruster <armbru@redhat.com>
Fri, 17 Feb 2017 20:38:19 +0000 (21:38 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 22 Feb 2017 18:52:04 +0000 (19:52 +0100)
qobject_to_qlist(obj) returns NULL when obj isn't a QList.  Check
that instead of qobject_type(obj) == QTYPE_QLIST.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1487363905-9480-9-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
tests/test-qobject-output-visitor.c

index a87438613f9138db3866197d5746132466eb1d93..13a0a9b3ac3eb6cacd0a32bde73e817fec4071d6 100644 (file)
@@ -261,7 +261,6 @@ static void test_visitor_out_list(TestOutputVisitorData *data,
     bool value_bool = true;
     int value_int = 10;
     QListEntry *entry;
-    QObject *obj;
     QList *qlist;
     int i;
 
@@ -279,10 +278,8 @@ static void test_visitor_out_list(TestOutputVisitorData *data,
 
     visit_type_TestStructList(data->ov, NULL, &head, &error_abort);
 
-    obj = visitor_get(data);
-    g_assert(qobject_type(obj) == QTYPE_QLIST);
-
-    qlist = qobject_to_qlist(obj);
+    qlist = qobject_to_qlist(visitor_get(data));
+    g_assert(qlist);
     g_assert(!qlist_empty(qlist));
 
     /* ...and ensure that the visitor sees it in order */