aboutsummaryrefslogtreecommitdiff
path: root/tests/check-qdict.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-06-07 20:35:58 +0400
committerMarkus Armbruster <armbru@redhat.com>2017-06-20 14:31:31 +0200
commit01b2ffcedd94ad7b42bc870e4c6936c87ad03429 (patch)
tree39bbadfbbaa229bfbda245840a256fe0132b2390 /tests/check-qdict.c
parent58634047b7deeab36e4b07c4744e44d698975561 (diff)
qapi: merge QInt and QFloat in QNum
We would like to use a same QObject type to represent numbers, whether they are int, uint, or floats. Getters will allow some compatibility between the various types if the number fits other representations. Add a few more tests while at it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20170607163635.17635-7-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [parse_stats_intervals() simplified a bit, comment in test_visitor_in_int_overflow() tidied up, suppress bogus warnings] Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests/check-qdict.c')
-rw-r--r--tests/check-qdict.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/tests/check-qdict.c b/tests/check-qdict.c
index be8d81f07b..f067c63275 100644
--- a/tests/check-qdict.c
+++ b/tests/check-qdict.c
@@ -11,7 +11,6 @@
*/
#include "qemu/osdep.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h"
#include "qapi/error.h"
@@ -39,7 +38,7 @@ static void qdict_new_test(void)
static void qdict_put_obj_test(void)
{
- QInt *qi;
+ QNum *qn;
QDict *qdict;
QDictEntry *ent;
const int num = 42;
@@ -51,11 +50,11 @@ static void qdict_put_obj_test(void)
g_assert(qdict_size(qdict) == 1);
ent = QLIST_FIRST(&qdict->table[12345 % QDICT_BUCKET_MAX]);
- qi = qobject_to_qint(ent->value);
- g_assert(qint_get_int(qi) == num);
+ qn = qobject_to_qnum(ent->value);
+ g_assert_cmpint(qnum_get_int(qn), ==, num);
// destroy doesn't exit yet
- QDECREF(qi);
+ QDECREF(qn);
g_free(ent->key);
g_free(ent);
g_free(qdict);
@@ -74,7 +73,7 @@ static void qdict_destroy_simple_test(void)
static void qdict_get_test(void)
{
- QInt *qi;
+ QNum *qn;
QObject *obj;
const int value = -42;
const char *key = "test";
@@ -85,8 +84,8 @@ static void qdict_get_test(void)
obj = qdict_get(tests_dict, key);
g_assert(obj != NULL);
- qi = qobject_to_qint(obj);
- g_assert(qint_get_int(qi) == value);
+ qn = qobject_to_qnum(obj);
+ g_assert_cmpint(qnum_get_int(qn), ==, value);
QDECREF(tests_dict);
}
@@ -329,7 +328,7 @@ static void qdict_array_split_test(void)
{
QDict *test_dict = qdict_new();
QDict *dict1, *dict2;
- QInt *int1;
+ QNum *int1;
QList *test_list;
/*
@@ -380,7 +379,7 @@ static void qdict_array_split_test(void)
dict1 = qobject_to_qdict(qlist_pop(test_list));
dict2 = qobject_to_qdict(qlist_pop(test_list));
- int1 = qobject_to_qint(qlist_pop(test_list));
+ int1 = qobject_to_qnum(qlist_pop(test_list));
g_assert(dict1);
g_assert(dict2);
@@ -402,7 +401,7 @@ static void qdict_array_split_test(void)
QDECREF(dict2);
- g_assert(qint_get_int(int1) == 66);
+ g_assert_cmpint(qnum_get_int(int1), ==, 66);
QDECREF(int1);
@@ -447,14 +446,14 @@ static void qdict_array_split_test(void)
qdict_array_split(test_dict, &test_list);
- int1 = qobject_to_qint(qlist_pop(test_list));
+ int1 = qobject_to_qnum(qlist_pop(test_list));
g_assert(int1);
g_assert(qlist_empty(test_list));
QDECREF(test_list);
- g_assert(qint_get_int(int1) == 42);
+ g_assert_cmpint(qnum_get_int(int1), ==, 42);
QDECREF(int1);