Debian Codegraph @

test/unit/provider-by-factory-configuration-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"cxx . . $ `<file>/test/unit/expect.h`/
22
23 #include <injeqt/exception/qobject-type.h>cxx . . $ `<file>/include/injeqt/exception/qobject-type.h`/
24 #include <injeqt/exception/unique-factory-method-not-found.h>cxx . . $ `<file>/include/injeqt/exception/unique-factory-method-not-found.h`/
25
26 #include "internal/provider-by-factory-configuration.h"cxx . . $ `<file>/src/internal/provider-by-factory-configuration.h`/
27 #include "internal/provider.h"cxx . . $ `<file>/src/internal/provider.h`/
28 #include "internal/types.h"cxx . . $ `<file>/src/internal/types.h`/
29
30 #include <QtTest/QtTest>
31 #include <memory>
32
33 using namespace injeqtcxx . . $ injeqt/::v1;
34 using namespace injeqtcxx . . $ injeqt/::internal;
35
36 class type_1cxx . . $ type_1# : public QObjectcxx . . $ QObject#
37 {
38 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
39 };
40
41 class type_2cxx . . $ type_2# : public QObjectcxx . . $ QObject#
42 {
43 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
44 };
45
46 class type_1_subtype_1cxx . . $ type_1_subtype_1# : public type_1cxx . . $ type_1#
47 {
48 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
49 };
50
51 class factory_typecxx . . $ factory_type# : public QObjectcxx . . $ QObject#
52 {
53 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
54 public:
55 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! type_1cxx . . $ type_1# * createcxx . . $ factory_type#create(dbbfb158899b29b1).() { return new type_1cxx . . $ type_1#{}; }
56 };
57
58 class subtype_factory_typecxx . . $ subtype_factory_type# : public QObjectcxx . . $ QObject#
59 {
60 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
61 public:
62 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! type_1_subtype_1cxx . . $ type_1_subtype_1# * createcxx . . $ subtype_factory_type#create(12fd129f4bd5f042).() { return new type_1_subtype_1cxx . . $ type_1_subtype_1#{}; }
63 };
64
65 class non_unique_factory_typecxx . . $ non_unique_factory_type# : public QObjectcxx . . $ QObject#
66 {
67 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
68 public:
69 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! type_1cxx . . $ type_1# * createcxx . . $ non_unique_factory_type#create(dbbfb158899b29b1).() { return nullptr; }
70 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! type_1cxx . . $ type_1# * create2cxx . . $ non_unique_factory_type#create2(dbbfb158899b29b1).() { return nullptr; }
71 };
72
73 class provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test# : public QObjectcxx . . $ QObject#
74 {
75 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
76
77 public:
78 provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test#provider_by_factory_configuration_test(49f6e7a06ebc5aa8).();
79
80 private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!:
81 void should_accept_qobject_object_type_and_throw_on_createcxx . . $ provider_by_factory_configuration_test#should_accept_qobject_object_type_and_throw_on_create(49f6e7a06ebc5aa8).();
82 void should_accept_qobject_factory_type_and_throw_on_createcxx . . $ provider_by_factory_configuration_test#should_accept_qobject_factory_type_and_throw_on_create(49f6e7a06ebc5aa8).();
83 void should_accept_factory_without_factory_method_and_throw_on_createcxx . . $ provider_by_factory_configuration_test#should_accept_factory_without_factory_method_and_throw_on_create(49f6e7a06ebc5aa8).();
84 void should_accept_factory_without_unique_factory_method_and_throw_on_createcxx . . $ provider_by_factory_configuration_test#should_accept_factory_without_unique_factory_method_and_throw_on_create(49f6e7a06ebc5aa8).();
85 void should_accept_supertype_factory_and_throw_on_createcxx . . $ provider_by_factory_configuration_test#should_accept_supertype_factory_and_throw_on_create(49f6e7a06ebc5aa8).();
86 void should_accept_valid_configurationcxx . . $ provider_by_factory_configuration_test#should_accept_valid_configuration(49f6e7a06ebc5aa8).();
87 void should_accept_subtype_configurationcxx . . $ provider_by_factory_configuration_test#should_accept_subtype_configuration(49f6e7a06ebc5aa8).();
88
89 private:
90 types_by_namecxx . . $ injeqt/internal/types_by_name# known_typescxx . . $ provider_by_factory_configuration_test#known_types.;
91
92 };
93
94 provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test#::provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test#provider_by_factory_configuration_test(49f6e7a06ebc5aa8).()
95 {
96 known_typescxx . . $ provider_by_factory_configuration_test#known_types. =cxx . . $ injeqt/internal/sorted_unique_vector#`operator=`(21c4a51877e06114). types_by_namecxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(26e8deb829554aa).{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{
97 make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(),
98 make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_1cxx . . $ type_1_subtype_1#>(),
99 make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_2cxx . . $ type_2#>(),
100 make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<factory_typecxx . . $ factory_type#>(),
101 make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<subtype_factory_typecxx . . $ subtype_factory_type#>(),
102 make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<non_unique_factory_typecxx . . $ non_unique_factory_type#>()
103 }};
104 }
105
106 void provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test#::should_accept_qobject_object_type_and_throw_on_createcxx . . $ provider_by_factory_configuration_test#should_accept_qobject_object_type_and_throw_on_create(49f6e7a06ebc5aa8).()
107 {
108 auto pc = provider_by_factory_configurationcxx . . $ injeqt/internal/provider_by_factory_configuration#provider_by_factory_configuration(4db51c5aea7c0a3b).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<QObjectcxx . . $ QObject#>(), make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<factory_typecxx . . $ factory_type#>()};
109
110 expectcxx . . $ expect(13411efb8aeb1b14).<exceptioncxx . . $ injeqt/v1/exception/::qobject_typecxx . . $ injeqt/v1/exception/qobject_type#>([cxx . . $ std/function#function(a4b4b0c4acad1616).&](){
111 pc.create_providercxx . . $ injeqt/internal/provider_by_factory_configuration#create_provider(2c251cf15db9f22d).(known_typescxx . . $ provider_by_factory_configuration_test#known_types.);
112 });
113 }
114
115 void provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test#::should_accept_qobject_factory_type_and_throw_on_createcxx . . $ provider_by_factory_configuration_test#should_accept_qobject_factory_type_and_throw_on_create(49f6e7a06ebc5aa8).()
116 {
117 auto pc = provider_by_factory_configurationcxx . . $ injeqt/internal/provider_by_factory_configuration#provider_by_factory_configuration(4db51c5aea7c0a3b).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<QObjectcxx . . $ QObject#>()};
118
119 expectcxx . . $ expect(13411efb8aeb1b14).<exceptioncxx . . $ injeqt/v1/exception/::qobject_typecxx . . $ injeqt/v1/exception/qobject_type#>([cxx . . $ std/function#function(a4b4b0c4acad1616).&](){
120 pc.create_providercxx . . $ injeqt/internal/provider_by_factory_configuration#create_provider(2c251cf15db9f22d).(known_typescxx . . $ provider_by_factory_configuration_test#known_types.);
121 });
122 }
123
124 void provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test#::should_accept_factory_without_factory_method_and_throw_on_createcxx . . $ provider_by_factory_configuration_test#should_accept_factory_without_factory_method_and_throw_on_create(49f6e7a06ebc5aa8).()
125 {
126 auto pc = provider_by_factory_configurationcxx . . $ injeqt/internal/provider_by_factory_configuration#provider_by_factory_configuration(4db51c5aea7c0a3b).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_2cxx . . $ type_2#>(), make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<factory_typecxx . . $ factory_type#>()};
127
128 expectcxx . . $ expect(13411efb8aeb1b14).<exceptioncxx . . $ injeqt/v1/exception/::unique_factory_method_not_foundcxx . . $ injeqt/v1/exception/unique_factory_method_not_found#>([cxx . . $ std/function#function(a4b4b0c4acad1616).&](){
129 pc.create_providercxx . . $ injeqt/internal/provider_by_factory_configuration#create_provider(2c251cf15db9f22d).(known_typescxx . . $ provider_by_factory_configuration_test#known_types.);
130 });
131 }
132
133 void provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test#::should_accept_factory_without_unique_factory_method_and_throw_on_createcxx . . $ provider_by_factory_configuration_test#should_accept_factory_without_unique_factory_method_and_throw_on_create(49f6e7a06ebc5aa8).()
134 {
135 auto pc = provider_by_factory_configurationcxx . . $ injeqt/internal/provider_by_factory_configuration#provider_by_factory_configuration(4db51c5aea7c0a3b).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_2cxx . . $ type_2#>(), make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<non_unique_factory_typecxx . . $ non_unique_factory_type#>()};
136
137 expectcxx . . $ expect(13411efb8aeb1b14).<exceptioncxx . . $ injeqt/v1/exception/::unique_factory_method_not_foundcxx . . $ injeqt/v1/exception/unique_factory_method_not_found#>([cxx . . $ std/function#function(a4b4b0c4acad1616).&](){
138 pc.create_providercxx . . $ injeqt/internal/provider_by_factory_configuration#create_provider(2c251cf15db9f22d).(known_typescxx . . $ provider_by_factory_configuration_test#known_types.);
139 });
140 }
141
142 void provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test#::should_accept_supertype_factory_and_throw_on_createcxx . . $ provider_by_factory_configuration_test#should_accept_supertype_factory_and_throw_on_create(49f6e7a06ebc5aa8).()
143 {
144 auto pc = provider_by_factory_configurationcxx . . $ injeqt/internal/provider_by_factory_configuration#provider_by_factory_configuration(4db51c5aea7c0a3b).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_1cxx . . $ type_1_subtype_1#>(), make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<factory_typecxx . . $ factory_type#>()};
145
146 expectcxx . . $ expect(13411efb8aeb1b14).<exceptioncxx . . $ injeqt/v1/exception/::unique_factory_method_not_foundcxx . . $ injeqt/v1/exception/unique_factory_method_not_found#>([cxx . . $ std/function#function(a4b4b0c4acad1616).&](){
147 pc.create_providercxx . . $ injeqt/internal/provider_by_factory_configuration#create_provider(2c251cf15db9f22d).(known_typescxx . . $ provider_by_factory_configuration_test#known_types.);
148 });
149 }
150
151 void provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test#::should_accept_valid_configurationcxx . . $ provider_by_factory_configuration_test#should_accept_valid_configuration(49f6e7a06ebc5aa8).()
152 {
153 auto pc = provider_by_factory_configurationcxx . . $ injeqt/internal/provider_by_factory_configuration#provider_by_factory_configuration(4db51c5aea7c0a3b).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<factory_typecxx . . $ factory_type#>()};
154 auto p = pccxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4)..create_providercxx . . $ injeqt/internal/provider_by_factory_configuration#create_provider(2c251cf15db9f22d).(known_typescxx . . $ provider_by_factory_configuration_test#known_types.);
155
156 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(types{make_type<factory_type>()}, p->required_types());
157 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(make_type<type_1>(), p->provided_type());
158 }
159
160 void provider_by_factory_configuration_testcxx . . $ provider_by_factory_configuration_test#::should_accept_subtype_configurationcxx . . $ provider_by_factory_configuration_test#should_accept_subtype_configuration(49f6e7a06ebc5aa8).()
161 {
162 auto pc = provider_by_factory_configurationcxx . . $ injeqt/internal/provider_by_factory_configuration#provider_by_factory_configuration(4db51c5aea7c0a3b).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<subtype_factory_typecxx . . $ subtype_factory_type#>()};
163 auto p = pccxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4)..create_providercxx . . $ injeqt/internal/provider_by_factory_configuration#create_provider(2c251cf15db9f22d).(known_typescxx . . $ provider_by_factory_configuration_test#known_types.);
164
165 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(types{make_type<subtype_factory_type>()}, p->required_types());
166 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(make_type<type_1_subtype_1>(), p->provided_type());
167 }
168
169 QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(provider_by_factory_configuration_test)
170 #include "provider-by-factory-configuration-test.moc"cxx . . $ `<file>/build/test/provider-by-factory-configuration-test_autogen/include/provider-by-factory-configuration-test.moc`/