aboutsummaryrefslogtreecommitdiff
path: root/tests/check-qjson.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-02-17 21:38:23 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-02-22 19:52:14 +0100
commitdfad9ec4e9f15344f300996ad8c6f3eaf699d195 (patch)
tree3c338dae06a4aab3f8fbc55dea74b5df6bc01cf2 /tests/check-qjson.c
parent8978b34af3250354e0b67340a7e920f909beda13 (diff)
tests: Don't check qobject_type() before qobject_to_qbool()
qobject_to_qbool(obj) returns NULL when obj isn't a QBool. Check that instead of qobject_type(obj) == QTYPE_QBOOL. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1487363905-9480-13-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests/check-qjson.c')
-rw-r--r--tests/check-qjson.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 591b70ace1..e6d6935653 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -966,10 +966,8 @@ static void keyword_literal(void)
QString *str;
obj = qobject_from_json("true");
- g_assert(obj != NULL);
- g_assert(qobject_type(obj) == QTYPE_QBOOL);
-
qbool = qobject_to_qbool(obj);
+ g_assert(qbool);
g_assert(qbool_get_bool(qbool) == true);
str = qobject_to_json(obj);
@@ -979,10 +977,8 @@ static void keyword_literal(void)
QDECREF(qbool);
obj = qobject_from_json("false");
- g_assert(obj != NULL);
- g_assert(qobject_type(obj) == QTYPE_QBOOL);
-
qbool = qobject_to_qbool(obj);
+ g_assert(qbool);
g_assert(qbool_get_bool(qbool) == false);
str = qobject_to_json(obj);
@@ -991,23 +987,15 @@ static void keyword_literal(void)
QDECREF(qbool);
- obj = qobject_from_jsonf("%i", false);
- g_assert(obj != NULL);
- g_assert(qobject_type(obj) == QTYPE_QBOOL);
-
- qbool = qobject_to_qbool(obj);
+ qbool = qobject_to_qbool(qobject_from_jsonf("%i", false));
+ g_assert(qbool);
g_assert(qbool_get_bool(qbool) == false);
-
QDECREF(qbool);
/* Test that non-zero values other than 1 get collapsed to true */
- obj = qobject_from_jsonf("%i", 2);
- g_assert(obj != NULL);
- g_assert(qobject_type(obj) == QTYPE_QBOOL);
-
- qbool = qobject_to_qbool(obj);
+ qbool = qobject_to_qbool(qobject_from_jsonf("%i", 2));
+ g_assert(qbool);
g_assert(qbool_get_bool(qbool) == true);
-
QDECREF(qbool);
obj = qobject_from_json("null");