Debian Codegraph @

test/unit/implemented-by-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 "internal/implemented-by.h"
25
26 #include <QtTest/QtTest>
27
28 using namespace injeqt::internal;
29 using namespace injeqt::v1;
30
31 class type_1 : public QObject
32 {
33 Q_OBJECT
34 };
35
36 class type_2 : public QObject
37 {
38 Q_OBJECT
39 };
40
41 class type_1_subtype_1 : public type_1
42 {
43 Q_OBJECT
44 };
45
46 class type_1_subtype_1_subtype_1 : public type_1_subtype_1
47 {
48 Q_OBJECT
49 };
50
51 class implemented_by_test : public QObject
52 {
53 Q_OBJECT
54
55 private slots:
56 void should_accept_implemented_by_self();
57 void should_accept_implemented_by_subtype();
58 void should_properly_compare();
59
60 };
61
62 void implemented_by_test::should_accept_implemented_by_self()
63 {
64 auto i = implemented_by{make_type<type_1>(), make_type<type_1>()};
65
66 QCOMPARE(make_type<type_1>(), i.interface_type());
67 QCOMPARE(make_type<type_1>(), i.implementation_type());
68 }
69
70 void implemented_by_test::should_accept_implemented_by_subtype()
71 {
72 auto i = implemented_by{make_type<type_1>(), make_type<type_1_subtype_1_subtype_1>()};
73
74 QCOMPARE(make_type<type_1>(), i.interface_type());
75 QCOMPARE(make_type<type_1_subtype_1_subtype_1>(), i.implementation_type());
76 }
77
78 void implemented_by_test::should_properly_compare()
79 {
80 auto ib1a = implemented_by{make_type<type_1>(), make_type<type_1_subtype_1>()};
81 auto ib1b = implemented_by{make_type<type_1>(), make_type<type_1_subtype_1>()};
82 auto ib2a = implemented_by{make_type<type_1>(), make_type<type_1_subtype_1_subtype_1>()};
83 auto ib2b = implemented_by{make_type<type_1>(), make_type<type_1_subtype_1_subtype_1>()};
84 auto ib3a = implemented_by{make_type<type_1_subtype_1>(), make_type<type_1_subtype_1_subtype_1>()};
85 auto ib3b = implemented_by{make_type<type_1_subtype_1>(), make_type<type_1_subtype_1_subtype_1>()};
86
87 test_compare<implemented_by>({{ib1a, ib1b}, {ib2a, ib2b}, {ib3a, ib3b}});
88 }
89
90 QTEST_APPLESS_MAIN(implemented_by_test)
91 #include "implemented-by-test.moc"