]>
Commit | Line | Data |
---|---|---|
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 | */ | |
a9e1c28d | 13 | #include <glib.h> |
9c9efb6b AL |
14 | |
15 | #include "qfloat.h" | |
16 | #include "qemu-common.h" | |
17 | ||
18 | /* | |
19 | * Public Interface test-cases | |
20 | * | |
21 | * (with some violations to access 'private' data) | |
22 | */ | |
23 | ||
a9e1c28d | 24 | static void qfloat_from_double_test(void) |
9c9efb6b AL |
25 | { |
26 | QFloat *qf; | |
27 | const double value = -42.23423; | |
28 | ||
29 | qf = qfloat_from_double(value); | |
a9e1c28d AL |
30 | g_assert(qf != NULL); |
31 | g_assert(qf->value == value); | |
32 | g_assert(qf->base.refcnt == 1); | |
33 | g_assert(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT); | |
9c9efb6b AL |
34 | |
35 | // destroy doesn't exit yet | |
7267c094 | 36 | g_free(qf); |
9c9efb6b | 37 | } |
9c9efb6b | 38 | |
a9e1c28d | 39 | static void qfloat_destroy_test(void) |
9c9efb6b AL |
40 | { |
41 | QFloat *qf = qfloat_from_double(0.0); | |
42 | QDECREF(qf); | |
43 | } | |
9c9efb6b | 44 | |
a9e1c28d | 45 | int main(int argc, char **argv) |
9c9efb6b | 46 | { |
a9e1c28d | 47 | g_test_init(&argc, &argv, NULL); |
9c9efb6b | 48 | |
a9e1c28d AL |
49 | g_test_add_func("/public/from_double", qfloat_from_double_test); |
50 | g_test_add_func("/public/destroy", qfloat_destroy_test); | |
9c9efb6b | 51 | |
a9e1c28d | 52 | return g_test_run(); |
9c9efb6b | 53 | } |