diff mbox

[09/11] qjson: add unit test for varargs bool parsing

Message ID 1255786571-3528-10-git-send-email-aliguori@us.ibm.com
State New
Headers show

Commit Message

Anthony Liguori Oct. 17, 2009, 1:36 p.m. UTC
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 check-qjson.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
diff mbox

Patch

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 <check.h>
+#include <stdbool.h>
 
 #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