vga: fix typo in length passed to kvm_log_stop
[qemu/aliguori-queue.git] / check-qint.c
blob49887bb7d9c1b9514b30fe2a7787758e13b1d8d7
1 /*
2 * QInt unit-tests.
4 * Copyright (C) 2009 Red Hat Inc.
6 * Authors:
7 * Luiz Capitulino <lcapitulino@redhat.com>
8 */
9 #include <check.h>
11 #include "qint.h"
12 #include "qemu-common.h"
15 * Public Interface test-cases
17 * (with some violations to access 'private' data)
20 START_TEST(qint_from_int_test)
22 QInt *qi;
23 const int value = -42;
25 qi = qint_from_int(value);
26 fail_unless(qi != NULL);
27 fail_unless(qi->value == value);
28 fail_unless(qi->base.refcnt == 1);
29 fail_unless(qobject_type(QOBJECT(qi)) == QTYPE_QINT);
31 // destroy doesn't exit yet
32 qemu_free(qi);
34 END_TEST
36 START_TEST(qint_destroy_test)
38 QInt *qi = qint_from_int(0);
39 QDECREF(qi);
41 END_TEST
43 START_TEST(qint_from_int64_test)
45 QInt *qi;
46 const int64_t value = 0x1234567890abcdefLL;
48 qi = qint_from_int(value);
49 fail_unless((int64_t) qi->value == value);
51 QDECREF(qi);
53 END_TEST
55 START_TEST(qint_get_int_test)
57 QInt *qi;
58 const int value = 123456;
60 qi = qint_from_int(value);
61 fail_unless(qint_get_int(qi) == value);
63 QDECREF(qi);
65 END_TEST
67 START_TEST(qobject_to_qint_test)
69 QInt *qi;
71 qi = qint_from_int(0);
72 fail_unless(qobject_to_qint(QOBJECT(qi)) == qi);
74 QDECREF(qi);
76 END_TEST
78 static Suite *qint_suite(void)
80 Suite *s;
81 TCase *qint_public_tcase;
83 s = suite_create("QInt test-suite");
85 qint_public_tcase = tcase_create("Public Interface");
86 suite_add_tcase(s, qint_public_tcase);
87 tcase_add_test(qint_public_tcase, qint_from_int_test);
88 tcase_add_test(qint_public_tcase, qint_destroy_test);
89 tcase_add_test(qint_public_tcase, qint_from_int64_test);
90 tcase_add_test(qint_public_tcase, qint_get_int_test);
91 tcase_add_test(qint_public_tcase, qobject_to_qint_test);
93 return s;
96 int main(void)
98 int nf;
99 Suite *s;
100 SRunner *sr;
102 s = qint_suite();
103 sr = srunner_create(s);
105 srunner_run_all(sr, CK_NORMAL);
106 nf = srunner_ntests_failed(sr);
107 srunner_free(sr);
109 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;