Debian Codegraph @

test/unit/type-test.cpp

raw symbols SCIP
1 /*
2 * %injeqt copyright begin%
3 * Copyright 2014 Rafał Malinowski ([email protected])
4 * %injeqt copyright end%
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "expect.h"
22 #include "utils.h"
23
24 #include <injeqt/type.h>
25
26 #include <QtTest/QtTest>
27
28 using namespace injeqt::v1;
29
30 class type_test : public QObject
31 {
32 Q_OBJECT
33
34 private slots:
35 void should_return_empty_when_created_with_null_meta_object();
36 void should_return_qobject_when_created_with_qobject_meta_object();
37 void should_return_valid_meta_object();
38 void should_properly_compare();
39
40 };
41
42 class valid_type : public QObject
43 {
44 Q_OBJECT
45 };
46
47 class valid_type2 : public QObject
48 {
49 Q_OBJECT
50 };
51
52 void type_test::should_return_empty_when_created_with_null_meta_object()
53 {
54 auto t = type{nullptr};
55 QVERIFY(t.is_empty());
56 }
57
58 void type_test::should_return_qobject_when_created_with_qobject_meta_object()
59 {
60 auto t = make_type<QObject>();
61 QVERIFY(!t.is_empty());
62 QVERIFY(t.is_qobject());
63 }
64
65 void type_test::should_return_valid_meta_object()
66 {
67 auto t = make_type<valid_type>();
68
69 QCOMPARE(t.meta_object(), &valid_type::staticMetaObject);
70 }
71
72 void type_test::should_properly_compare()
73 {
74 auto t1a = type{};
75 auto t1b = type{};
76 auto t2a = make_type<QObject>();
77 auto t2b = make_type<QObject>();
78 auto t3a = make_type<valid_type>();
79 auto t3b = make_type<valid_type>();
80 auto t4a = make_type<valid_type2>();
81 auto t4b = make_type<valid_type2>();
82
83 test_compare_ex<type>({{t1a, t1b}, {t2a, t2b}, {t3a, t3b}, {t4a, t4b}});
84 }
85
86 QTEST_APPLESS_MAIN(type_test)
87 #include "type-test.moc"