| 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 | |
| 24 | #include <QtTest/QtTest> |
| 25 | |
| 26 | class injectable_supercxx . . $ injectable_super# : public QObjectcxx . . $ QObject# |
| 27 | { |
| 28 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 29 | |
| 30 | public: |
| 31 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! injectable_supercxx . . $ injectable_super#injectable_super(49f6e7a06ebc5aa8).() {} |
| 32 | virtual ~cxx . . $ injectable_super#`~injectable_super`(49f6e7a06ebc5aa8).injectable_supercxx . . $ injectable_super#() {} |
| 33 | |
| 34 | }; |
| 35 | |
| 36 | class injectable_subcxx . . $ injectable_sub# : public injectable_supercxx . . $ injectable_super# |
| 37 | { |
| 38 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 39 | |
| 40 | public: |
| 41 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! injectable_subcxx . . $ injectable_sub#injectable_sub(49f6e7a06ebc5aa8).() {} |
| 42 | virtual ~cxx . . $ injectable_sub#`~injectable_sub`(49f6e7a06ebc5aa8).injectable_subcxx . . $ injectable_sub#() {} |
| 43 | |
| 44 | }; |
| 45 | |
| 46 | class super_dependneciescxx . . $ super_dependnecies# : public QObjectcxx . . $ QObject# |
| 47 | { |
| 48 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 49 | |
| 50 | public: |
| 51 | injectable_supercxx . . $ injectable_super# *vcxx . . $ super_dependnecies#v. = nullptr; |
| 52 | |
| 53 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! super_dependneciescxx . . $ super_dependnecies#super_dependnecies(49f6e7a06ebc5aa8).() {} |
| 54 | virtual ~cxx . . $ super_dependnecies#`~super_dependnecies`(49f6e7a06ebc5aa8).super_dependneciescxx . . $ super_dependnecies#() {} |
| 55 | |
| 56 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 57 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void set_injectable_supercxx . . $ super_dependnecies#set_injectable_super(d8b04adf48f871a).(injectable_supercxx . . $ injectable_super# *x) { vcxx . . $ super_dependnecies#v. = x; } |
| 58 | |
| 59 | }; |
| 60 | |
| 61 | class sub_dependneciescxx . . $ sub_dependnecies# : public QObjectcxx . . $ QObject# |
| 62 | { |
| 63 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 64 | |
| 65 | public: |
| 66 | injectable_subcxx . . $ injectable_sub# *vcxx . . $ sub_dependnecies#v. = nullptr; |
| 67 | |
| 68 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! sub_dependneciescxx . . $ sub_dependnecies#sub_dependnecies(49f6e7a06ebc5aa8).() {} |
| 69 | virtual ~cxx . . $ sub_dependnecies#`~sub_dependnecies`(49f6e7a06ebc5aa8).sub_dependneciescxx . . $ sub_dependnecies#() {} |
| 70 | |
| 71 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 72 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void set_injectable_subcxx . . $ sub_dependnecies#set_injectable_sub(f949a4a1d1eb3593).(injectable_subcxx . . $ injectable_sub# *x) { vcxx . . $ sub_dependnecies#v. = x; } |
| 73 | |
| 74 | }; |
| 75 | |
| 76 | class super_sub_dependency_testcxx . . $ super_sub_dependency_test# : public QObjectcxx . . $ QObject# |
| 77 | { |
| 78 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 79 | |
| 80 | private: |
| 81 | injeqtcxx . . $ injeqt/::injectorcxx . . $ injeqt/v1/injector# get_injectorcxx . . $ super_sub_dependency_test#get_injector(4c43d4e061b64641).() const; |
| 82 | |
| 83 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 84 | void should_set_valid_super_dependenciescxx . . $ super_sub_dependency_test#should_set_valid_super_dependencies(49f6e7a06ebc5aa8).(); |
| 85 | void should_set_valid_sub_dependenciescxx . . $ super_sub_dependency_test#should_set_valid_sub_dependencies(49f6e7a06ebc5aa8).(); |
| 86 | |
| 87 | }; |
| 88 | |
| 89 | injeqtcxx . . $ injeqt/::injectorcxx . . $ injeqt/v1/injector# super_sub_dependency_testcxx . . $ super_sub_dependency_test#::get_injectorcxx . . $ super_sub_dependency_test#get_injector(4c43d4e061b64641).() const |
| 90 | { |
| 91 | class mcxx . . $ super_sub_dependency_test#get_injector(4c43d4e061b64641).m# : public injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module# |
| 92 | { |
| 93 | public: |
| 94 | mcxx . . $ super_sub_dependency_test#get_injector(4c43d4e061b64641).m#m(49f6e7a06ebc5aa8).() |
| 95 | { |
| 96 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<injectable_subcxx . . $ injectable_sub#>(); |
| 97 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<super_dependneciescxx . . $ super_dependnecies#>(); |
| 98 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<sub_dependneciescxx . . $ sub_dependnecies#>(); |
| 99 | } |
| 100 | virtual ~cxx . . $ super_sub_dependency_test#get_injector(4c43d4e061b64641).m#`~m`(49f6e7a06ebc5aa8).mcxx . . $ super_sub_dependency_test#get_injector(4c43d4e061b64641).m#() {} |
| 101 | }; |
| 102 | |
| 103 | auto modules = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module#>>{}; |
| 104 | modules.emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(stdcxx . . $ std/unique_ptr#unique_ptr(57bc6b0441bf5294).::unique_ptrcxx . . $ std/unique_ptr#<mcxx . . $ super_sub_dependency_test#get_injector(4c43d4e061b64641).m#>{new mcxx . . $ super_sub_dependency_test#get_injector(4c43d4e061b64641).m#{}}); |
| 105 | return injeqtcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).::injectorcxx . . $ injeqt/v1/injector#{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::movecxx . . $ std/move(e7c6c0c8363dcc46).(modules)}; |
| 106 | } |
| 107 | |
| 108 | void super_sub_dependency_testcxx . . $ super_sub_dependency_test#::should_set_valid_super_dependenciescxx . . $ super_sub_dependency_test#should_set_valid_super_dependencies(49f6e7a06ebc5aa8).() |
| 109 | { |
| 110 | auto injector = get_injectorcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).(); |
| 111 | auto c = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<super_dependneciescxx . . $ super_dependnecies#>(); |
| 112 | auto sub = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<injectable_subcxx . . $ injectable_sub#>(); |
| 113 | auto super = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<injectable_supercxx . . $ injectable_super#>(); |
| 114 | |
| 115 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(c != nullptr); |
| 116 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(sub != nullptr); |
| 117 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(super != nullptr); |
| 118 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(c->v == super); |
| 119 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(c->v == sub); |
| 120 | } |
| 121 | |
| 122 | void super_sub_dependency_testcxx . . $ super_sub_dependency_test#::should_set_valid_sub_dependenciescxx . . $ super_sub_dependency_test#should_set_valid_sub_dependencies(49f6e7a06ebc5aa8).() |
| 123 | { |
| 124 | auto injector = get_injectorcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).(); |
| 125 | auto c = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<sub_dependneciescxx . . $ sub_dependnecies#>(); |
| 126 | auto sub = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<injectable_subcxx . . $ injectable_sub#>(); |
| 127 | auto super = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<injectable_supercxx . . $ injectable_super#>(); |
| 128 | |
| 129 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(c != nullptr); |
| 130 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(sub != nullptr); |
| 131 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(super != nullptr); |
| 132 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(c->v == super); |
| 133 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(c->v == sub); |
| 134 | } |
| 135 | |
| 136 | QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(super_sub_dependency_test) |
| 137 | #include "super-sub-dependency-test.moc"cxx . . $ `<file>/build/test/super-sub-dependency-test_autogen/include/super-sub-dependency-test.moc`/ |