ditto hw/xilinx_uartlite.c
[qemu/aliguori.git] / check-qfloat.c
blobb71d9834f09f1836e0a86ed34ae3c6e3d0a51c1c
1 /*
2 * QFloat unit-tests.
4 * Copyright IBM, Corp. 2009
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
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.
13 #include <check.h>
15 #include "qfloat.h"
16 #include "qemu-common.h"
19 * Public Interface test-cases
21 * (with some violations to access 'private' data)
24 START_TEST(qfloat_from_double_test)
26 QFloat *qf;
27 const double value = -42.23423;
29 qf = qfloat_from_double(value);
30 fail_unless(qf != NULL);
31 fail_unless(qf->value == value);
32 fail_unless(qf->base.refcnt == 1);
33 fail_unless(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
35 // destroy doesn't exit yet
36 qemu_free(qf);
38 END_TEST
40 START_TEST(qfloat_destroy_test)
42 QFloat *qf = qfloat_from_double(0.0);
43 QDECREF(qf);
45 END_TEST
47 static Suite *qfloat_suite(void)
49 Suite *s;
50 TCase *qfloat_public_tcase;
52 s = suite_create("QFloat test-suite");
54 qfloat_public_tcase = tcase_create("Public Interface");
55 suite_add_tcase(s, qfloat_public_tcase);
56 tcase_add_test(qfloat_public_tcase, qfloat_from_double_test);
57 tcase_add_test(qfloat_public_tcase, qfloat_destroy_test);
59 return s;
62 int main(void)
64 int nf;
65 Suite *s;
66 SRunner *sr;
68 s = qfloat_suite();
69 sr = srunner_create(s);
71 srunner_run_all(sr, CK_NORMAL);
72 nf = srunner_ntests_failed(sr);
73 srunner_free(sr);
75 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;