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.
12 #include "qemu/osdep.h"
15 #include "qapi/qmp/qint.h"
16 #include "qemu-common.h"
19 * Public Interface test-cases
21 * (with some violations to access 'private' data)
24 static void qint_from_int_test(void)
27 const int value
= -42;
29 qi
= qint_from_int(value
);
31 g_assert(qi
->value
== value
);
32 g_assert(qi
->base
.refcnt
== 1);
33 g_assert(qobject_type(QOBJECT(qi
)) == QTYPE_QINT
);
35 // destroy doesn't exit yet
39 static void qint_destroy_test(void)
41 QInt
*qi
= qint_from_int(0);
45 static void qint_from_int64_test(void)
48 const int64_t value
= 0x1234567890abcdefLL
;
50 qi
= qint_from_int(value
);
51 g_assert((int64_t) qi
->value
== value
);
56 static void qint_get_int_test(void)
59 const int value
= 123456;
61 qi
= qint_from_int(value
);
62 g_assert(qint_get_int(qi
) == value
);
67 static void qobject_to_qint_test(void)
71 qi
= qint_from_int(0);
72 g_assert(qobject_to_qint(QOBJECT(qi
)) == qi
);
77 int main(int argc
, char **argv
)
79 g_test_init(&argc
, &argv
, NULL
);
81 g_test_add_func("/public/from_int", qint_from_int_test
);
82 g_test_add_func("/public/destroy", qint_destroy_test
);
83 g_test_add_func("/public/from_int64", qint_from_int64_test
);
84 g_test_add_func("/public/get_int", qint_get_int_test
);
85 g_test_add_func("/public/to_qint", qobject_to_qint_test
);