summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-05-15 16:24:59 -0600
committerMarkus Armbruster <armbru@redhat.com>2015-06-22 17:40:00 +0200
commitfc48ffc39ed1060856475e4320d5896f26c945e8 (patch)
tree4e4a5a4b9a6b9a0602fe5863e694ec472edccbf8 /tests
parent0a3346f5dea0a679322df804e1e78d7c10d12a9f (diff)
downloadqemu-fc48ffc39ed1060856475e4320d5896f26c945e8.tar.gz
qemu-fc48ffc39ed1060856475e4320d5896f26c945e8.tar.bz2
qemu-fc48ffc39ed1060856475e4320d5896f26c945e8.zip
qobject: Use 'bool' for qbool
We require a C99 compiler, so let's use 'bool' instead of 'int' when dealing with boolean values. There are few enough clients to fix them all in one pass. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Alberto Garcia <berto@igalia.com> Acked-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/check-qjson.c11
-rw-r--r--tests/test-qmp-event.c4
-rw-r--r--tests/test-qmp-output-visitor.c4
3 files changed, 10 insertions, 9 deletions
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 60e5b22a98..1cfffa5934 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -1013,7 +1013,7 @@ static void keyword_literal(void)
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
- g_assert(qbool_get_int(qbool) != 0);
+ g_assert(qbool_get_bool(qbool) == true);
str = qobject_to_json(obj);
g_assert(strcmp(qstring_get_str(str), "true") == 0);
@@ -1026,7 +1026,7 @@ static void keyword_literal(void)
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
- g_assert(qbool_get_int(qbool) == 0);
+ g_assert(qbool_get_bool(qbool) == false);
str = qobject_to_json(obj);
g_assert(strcmp(qstring_get_str(str), "false") == 0);
@@ -1039,16 +1039,17 @@ static void keyword_literal(void)
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
- g_assert(qbool_get_int(qbool) == 0);
+ g_assert(qbool_get_bool(qbool) == false);
QDECREF(qbool);
- obj = qobject_from_jsonf("%i", true);
+ /* 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);
- g_assert(qbool_get_int(qbool) != 0);
+ g_assert(qbool_get_bool(qbool) == true);
QDECREF(qbool);
diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c
index cb354e6e81..1ee40e148a 100644
--- a/tests/test-qmp-event.c
+++ b/tests/test-qmp-event.c
@@ -60,8 +60,8 @@ void qdict_cmp_do_simple(const char *key, QObject *obj1, void *opaque)
switch (qobject_type(obj1)) {
case QTYPE_QBOOL:
- d->result = (qbool_get_int(qobject_to_qbool(obj1)) ==
- qbool_get_int(qobject_to_qbool(obj2)));
+ d->result = (qbool_get_bool(qobject_to_qbool(obj1)) ==
+ qbool_get_bool(qobject_to_qbool(obj2)));
return;
case QTYPE_QINT:
d->result = (qint_get_int(qobject_to_qint(obj1)) ==
diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c
index f8c9367e48..5be8e77aa5 100644
--- a/tests/test-qmp-output-visitor.c
+++ b/tests/test-qmp-output-visitor.c
@@ -72,7 +72,7 @@ static void test_visitor_out_bool(TestOutputVisitorData *data,
obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QBOOL);
- g_assert(qbool_get_int(qobject_to_qbool(obj)) == value);
+ g_assert(qbool_get_bool(qobject_to_qbool(obj)) == value);
qobject_decref(obj);
}
@@ -662,7 +662,7 @@ static void check_native_list(QObject *qobj,
tmp = qlist_peek(qlist);
g_assert(tmp);
qvalue = qobject_to_qbool(tmp);
- g_assert_cmpint(qbool_get_int(qvalue), ==, (i % 3 == 0) ? 1 : 0);
+ g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0);
qobject_decref(qlist_pop(qlist));
}
break;