@@ -217,7 +217,7 @@ check-qstring: check-qstring.o qstring.o qemu-malloc.o
check-qdict: check-qdict.o qdict.o qint.o qstring.o qemu-malloc.o
check-qlist: check-qlist.o qlist.o qint.o qemu-malloc.o
check-qfloat: check-qfloat.o qfloat.o qemu-malloc.o
-check-qjson: check-qjson.o qjson.o qstring.o qint.o qdict.o qlist.o qfloat.o qemu-malloc.o
+check-qjson: check-qjson.o qjson.o qstring.o qint.o qdict.o qlist.o qfloat.o qbool.o qemu-malloc.o
clean:
# avoid old build problems by removing potentially incorrect old files
@@ -15,6 +15,7 @@
#include "qdict.h"
#include "qlist.h"
#include "qfloat.h"
+#include "qbool.h"
#include "qjson.h"
#include "qemu-common.h"
@@ -259,28 +260,28 @@ END_TEST
START_TEST(keyword_literal)
{
QObject *obj;
- QInt *qint;
+ QBool *qbool;
size_t length = 0;
obj = qobject_from_json("true", &length);
fail_unless(obj != NULL);
- fail_unless(qobject_type(obj) == QTYPE_QINT);
+ fail_unless(qobject_type(obj) == QTYPE_QBOOL);
fail_unless(length == 4);
- qint = qobject_to_qint(obj);
- fail_unless(qint_get_int(qint) != 0);
+ qbool = qobject_to_qbool(obj);
+ fail_unless(qbool_get_int(qbool) != 0);
- QDECREF(qint);
+ QDECREF(qbool);
obj = qobject_from_json("false", &length);
fail_unless(obj != NULL);
- fail_unless(qobject_type(obj) == QTYPE_QINT);
+ fail_unless(qobject_type(obj) == QTYPE_QBOOL);
fail_unless(length == 5);
- qint = qobject_to_qint(obj);
- fail_unless(qint_get_int(qint) == 0);
+ qbool = qobject_to_qbool(obj);
+ fail_unless(qbool_get_int(qbool) == 0);
- QDECREF(qint);
+ QDECREF(qbool);
}
END_TEST
@@ -17,6 +17,7 @@
#include "qdict.h"
#include "qlist.h"
#include "qfloat.h"
+#include "qbool.h"
#include "qjson.h"
typedef struct JSONParserContext
@@ -627,9 +628,9 @@ static QObject *parse_keyword(JSONParserContext *ctxt, const char *data, size_t
}
if (strcmp(qstring_get_str(str), "true") == 0) {
- obj = QOBJECT(qint_from_int(1));
+ obj = QOBJECT(qbool_from_int(1));
} else if (strcmp(qstring_get_str(str), "false") == 0) {
- obj = QOBJECT(qint_from_int(0));
+ obj = QOBJECT(qbool_from_int(0));
}
if (obj) {
Instead of parsing true/false as QInt, parse them as QBool and update the test suite accordingly. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- Makefile | 2 +- check-qjson.c | 19 ++++++++++--------- qjson.c | 5 +++-- 3 files changed, 14 insertions(+), 12 deletions(-)