Debian Codegraph @

test/unit/types-by-name-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 <QtTest/QtTest>
22
23 #include "internal/types-by-name.h"
24
25 using namespace injeqt::internal;
26 using namespace injeqt::v1;
27
28 class type_1 : public QObject
29 {
30 Q_OBJECT
31 };
32
33 class type_2 : public QObject
34 {
35 Q_OBJECT
36 };
37
38 class type_3 : public QObject
39 {
40 Q_OBJECT
41 };
42
43 class types_by_name_test : public QObject
44 {
45 Q_OBJECT
46
47 public:
48 types_by_name_test();
49
50 private slots:
51 void should_return_empty_for_empty_name();
52 void should_return_empty_for_asterix();
53 void should_return_empty_for_type_name();
54 void should_return_valid_for_type_name_with_asterix();
55 void should_return_empty_for_unknown_type_name_with_asterix();
56
57 private:
58 types_by_name _known_types;
59
60 };
61
62 types_by_name_test::types_by_name_test() :
63 _known_types{
64 make_type<type_1>(),
65 make_type<type_2>()
66 }
67 {
68 }
69
70 void types_by_name_test::should_return_empty_for_empty_name()
71 {
72 auto t = type_by_pointer(_known_types, {});
73 QVERIFY(t.is_empty());
74 }
75
76 void types_by_name_test::should_return_empty_for_asterix()
77 {
78 auto t = type_by_pointer(_known_types, "*");
79 QVERIFY(t.is_empty());
80 }
81
82 void types_by_name_test::should_return_empty_for_type_name()
83 {
84 auto t = type_by_pointer(_known_types, "type_1");
85 QVERIFY(t.is_empty());
86 }
87
88 void types_by_name_test::should_return_valid_for_type_name_with_asterix()
89 {
90 auto t1 = type_by_pointer(_known_types, "type_1*");
91 QCOMPARE(make_type<type_1>(), t1);
92
93 auto t2 = type_by_pointer(_known_types, "type_2*");
94 QCOMPARE(make_type<type_2>(), t2);
95 }
96
97 void types_by_name_test::should_return_empty_for_unknown_type_name_with_asterix()
98 {
99 auto t = type_by_pointer(_known_types, "type_3*");
100 QVERIFY(t.is_empty());
101 }
102
103 QTEST_APPLESS_MAIN(types_by_name_test)
104 #include "types-by-name-test.moc"