Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 77 lines (62 sloc) 1.522 kB
68396ea @rmustacc Initial commit of d32e8d0b8d9e0ef7cf7ab2e74548982972789dfc from qemu-kvm
rmustacc authored
1 /*
2 * QFloat unit-tests.
3 *
4 * Copyright IBM, Corp. 2009
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
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 */
13 #include <check.h>
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
24 START_TEST(qfloat_from_double_test)
25 {
26 QFloat *qf;
27 const double value = -42.23423;
28
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);
34
35 // destroy doesn't exit yet
36 qemu_free(qf);
37 }
38 END_TEST
39
40 START_TEST(qfloat_destroy_test)
41 {
42 QFloat *qf = qfloat_from_double(0.0);
43 QDECREF(qf);
44 }
45 END_TEST
46
47 static Suite *qfloat_suite(void)
48 {
49 Suite *s;
50 TCase *qfloat_public_tcase;
51
52 s = suite_create("QFloat test-suite");
53
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);
58
59 return s;
60 }
61
62 int main(void)
63 {
64 int nf;
65 Suite *s;
66 SRunner *sr;
67
68 s = qfloat_suite();
69 sr = srunner_create(s);
70
71 srunner_run_all(sr, CK_NORMAL);
72 nf = srunner_ntests_failed(sr);
73 srunner_free(sr);
74
75 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
76 }
Something went wrong with that request. Please try again.