4 * Copyright (C) 2009 Red Hat Inc.
7 * Luiz Capitulino <lcapitulino@redhat.com>
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
)
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
36 START_TEST(qint_destroy_test
)
38 QInt
*qi
= qint_from_int(0);
43 START_TEST(qint_from_int64_test
)
46 const int64_t value
= 0xffffffffffffffff;
48 qi
= qint_from_int(value
);
49 fail_unless(qi
->value
== value
);
55 START_TEST(qint_get_int_test
)
58 const int value
= 123456;
60 qi
= qint_from_int(value
);
61 fail_unless(qint_get_int(qi
) == value
);
67 START_TEST(qobject_to_qint_test
)
71 qi
= qint_from_int(0);
72 fail_unless(qobject_to_qint(QOBJECT(qi
)) == qi
);
78 static Suite
*qint_suite(void)
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
);
103 sr
= srunner_create(s
);
105 srunner_run_all(sr
, CK_NORMAL
);
106 nf
= srunner_ntests_failed(sr
);
109 return (nf
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;