Debian Codegraph @

test/integration/get-all-with-type-role-test.cpp

raw symbols SCIP
1 /*
2 * %injeqt copyright begin%
3 * Copyright 2016 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 <injeqt/injector.h>cxx . . $ `<file>/include/injeqt/injector.h`/
22 #include <injeqt/module.h>cxx . . $ `<file>/include/injeqt/module.h`/
23 #include <injeqt/type.h>cxx . . $ `<file>/include/injeqt/type.h`/
24
25 #include <QtTest/QtTest>
26 #include <set>
27
28 using injeqtcxx . . $ injeqt/::make_typecxx . . $ make_type(10a1ed948a80d481).;
29 using injeqtcxx . . $ injeqt/::typecxx . . $ type#;
30
31 #define ROLE_1cxx . . $ `test/integration/get-all-with-type-role-test.cpp:31:9`! "role1"
32 #define ROLE_2cxx . . $ `test/integration/get-all-with-type-role-test.cpp:32:9`! "role2"
33
34 class role_1_type_1cxx . . $ role_1_type_1# : public QObjectcxx . . $ QObject#
35 {
36 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
37 INJEQT_TYPE_ROLEcxx . . $ `include/injeqt/injeqt.h:40:9`!(ROLE_1cxx . . $ `test/integration/get-all-with-type-role-test.cpp:31:9`!)
38
39 public:
40 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! role_1_type_1cxx . . $ role_1_type_1#role_1_type_1(49f6e7a06ebc5aa8).() { }
41 };
42
43 class role_1_type_2cxx . . $ role_1_type_2# : public QObjectcxx . . $ QObject#
44 {
45 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
46 INJEQT_TYPE_ROLEcxx . . $ `include/injeqt/injeqt.h:40:9`!(ROLE_1cxx . . $ `test/integration/get-all-with-type-role-test.cpp:31:9`!)
47
48 public:
49 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! role_1_type_2cxx . . $ role_1_type_2#role_1_type_2(49f6e7a06ebc5aa8).() { }
50 };
51
52 class role_2_type_1cxx . . $ role_2_type_1# : public QObjectcxx . . $ QObject#
53 {
54 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
55 INJEQT_TYPE_ROLEcxx . . $ `include/injeqt/injeqt.h:40:9`!(ROLE_2cxx . . $ `test/integration/get-all-with-type-role-test.cpp:32:9`!)
56
57 public:
58 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! role_2_type_1cxx . . $ role_2_type_1#role_2_type_1(49f6e7a06ebc5aa8).() { }
59 };
60
61 class role_2_type_2cxx . . $ role_2_type_2# : public QObjectcxx . . $ QObject#
62 {
63 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
64 INJEQT_TYPE_ROLEcxx . . $ `include/injeqt/injeqt.h:40:9`!(ROLE_2cxx . . $ `test/integration/get-all-with-type-role-test.cpp:32:9`!)
65
66 public:
67 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! role_2_type_2cxx . . $ role_2_type_2#role_2_type_2(49f6e7a06ebc5aa8).() { }
68 };
69
70 class get_all_with_type_role_testcxx . . $ get_all_with_type_role_test# : public QObjectcxx . . $ QObject#
71 {
72 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
73
74 private:
75 injeqtcxx . . $ injeqt/::injectorcxx . . $ injeqt/v1/injector# create_injectorcxx . . $ get_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).();
76
77 private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!:
78 void should_return_all_role_instancescxx . . $ get_all_with_type_role_test#should_return_all_role_instances(49f6e7a06ebc5aa8).();
79
80 };
81
82 injeqtcxx . . $ injeqt/::injectorcxx . . $ injeqt/v1/injector# get_all_with_type_role_testcxx . . $ get_all_with_type_role_test#::create_injectorcxx . . $ get_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).()
83 {
84 class mcxx . . $ get_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m# : public injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module#
85 {
86 public:
87 mcxx . . $ get_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m#m(49f6e7a06ebc5aa8).()
88 {
89 add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<role_1_type_1cxx . . $ role_1_type_1#>();
90 add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<role_1_type_2cxx . . $ role_1_type_2#>();
91 add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<role_2_type_1cxx . . $ role_2_type_1#>();
92 add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<role_2_type_2cxx . . $ role_2_type_2#>();
93 }
94 virtual ~cxx . . $ get_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m#`~m`(49f6e7a06ebc5aa8).mcxx . . $ get_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m#() {}
95 };
96
97 auto modules = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module#>>{};
98 modules.emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(stdcxx . . $ std/unique_ptr#unique_ptr(57bc6b0441bf5294).::unique_ptrcxx . . $ std/unique_ptr#<mcxx . . $ get_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m#>{new mcxx . . $ get_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m#{}});
99 return injeqtcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).::injectorcxx . . $ injeqt/v1/injector#{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::movecxx . . $ std/move(e7c6c0c8363dcc46).(modules)};
100 }
101
102 void get_all_with_type_role_testcxx . . $ get_all_with_type_role_test#::should_return_all_role_instancescxx . . $ get_all_with_type_role_test#should_return_all_role_instances(49f6e7a06ebc5aa8).()
103 {
104 auto injector = create_injectorcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).();
105 auto role_1_objects = injectorcxx . . $ std/vector#vector(b1ea180184b47f03)..get_all_with_type_rolecxx . . $ injeqt/v1/injector#get_all_with_type_role(60702980c580d8f6).(ROLE_1cxx . . $ `test/integration/get-all-with-type-role-test.cpp:31:9`!);
106 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(role_1_objects.size(), size_t{2});
107 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(std::any_of(std::begin(role_1_objects), std::end(role_1_objects), [](QObject *o){
108 return !!qobject_cast<role_1_type_1 *>(o);
109 }));
110 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(std::any_of(std::begin(role_1_objects), std::end(role_1_objects), [](QObject *o){
111 return !!qobject_cast<role_1_type_2 *>(o);
112 }));
113
114 auto role_2_object = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<role_2_type_1cxx . . $ role_2_type_1#>();
115 auto role_2_objects = injectorcxx . . $ std/vector#vector(b1ea180184b47f03)..get_all_with_type_rolecxx . . $ injeqt/v1/injector#get_all_with_type_role(60702980c580d8f6).(ROLE_2cxx . . $ `test/integration/get-all-with-type-role-test.cpp:32:9`!);
116 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(role_2_objects.size(), size_t{2});
117 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(std::any_of(std::begin(role_2_objects), std::end(role_2_objects), [](QObject *o){
118 return !!qobject_cast<role_2_type_1 *>(o);
119 }));
120 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(std::any_of(std::begin(role_2_objects), std::end(role_2_objects), [](QObject *o){
121 return !!qobject_cast<role_2_type_2 *>(o);
122 }));
123 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(std::any_of(std::begin(role_2_objects), std::end(role_2_objects), [role_2_object](QObject *o){
124 return o == role_2_object;
125 }));
126 }
127
128 QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(get_all_with_type_role_test)
129 #include "get-all-with-type-role-test.moc"cxx . . $ `<file>/build/test/get-all-with-type-role-test_autogen/include/get-all-with-type-role-test.moc`/