From patchwork Sat Oct 17 13:36:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [09/11] qjson: add unit test for varargs bool parsing From: Anthony Liguori X-Patchwork-Id: 36310 Message-Id: <1255786571-3528-10-git-send-email-aliguori@us.ibm.com> To: qemu-devel@nongnu.org Cc: Anthony Liguori Date: Sat, 17 Oct 2009 08:36:09 -0500 Signed-off-by: Anthony Liguori --- check-qjson.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/check-qjson.c b/check-qjson.c index 32aa33c..8760941 100644 --- a/check-qjson.c +++ b/check-qjson.c @@ -9,6 +9,7 @@ * */ #include +#include #include "qstring.h" #include "qint.h" @@ -282,6 +283,26 @@ START_TEST(keyword_literal) fail_unless(qbool_get_int(qbool) == 0); QDECREF(qbool); + + obj = qobject_from_jsonf("%i", &length, false); + fail_unless(obj != NULL); + fail_unless(qobject_type(obj) == QTYPE_QBOOL); + fail_unless(length == 2); + + qbool = qobject_to_qbool(obj); + fail_unless(qbool_get_int(qbool) == 0); + + QDECREF(qbool); + + obj = qobject_from_jsonf("%i", &length, true); + fail_unless(obj != NULL); + fail_unless(qobject_type(obj) == QTYPE_QBOOL); + fail_unless(length == 2); + + qbool = qobject_to_qbool(obj); + fail_unless(qbool_get_int(qbool) != 0); + + QDECREF(qbool); } END_TEST