2009-11-11 16:36:51 +00:00
|
|
|
/*
|
|
|
|
* QFloat unit-tests.
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2009
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Anthony Liguori <aliguori@us.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
|
|
|
* See the COPYING.LIB file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
2016-02-08 18:08:51 +00:00
|
|
|
#include "qemu/osdep.h"
|
2009-11-11 16:36:51 +00:00
|
|
|
|
2012-12-17 17:19:43 +00:00
|
|
|
#include "qapi/qmp/qfloat.h"
|
2009-11-11 16:36:51 +00:00
|
|
|
#include "qemu-common.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Public Interface test-cases
|
|
|
|
*
|
|
|
|
* (with some violations to access 'private' data)
|
|
|
|
*/
|
|
|
|
|
2012-01-10 19:10:45 +00:00
|
|
|
static void qfloat_from_double_test(void)
|
2009-11-11 16:36:51 +00:00
|
|
|
{
|
|
|
|
QFloat *qf;
|
|
|
|
const double value = -42.23423;
|
|
|
|
|
|
|
|
qf = qfloat_from_double(value);
|
2012-01-10 19:10:45 +00:00
|
|
|
g_assert(qf != NULL);
|
|
|
|
g_assert(qf->value == value);
|
|
|
|
g_assert(qf->base.refcnt == 1);
|
|
|
|
g_assert(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
|
2009-11-11 16:36:51 +00:00
|
|
|
|
|
|
|
// destroy doesn't exit yet
|
2011-08-21 03:09:37 +00:00
|
|
|
g_free(qf);
|
2009-11-11 16:36:51 +00:00
|
|
|
}
|
|
|
|
|
2012-01-10 19:10:45 +00:00
|
|
|
static void qfloat_destroy_test(void)
|
2009-11-11 16:36:51 +00:00
|
|
|
{
|
|
|
|
QFloat *qf = qfloat_from_double(0.0);
|
|
|
|
QDECREF(qf);
|
|
|
|
}
|
|
|
|
|
2012-01-10 19:10:45 +00:00
|
|
|
int main(int argc, char **argv)
|
2009-11-11 16:36:51 +00:00
|
|
|
{
|
2012-01-10 19:10:45 +00:00
|
|
|
g_test_init(&argc, &argv, NULL);
|
2009-11-11 16:36:51 +00:00
|
|
|
|
2012-01-10 19:10:45 +00:00
|
|
|
g_test_add_func("/public/from_double", qfloat_from_double_test);
|
|
|
|
g_test_add_func("/public/destroy", qfloat_destroy_test);
|
2009-11-11 16:36:51 +00:00
|
|
|
|
2012-01-10 19:10:45 +00:00
|
|
|
return g_test_run();
|
2009-11-11 16:36:51 +00:00
|
|
|
}
|