4
* Copyright (C) 2009 Red Hat Inc.
7
* Luiz Capitulino <lcapitulino@redhat.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.
15
#include "qemu-common.h"
18
* Public Interface test-cases
20
* (with some violations to access 'private' data)
23
START_TEST(qint_from_int_test)
26
const int value = -42;
28
qi = qint_from_int(value);
29
fail_unless(qi != NULL);
30
fail_unless(qi->value == value);
31
fail_unless(qi->base.refcnt == 1);
32
fail_unless(qobject_type(QOBJECT(qi)) == QTYPE_QINT);
34
// destroy doesn't exit yet
39
START_TEST(qint_destroy_test)
41
QInt *qi = qint_from_int(0);
46
START_TEST(qint_from_int64_test)
49
const int64_t value = 0x1234567890abcdefLL;
51
qi = qint_from_int(value);
52
fail_unless((int64_t) qi->value == value);
58
START_TEST(qint_get_int_test)
61
const int value = 123456;
63
qi = qint_from_int(value);
64
fail_unless(qint_get_int(qi) == value);
70
START_TEST(qobject_to_qint_test)
74
qi = qint_from_int(0);
75
fail_unless(qobject_to_qint(QOBJECT(qi)) == qi);
81
static Suite *qint_suite(void)
84
TCase *qint_public_tcase;
86
s = suite_create("QInt test-suite");
88
qint_public_tcase = tcase_create("Public Interface");
89
suite_add_tcase(s, qint_public_tcase);
90
tcase_add_test(qint_public_tcase, qint_from_int_test);
91
tcase_add_test(qint_public_tcase, qint_destroy_test);
92
tcase_add_test(qint_public_tcase, qint_from_int64_test);
93
tcase_add_test(qint_public_tcase, qint_get_int_test);
94
tcase_add_test(qint_public_tcase, qobject_to_qint_test);
106
sr = srunner_create(s);
108
srunner_run_all(sr, CK_NORMAL);
109
nf = srunner_ntests_failed(sr);
112
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;