提交 8978b34a 编写于 作者: M Markus Armbruster

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: NMarkus Armbruster <armbru@redhat.com>
Message-Id: <1487363905-9480-12-git-send-email-armbru@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
上级 0abfc4b8
...@@ -921,10 +921,8 @@ static void float_number(void) ...@@ -921,10 +921,8 @@ static void float_number(void)
QFloat *qfloat; QFloat *qfloat;
obj = qobject_from_json(test_cases[i].encoded); obj = qobject_from_json(test_cases[i].encoded);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QFLOAT);
qfloat = qobject_to_qfloat(obj); qfloat = qobject_to_qfloat(obj);
g_assert(qfloat);
g_assert(qfloat_get_double(qfloat) == test_cases[i].decoded); g_assert(qfloat_get_double(qfloat) == test_cases[i].decoded);
if (test_cases[i].skip == 0) { if (test_cases[i].skip == 0) {
...@@ -941,7 +939,6 @@ static void float_number(void) ...@@ -941,7 +939,6 @@ static void float_number(void)
static void vararg_number(void) static void vararg_number(void)
{ {
QObject *obj;
QInt *qint; QInt *qint;
QFloat *qfloat; QFloat *qfloat;
int value = 0x2342; int value = 0x2342;
...@@ -956,13 +953,8 @@ static void vararg_number(void) ...@@ -956,13 +953,8 @@ static void vararg_number(void)
g_assert(qint_get_int(qint) == value_ll); g_assert(qint_get_int(qint) == value_ll);
QDECREF(qint); QDECREF(qint);
obj = qobject_from_jsonf("%f", valuef); qfloat = qobject_to_qfloat(qobject_from_jsonf("%f", valuef));
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QFLOAT);
qfloat = qobject_to_qfloat(obj);
g_assert(qfloat_get_double(qfloat) == valuef); g_assert(qfloat_get_double(qfloat) == valuef);
QDECREF(qfloat); QDECREF(qfloat);
} }
......
...@@ -84,13 +84,13 @@ static void test_visitor_out_number(TestOutputVisitorData *data, ...@@ -84,13 +84,13 @@ static void test_visitor_out_number(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
double value = 3.14; double value = 3.14;
QObject *obj; QFloat *qfloat;
visit_type_number(data->ov, NULL, &value, &error_abort); visit_type_number(data->ov, NULL, &value, &error_abort);
obj = visitor_get(data); qfloat = qobject_to_qfloat(visitor_get(data));
g_assert(qobject_type(obj) == QTYPE_QFLOAT); g_assert(qfloat);
g_assert(qfloat_get_double(qobject_to_qfloat(obj)) == value); g_assert(qfloat_get_double(qfloat) == value);
} }
static void test_visitor_out_string(TestOutputVisitorData *data, static void test_visitor_out_string(TestOutputVisitorData *data,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册