mirror of https://github.com/xqemu/xqemu.git
tests: Don't check qobject_type() before qobject_to_qfloat()
qobject_to_qfloat(obj) returns NULL when obj isn't a QFloat. Check that instead of qobject_type(obj) == QTYPE_QFLOAT. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1487363905-9480-12-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
0abfc4b885
commit
8978b34af3
|
@ -921,10 +921,8 @@ static void float_number(void)
|
|||
QFloat *qfloat;
|
||||
|
||||
obj = qobject_from_json(test_cases[i].encoded);
|
||||
g_assert(obj != NULL);
|
||||
g_assert(qobject_type(obj) == QTYPE_QFLOAT);
|
||||
|
||||
qfloat = qobject_to_qfloat(obj);
|
||||
g_assert(qfloat);
|
||||
g_assert(qfloat_get_double(qfloat) == test_cases[i].decoded);
|
||||
|
||||
if (test_cases[i].skip == 0) {
|
||||
|
@ -941,7 +939,6 @@ static void float_number(void)
|
|||
|
||||
static void vararg_number(void)
|
||||
{
|
||||
QObject *obj;
|
||||
QInt *qint;
|
||||
QFloat *qfloat;
|
||||
int value = 0x2342;
|
||||
|
@ -956,13 +953,8 @@ static void vararg_number(void)
|
|||
g_assert(qint_get_int(qint) == value_ll);
|
||||
QDECREF(qint);
|
||||
|
||||
obj = qobject_from_jsonf("%f", valuef);
|
||||
g_assert(obj != NULL);
|
||||
g_assert(qobject_type(obj) == QTYPE_QFLOAT);
|
||||
|
||||
qfloat = qobject_to_qfloat(obj);
|
||||
qfloat = qobject_to_qfloat(qobject_from_jsonf("%f", valuef));
|
||||
g_assert(qfloat_get_double(qfloat) == valuef);
|
||||
|
||||
QDECREF(qfloat);
|
||||
}
|
||||
|
||||
|
|
|
@ -84,13 +84,13 @@ static void test_visitor_out_number(TestOutputVisitorData *data,
|
|||
const void *unused)
|
||||
{
|
||||
double value = 3.14;
|
||||
QObject *obj;
|
||||
QFloat *qfloat;
|
||||
|
||||
visit_type_number(data->ov, NULL, &value, &error_abort);
|
||||
|
||||
obj = visitor_get(data);
|
||||
g_assert(qobject_type(obj) == QTYPE_QFLOAT);
|
||||
g_assert(qfloat_get_double(qobject_to_qfloat(obj)) == value);
|
||||
qfloat = qobject_to_qfloat(visitor_get(data));
|
||||
g_assert(qfloat);
|
||||
g_assert(qfloat_get_double(qfloat) == value);
|
||||
}
|
||||
|
||||
static void test_visitor_out_string(TestOutputVisitorData *data,
|
||||
|
|
Loading…
Reference in New Issue