From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 04/14] check-qjson: Simplify around compare_litqobj_to_qobj()
Date: Fri, 17 Feb 2017 21:38:15 +0100 [thread overview]
Message-ID: <1487363905-9480-5-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1487363905-9480-1-git-send-email-armbru@redhat.com>
Make compare_litqobj_to_qobj() cope with null, and drop non-null
assertions from callers.
compare_litqobj_to_qobj() already checks the QType matches; drop the
redundant assertions from callers.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
tests/check-qjson.c | 22 +---------------------
1 file changed, 1 insertion(+), 21 deletions(-)
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 0b21a22..49e02591 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -1110,7 +1110,7 @@ static void compare_helper(QObject *obj, void *opaque)
static int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs)
{
- if (lhs->type != qobject_type(rhs)) {
+ if (!rhs || lhs->type != qobject_type(rhs)) {
return 0;
}
@@ -1184,18 +1184,12 @@ static void simple_dict(void)
QString *str;
obj = qobject_from_json(test_cases[i].encoded);
- g_assert(obj != NULL);
- g_assert(qobject_type(obj) == QTYPE_QDICT);
-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
str = qobject_to_json(obj);
qobject_decref(obj);
obj = qobject_from_json(qstring_get_str(str));
- g_assert(obj != NULL);
- g_assert(qobject_type(obj) == QTYPE_QDICT);
-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
qobject_decref(obj);
QDECREF(str);
@@ -1299,18 +1293,12 @@ static void simple_list(void)
QString *str;
obj = qobject_from_json(test_cases[i].encoded);
- g_assert(obj != NULL);
- g_assert(qobject_type(obj) == QTYPE_QLIST);
-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
str = qobject_to_json(obj);
qobject_decref(obj);
obj = qobject_from_json(qstring_get_str(str));
- g_assert(obj != NULL);
- g_assert(qobject_type(obj) == QTYPE_QLIST);
-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
qobject_decref(obj);
QDECREF(str);
@@ -1367,18 +1355,12 @@ static void simple_whitespace(void)
QString *str;
obj = qobject_from_json(test_cases[i].encoded);
- g_assert(obj != NULL);
- g_assert(qobject_type(obj) == QTYPE_QLIST);
-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
str = qobject_to_json(obj);
qobject_decref(obj);
obj = qobject_from_json(qstring_get_str(str));
- g_assert(obj != NULL);
- g_assert(qobject_type(obj) == QTYPE_QLIST);
-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
qobject_decref(obj);
@@ -1403,8 +1385,6 @@ static void simple_varargs(void)
g_assert(embedded_obj != NULL);
obj = qobject_from_jsonf("[%d, 2, %p]", 1, embedded_obj);
- g_assert(obj != NULL);
-
g_assert(compare_litqobj_to_qobj(&decoded, obj) == 1);
qobject_decref(obj);
--
2.7.4
next prev parent reply other threads:[~2017-02-17 20:38 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-17 20:38 [Qemu-devel] [PATCH 00/14] qobject: Cleanups, mostly in tests Markus Armbruster
2017-02-17 20:38 ` [Qemu-devel] [PATCH 01/14] qdict: Make qdict_get_qlist() safe like qdict_get_qdict() Markus Armbruster
2017-02-17 22:29 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 02/14] check-qdict: Simplify qdict_crumple_test_recursive() Markus Armbruster
2017-02-17 22:34 ` Eric Blake
2017-02-18 10:49 ` Markus Armbruster
2017-02-17 20:38 ` [Qemu-devel] [PATCH 03/14] check-qdict: Tighten qdict_crumple_test_recursive() some Markus Armbruster
2017-02-18 13:11 ` Eric Blake
2017-02-17 20:38 ` Markus Armbruster [this message]
2017-02-18 15:54 ` [Qemu-devel] [PATCH 04/14] check-qjson: Simplify around compare_litqobj_to_qobj() Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 05/14] libqtest: Clean up qmp_response() a bit Markus Armbruster
2017-02-21 2:48 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 06/14] test-qmp-event: Simplify and tighten event_test_emit() Markus Armbruster
2017-02-21 15:03 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 07/14] Don't check qobject_type() before qobject_to_qdict() Markus Armbruster
2017-02-21 15:05 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 08/14] tests: Don't check qobject_type() before qobject_to_qlist() Markus Armbruster
2017-02-21 16:35 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 09/14] tests: Don't check qobject_type() before qobject_to_qstring() Markus Armbruster
2017-02-21 17:50 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 10/14] tests: Don't check qobject_type() before qobject_to_qint() Markus Armbruster
2017-02-21 19:18 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 11/14] tests: Don't check qobject_type() before qobject_to_qfloat() Markus Armbruster
2017-02-21 19:38 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 12/14] tests: Don't check qobject_type() before qobject_to_qbool() Markus Armbruster
2017-02-21 19:44 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 13/14] monitor: Clean up handle_hmp_command() a bit Markus Armbruster
2017-02-21 19:45 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 14/14] block: Don't bother asserting type of output visitor's output Markus Armbruster
2017-02-21 19:46 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1487363905-9480-5-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).