Replace expose-event handler with draw handler in GTK3
[qemu/pbrook.git] / tests / check-qint.c
blob86868844abbfd2ef333d80a8301d46a9f84130de
1 /*
2 * QInt unit-tests.
4 * Copyright (C) 2009 Red Hat Inc.
6 * Authors:
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 <glib.h>
14 #include "qapi/qmp/qint.h"
15 #include "qemu-common.h"
18 * Public Interface test-cases
20 * (with some violations to access 'private' data)
23 static void qint_from_int_test(void)
25 QInt *qi;
26 const int value = -42;
28 qi = qint_from_int(value);
29 g_assert(qi != NULL);
30 g_assert(qi->value == value);
31 g_assert(qi->base.refcnt == 1);
32 g_assert(qobject_type(QOBJECT(qi)) == QTYPE_QINT);
34 // destroy doesn't exit yet
35 g_free(qi);
38 static void qint_destroy_test(void)
40 QInt *qi = qint_from_int(0);
41 QDECREF(qi);
44 static void qint_from_int64_test(void)
46 QInt *qi;
47 const int64_t value = 0x1234567890abcdefLL;
49 qi = qint_from_int(value);
50 g_assert((int64_t) qi->value == value);
52 QDECREF(qi);
55 static void qint_get_int_test(void)
57 QInt *qi;
58 const int value = 123456;
60 qi = qint_from_int(value);
61 g_assert(qint_get_int(qi) == value);
63 QDECREF(qi);
66 static void qobject_to_qint_test(void)
68 QInt *qi;
70 qi = qint_from_int(0);
71 g_assert(qobject_to_qint(QOBJECT(qi)) == qi);
73 QDECREF(qi);
76 int main(int argc, char **argv)
78 g_test_init(&argc, &argv, NULL);
80 g_test_add_func("/public/from_int", qint_from_int_test);
81 g_test_add_func("/public/destroy", qint_destroy_test);
82 g_test_add_func("/public/from_int64", qint_from_int64_test);
83 g_test_add_func("/public/get_int", qint_get_int_test);
84 g_test_add_func("/public/to_qint", qobject_to_qint_test);
86 return g_test_run();