check-qfloat: convert to gtest
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
ac531cb6e5
commit
a9e1c28dda
@ -10,7 +10,7 @@
|
|||||||
* See the COPYING.LIB file in the top-level directory.
|
* See the COPYING.LIB file in the top-level directory.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <check.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "qfloat.h"
|
#include "qfloat.h"
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
@ -21,56 +21,33 @@
|
|||||||
* (with some violations to access 'private' data)
|
* (with some violations to access 'private' data)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
START_TEST(qfloat_from_double_test)
|
static void qfloat_from_double_test(void)
|
||||||
{
|
{
|
||||||
QFloat *qf;
|
QFloat *qf;
|
||||||
const double value = -42.23423;
|
const double value = -42.23423;
|
||||||
|
|
||||||
qf = qfloat_from_double(value);
|
qf = qfloat_from_double(value);
|
||||||
fail_unless(qf != NULL);
|
g_assert(qf != NULL);
|
||||||
fail_unless(qf->value == value);
|
g_assert(qf->value == value);
|
||||||
fail_unless(qf->base.refcnt == 1);
|
g_assert(qf->base.refcnt == 1);
|
||||||
fail_unless(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
|
g_assert(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
|
||||||
|
|
||||||
// destroy doesn't exit yet
|
// destroy doesn't exit yet
|
||||||
g_free(qf);
|
g_free(qf);
|
||||||
}
|
}
|
||||||
END_TEST
|
|
||||||
|
|
||||||
START_TEST(qfloat_destroy_test)
|
static void qfloat_destroy_test(void)
|
||||||
{
|
{
|
||||||
QFloat *qf = qfloat_from_double(0.0);
|
QFloat *qf = qfloat_from_double(0.0);
|
||||||
QDECREF(qf);
|
QDECREF(qf);
|
||||||
}
|
}
|
||||||
END_TEST
|
|
||||||
|
|
||||||
static Suite *qfloat_suite(void)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Suite *s;
|
g_test_init(&argc, &argv, NULL);
|
||||||
TCase *qfloat_public_tcase;
|
|
||||||
|
|
||||||
s = suite_create("QFloat test-suite");
|
g_test_add_func("/public/from_double", qfloat_from_double_test);
|
||||||
|
g_test_add_func("/public/destroy", qfloat_destroy_test);
|
||||||
|
|
||||||
qfloat_public_tcase = tcase_create("Public Interface");
|
return g_test_run();
|
||||||
suite_add_tcase(s, qfloat_public_tcase);
|
|
||||||
tcase_add_test(qfloat_public_tcase, qfloat_from_double_test);
|
|
||||||
tcase_add_test(qfloat_public_tcase, qfloat_destroy_test);
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int nf;
|
|
||||||
Suite *s;
|
|
||||||
SRunner *sr;
|
|
||||||
|
|
||||||
s = qfloat_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;
|
|
||||||
}
|
}
|
||||||
|
4
configure
vendored
4
configure
vendored
@ -2801,9 +2801,9 @@ if test "$softmmu" = yes ; then
|
|||||||
fi
|
fi
|
||||||
if [ "$check_utests" = "yes" ]; then
|
if [ "$check_utests" = "yes" ]; then
|
||||||
checks="check-qint check-qstring check-qlist"
|
checks="check-qint check-qstring check-qlist"
|
||||||
checks="check-qfloat check-qjson $checks"
|
checks="check-qjson $checks"
|
||||||
fi
|
fi
|
||||||
test_progs="$checks check-qdict test-coroutine test-qmp-output-visitor test-qmp-input-visitor"
|
test_progs="$checks check-qdict check-qfloat test-coroutine test-qmp-output-visitor test-qmp-input-visitor"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user