]> Git Repo - qemu.git/blame - tests/check-qfloat.c
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
[qemu.git] / tests / check-qfloat.c
CommitLineData
9c9efb6b
AL
1/*
2 * QFloat unit-tests.
3 *
9c9efb6b
AL
4 * Copyright IBM, Corp. 2009
5 *
6 * Authors:
7 * Anthony Liguori <[email protected]>
8 *
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
11 *
12 */
681c28a3 13#include "qemu/osdep.h"
a9e1c28d 14#include <glib.h>
9c9efb6b 15
7b1b5d19 16#include "qapi/qmp/qfloat.h"
9c9efb6b
AL
17#include "qemu-common.h"
18
19/*
20 * Public Interface test-cases
21 *
22 * (with some violations to access 'private' data)
23 */
24
a9e1c28d 25static void qfloat_from_double_test(void)
9c9efb6b
AL
26{
27 QFloat *qf;
28 const double value = -42.23423;
29
30 qf = qfloat_from_double(value);
a9e1c28d
AL
31 g_assert(qf != NULL);
32 g_assert(qf->value == value);
33 g_assert(qf->base.refcnt == 1);
34 g_assert(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
9c9efb6b
AL
35
36 // destroy doesn't exit yet
7267c094 37 g_free(qf);
9c9efb6b 38}
9c9efb6b 39
a9e1c28d 40static void qfloat_destroy_test(void)
9c9efb6b
AL
41{
42 QFloat *qf = qfloat_from_double(0.0);
43 QDECREF(qf);
44}
9c9efb6b 45
a9e1c28d 46int main(int argc, char **argv)
9c9efb6b 47{
a9e1c28d 48 g_test_init(&argc, &argv, NULL);
9c9efb6b 49
a9e1c28d
AL
50 g_test_add_func("/public/from_double", qfloat_from_double_test);
51 g_test_add_func("/public/destroy", qfloat_destroy_test);
9c9efb6b 52
a9e1c28d 53 return g_test_run();
9c9efb6b 54}
This page took 0.413818 seconds and 4 git commands to generate.