| 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/instantiate-all-with-type-role-test.cpp:31:9`! "role1" |
| 32 | #define ROLE_2cxx . . $ `test/integration/instantiate-all-with-type-role-test.cpp:32:9`! "role2" |
| 33 | |
| 34 | stdcxx . . $ std/::setcxx . . $ std/set#<typecxx . . $ type#> instantiated_typescxx . . $ instantiated_types.; |
| 35 | |
| 36 | class role_1_typecxx . . $ role_1_type# : public QObjectcxx . . $ QObject# |
| 37 | { |
| 38 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 39 | INJEQT_TYPE_ROLEcxx . . $ `include/injeqt/injeqt.h:40:9`!(ROLE_1cxx . . $ `test/integration/instantiate-all-with-type-role-test.cpp:31:9`!) |
| 40 | |
| 41 | public: |
| 42 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! role_1_typecxx . . $ role_1_type#role_1_type(49f6e7a06ebc5aa8).() { instantiated_typescxx . . $ instantiated_types..insertcxx . . $ std/set#insert(10916b2dbd511ba8).(make_typecxx . . $ make_type(10a1ed948a80d481).<role_1_typecxx . . $ role_1_type#>()); } |
| 43 | }; |
| 44 | |
| 45 | class no_role_required_by_role_2cxx . . $ no_role_required_by_role_2# : public QObjectcxx . . $ QObject# |
| 46 | { |
| 47 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 48 | |
| 49 | public: |
| 50 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! no_role_required_by_role_2cxx . . $ no_role_required_by_role_2#no_role_required_by_role_2(49f6e7a06ebc5aa8).() { instantiated_typescxx . . $ instantiated_types..insertcxx . . $ std/set#insert(10916b2dbd511ba8).(make_typecxx . . $ make_type(10a1ed948a80d481).<no_role_required_by_role_2cxx . . $ no_role_required_by_role_2#>()); } |
| 51 | }; |
| 52 | |
| 53 | class role_2_typecxx . . $ role_2_type# : public QObjectcxx . . $ QObject# |
| 54 | { |
| 55 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 56 | INJEQT_TYPE_ROLEcxx . . $ `include/injeqt/injeqt.h:40:9`!(ROLE_2cxx . . $ `test/integration/instantiate-all-with-type-role-test.cpp:32:9`!) |
| 57 | |
| 58 | public: |
| 59 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! role_2_typecxx . . $ role_2_type#role_2_type(49f6e7a06ebc5aa8).() { instantiated_typescxx . . $ instantiated_types..insertcxx . . $ std/set#insert(10916b2dbd511ba8).(make_typecxx . . $ make_type(10a1ed948a80d481).<role_2_typecxx . . $ role_2_type#>()); } |
| 60 | |
| 61 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 62 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void set_no_role_required_by_role_2cxx . . $ role_2_type#set_no_role_required_by_role_2(29fad2ab2c716e03).(no_role_required_by_role_2cxx . . $ no_role_required_by_role_2# *) {} |
| 63 | |
| 64 | }; |
| 65 | |
| 66 | class instantiate_all_with_type_role_testcxx . . $ instantiate_all_with_type_role_test# : public QObjectcxx . . $ QObject# |
| 67 | { |
| 68 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 69 | |
| 70 | private: |
| 71 | injeqtcxx . . $ injeqt/::injectorcxx . . $ injeqt/v1/injector# create_injectorcxx . . $ instantiate_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).(); |
| 72 | |
| 73 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 74 | void should_create_all_role_instances_with_dependencied_when_requestedcxx . . $ instantiate_all_with_type_role_test#should_create_all_role_instances_with_dependencied_when_requested(49f6e7a06ebc5aa8).(); |
| 75 | |
| 76 | }; |
| 77 | |
| 78 | injeqtcxx . . $ injeqt/::injectorcxx . . $ injeqt/v1/injector# instantiate_all_with_type_role_testcxx . . $ instantiate_all_with_type_role_test#::create_injectorcxx . . $ instantiate_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).() |
| 79 | { |
| 80 | class mcxx . . $ instantiate_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m# : public injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module# |
| 81 | { |
| 82 | public: |
| 83 | mcxx . . $ instantiate_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m#m(49f6e7a06ebc5aa8).() |
| 84 | { |
| 85 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<role_1_typecxx . . $ role_1_type#>(); |
| 86 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<no_role_required_by_role_2cxx . . $ no_role_required_by_role_2#>(); |
| 87 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<role_2_typecxx . . $ role_2_type#>(); |
| 88 | } |
| 89 | virtual ~cxx . . $ instantiate_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m#`~m`(49f6e7a06ebc5aa8).mcxx . . $ instantiate_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m#() {} |
| 90 | }; |
| 91 | |
| 92 | auto modules = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module#>>{}; |
| 93 | modules.emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(stdcxx . . $ std/unique_ptr#unique_ptr(57bc6b0441bf5294).::unique_ptrcxx . . $ std/unique_ptr#<mcxx . . $ instantiate_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m#>{new mcxx . . $ instantiate_all_with_type_role_test#create_injector(e7f7e8043efbe7f0).m#{}}); |
| 94 | return injeqtcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).::injectorcxx . . $ injeqt/v1/injector#{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::movecxx . . $ std/move(e7c6c0c8363dcc46).(modules)}; |
| 95 | } |
| 96 | |
| 97 | void instantiate_all_with_type_role_testcxx . . $ instantiate_all_with_type_role_test#::should_create_all_role_instances_with_dependencied_when_requestedcxx . . $ instantiate_all_with_type_role_test#should_create_all_role_instances_with_dependencied_when_requested(49f6e7a06ebc5aa8).() |
| 98 | { |
| 99 | auto injector = create_injectorcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).(); |
| 100 | instantiated_typescxx . . $ instantiated_types..clearcxx . . $ std/set#clear(49f6e7a06ebc5aa8).(); |
| 101 | injector.instantiate_all_with_type_rolecxx . . $ injeqt/v1/injector#instantiate_all_with_type_role(9c546c94e5fcce4e).(ROLE_2cxx . . $ `test/integration/instantiate-all-with-type-role-test.cpp:32:9`!); |
| 102 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(instantiated_types, (std::set<type>{make_type<role_2_type>(), make_type<no_role_required_by_role_2>()})); |
| 103 | |
| 104 | instantiated_typescxx . . $ instantiated_types..clearcxx . . $ std/set#clear(49f6e7a06ebc5aa8).(); |
| 105 | injector.instantiate_all_with_type_rolecxx . . $ injeqt/v1/injector#instantiate_all_with_type_role(9c546c94e5fcce4e).(ROLE_1cxx . . $ `test/integration/instantiate-all-with-type-role-test.cpp:31:9`!); |
| 106 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(instantiated_types, (std::set<type>{make_type<role_1_type>()})); |
| 107 | } |
| 108 | |
| 109 | QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(instantiate_all_with_type_role_test) |
| 110 | #include "instantiate-all-with-type-role-test.moc"cxx . . $ `<file>/build/test/instantiate-all-with-type-role-test_autogen/include/instantiate-all-with-type-role-test.moc`/ |