aboutsummaryrefslogtreecommitdiff
path: root/check-qint.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-01-10 13:10:46 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2012-01-12 10:05:37 -0600
commit65cdadd2e2de76f7db3bf6b7d8dd8c67abff9659 (patch)
tree16ca5515100338fc83ba321452ebea8e4d30bab8 /check-qint.c
parenta9e1c28ddaae5a48415fec1f336b5560eb85d3e1 (diff)
check-qint: convert to gtest
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'check-qint.c')
-rw-r--r--check-qint.c68
1 files changed, 21 insertions, 47 deletions
diff --git a/check-qint.c b/check-qint.c
index 3af51f20c8..5a27119ae2 100644
--- a/check-qint.c
+++ b/check-qint.c
@@ -9,7 +9,7 @@
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
* See the COPYING.LIB file in the top-level directory.
*/
-#include <check.h>
+#include <glib.h>
#include "qint.h"
#include "qemu-common.h"
@@ -20,94 +20,68 @@
* (with some violations to access 'private' data)
*/
-START_TEST(qint_from_int_test)
+static void qint_from_int_test(void)
{
QInt *qi;
const int value = -42;
qi = qint_from_int(value);
- fail_unless(qi != NULL);
- fail_unless(qi->value == value);
- fail_unless(qi->base.refcnt == 1);
- fail_unless(qobject_type(QOBJECT(qi)) == QTYPE_QINT);
+ g_assert(qi != NULL);
+ g_assert(qi->value == value);
+ g_assert(qi->base.refcnt == 1);
+ g_assert(qobject_type(QOBJECT(qi)) == QTYPE_QINT);
// destroy doesn't exit yet
g_free(qi);
}
-END_TEST
-START_TEST(qint_destroy_test)
+static void qint_destroy_test(void)
{
QInt *qi = qint_from_int(0);
QDECREF(qi);
}
-END_TEST
-START_TEST(qint_from_int64_test)
+static void qint_from_int64_test(void)
{
QInt *qi;
const int64_t value = 0x1234567890abcdefLL;
qi = qint_from_int(value);
- fail_unless((int64_t) qi->value == value);
+ g_assert((int64_t) qi->value == value);
QDECREF(qi);
}
-END_TEST
-START_TEST(qint_get_int_test)
+static void qint_get_int_test(void)
{
QInt *qi;
const int value = 123456;
qi = qint_from_int(value);
- fail_unless(qint_get_int(qi) == value);
+ g_assert(qint_get_int(qi) == value);
QDECREF(qi);
}
-END_TEST
-START_TEST(qobject_to_qint_test)
+static void qobject_to_qint_test(void)
{
QInt *qi;
qi = qint_from_int(0);
- fail_unless(qobject_to_qint(QOBJECT(qi)) == qi);
+ g_assert(qobject_to_qint(QOBJECT(qi)) == qi);
QDECREF(qi);
}
-END_TEST
-static Suite *qint_suite(void)
+int main(int argc, char **argv)
{
- Suite *s;
- TCase *qint_public_tcase;
+ g_test_init(&argc, &argv, NULL);
- s = suite_create("QInt test-suite");
+ g_test_add_func("/public/from_int", qint_from_int_test);
+ g_test_add_func("/public/destroy", qint_destroy_test);
+ g_test_add_func("/public/from_int64", qint_from_int64_test);
+ g_test_add_func("/public/get_int", qint_get_int_test);
+ g_test_add_func("/public/to_qint", qobject_to_qint_test);
- qint_public_tcase = tcase_create("Public Interface");
- suite_add_tcase(s, qint_public_tcase);
- tcase_add_test(qint_public_tcase, qint_from_int_test);
- tcase_add_test(qint_public_tcase, qint_destroy_test);
- tcase_add_test(qint_public_tcase, qint_from_int64_test);
- tcase_add_test(qint_public_tcase, qint_get_int_test);
- tcase_add_test(qint_public_tcase, qobject_to_qint_test);
-
- return s;
-}
-
-int main(void)
-{
- int nf;
- Suite *s;
- SRunner *sr;
-
- s = qint_suite();
- sr = srunner_create(s);
-
- srunner_run_all(sr, CK_NORMAL);
- nf = srunner_ntests_failed(sr);
- srunner_free(sr);
-
- return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+ return g_test_run();
}