Debian Codegraph @

test/unit/type-dependencies-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/dependency.h"
25 #include "internal/type-dependencies.h"
26
27 #include <QtTest/QtTest>
28 #include <string>
29
30 using namespace injeqt::internal;
31 using namespace injeqt::v1;
32
33 class type_1 : public QObject
34 {
35 Q_OBJECT
36 };
37
38 class type_2 : public QObject
39 {
40 Q_OBJECT
41 };
42
43 class type_with_dependency_1 : public QObject
44 {
45 Q_OBJECT
46
47 public slots:
48 INJEQT_SET void setter_1(type_1 *) { }
49 INJEQT_SET void setter_2(type_2 *) { }
50
51 };
52
53 class type_with_dependency_2 : public QObject
54 {
55 Q_OBJECT
56
57 public slots:
58 INJEQT_SET void setter_1(type_1 *) { }
59 INJEQT_SET void setter_2(type_2 *) { }
60
61 };
62
63 class type_dependencies_test : public QObject
64 {
65 Q_OBJECT
66
67 private slots:
68 void should_properly_compare();
69
70 };
71
72 void type_dependencies_test::should_properly_compare()
73 {
74 auto d11 = dependency{make_test_setter_method<type_with_dependency_1, type_1>("setter_1(type_1*)")};
75 auto d12 = dependency{make_test_setter_method<type_with_dependency_1, type_2>("setter_2(type_2*)")};
76 auto d21 = dependency{make_test_setter_method<type_with_dependency_2, type_1>("setter_1(type_1*)")};
77 auto d22 = dependency{make_test_setter_method<type_with_dependency_2, type_2>("setter_2(type_2*)")};
78
79 auto td_empty = type_dependencies{type{}, dependencies{}};
80 auto td1a = type_dependencies{make_type<type_1>(), dependencies{d11, d12}};
81 auto td1b = type_dependencies{make_type<type_1>(), dependencies{d11, d12}};
82 auto td2a = type_dependencies{make_type<type_1>(), dependencies{}};
83 auto td2b = type_dependencies{make_type<type_1>(), dependencies{}};
84 auto td3a = type_dependencies{make_type<type_2>(), dependencies{d21, d22}};
85 auto td3b = type_dependencies{make_type<type_2>(), dependencies{d21, d22}};
86
87 test_compare<type_dependencies>({{td_empty}, {td1a, td1b}, {td2a, td2b}, {td3a, td3b}});
88 }
89
90 QTEST_APPLESS_MAIN(type_dependencies_test)
91 #include "type-dependencies-test.moc"