| 1 | /* |
| 2 | * %injeqt copyright begin% |
| 3 | * Copyright 2015 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 int_containercxx . . $ int_container# : public QObjectcxx . . $ QObject# |
| 27 | { |
| 28 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 29 | |
| 30 | public: |
| 31 | int_containercxx . . $ int_container#int_container(49f6e7a06ebc5aa8).() {} |
| 32 | virtual ~cxx . . $ int_container#`~int_container`(49f6e7a06ebc5aa8).int_containercxx . . $ int_container#() {} |
| 33 | virtual int valuecxx . . $ int_container#value(455f465bc33b4cdf).() const = 0; |
| 34 | |
| 35 | }; |
| 36 | |
| 37 | class nine_containercxx . . $ nine_container# : public int_containercxx . . $ int_container# |
| 38 | { |
| 39 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 40 | |
| 41 | public: |
| 42 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! nine_containercxx . . $ nine_container#nine_container(49f6e7a06ebc5aa8).() {} |
| 43 | virtual ~cxx . . $ nine_container#`~nine_container`(49f6e7a06ebc5aa8).nine_containercxx . . $ nine_container#() {} |
| 44 | virtual int valuecxx . . $ nine_container#value(455f465bc33b4cdf).() const override { return 9; } |
| 45 | |
| 46 | }; |
| 47 | |
| 48 | class int_servicecxx . . $ int_service# : public QObjectcxx . . $ QObject# |
| 49 | { |
| 50 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 51 | |
| 52 | public: |
| 53 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! int_servicecxx . . $ int_service#int_service(49f6e7a06ebc5aa8).() {} |
| 54 | int valuecxx . . $ int_service#value(455f465bc33b4cdf).() const { return _int_containercxx . . $ int_service#_int_container.->cxx . . $ QPointer#`operator->`(5a2a78a048fb49a8).valuecxx . . $ int_container#value(455f465bc33b4cdf).(); } |
| 55 | |
| 56 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 57 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void set_int_containercxx . . $ int_service#set_int_container(e6e2b3d20ed44962).(int_containercxx . . $ int_container# *container) |
| 58 | { |
| 59 | _int_containercxx . . $ int_service#_int_container. =cxx . . $ QPointer#`operator=`(500fb76d9e491ab0). container; |
| 60 | } |
| 61 | |
| 62 | private: |
| 63 | QPointercxx . . $ QPointer#<int_containercxx . . $ int_container#> _int_containercxx . . $ int_service#_int_container.; |
| 64 | |
| 65 | }; |
| 66 | |
| 67 | class int_sub_servicecxx . . $ int_sub_service# : public int_servicecxx . . $ int_service# |
| 68 | { |
| 69 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 70 | |
| 71 | public: |
| 72 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! int_sub_servicecxx . . $ int_sub_service#int_sub_service(49f6e7a06ebc5aa8).() {} |
| 73 | |
| 74 | }; |
| 75 | |
| 76 | class inject_into_behavior_testcxx . . $ inject_into_behavior_test# : public QObjectcxx . . $ QObject# |
| 77 | { |
| 78 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 79 | |
| 80 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 81 | void should_properly_inject_intocxx . . $ inject_into_behavior_test#should_properly_inject_into(49f6e7a06ebc5aa8).(); |
| 82 | |
| 83 | }; |
| 84 | |
| 85 | void inject_into_behavior_testcxx . . $ inject_into_behavior_test#::should_properly_inject_intocxx . . $ inject_into_behavior_test#should_properly_inject_into(49f6e7a06ebc5aa8).() |
| 86 | { |
| 87 | class mcxx . . $ inject_into_behavior_test#should_properly_inject_into(49f6e7a06ebc5aa8).m# : public injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module# |
| 88 | { |
| 89 | public: |
| 90 | mcxx . . $ inject_into_behavior_test#should_properly_inject_into(49f6e7a06ebc5aa8).m#m(49f6e7a06ebc5aa8).() |
| 91 | { |
| 92 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<nine_containercxx . . $ nine_container#>(); |
| 93 | } |
| 94 | virtual ~cxx . . $ inject_into_behavior_test#should_properly_inject_into(49f6e7a06ebc5aa8).m#`~m`(49f6e7a06ebc5aa8).mcxx . . $ inject_into_behavior_test#should_properly_inject_into(49f6e7a06ebc5aa8).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 . . $ inject_into_behavior_test#should_properly_inject_into(49f6e7a06ebc5aa8).m#>{new mcxx . . $ inject_into_behavior_test#should_properly_inject_into(49f6e7a06ebc5aa8).m#{}}); |
| 99 | auto injector = injeqtcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).::injectorcxx . . $ injeqt/v1/injector#{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::movecxx . . $ std/move(e7c6c0c8363dcc46).(modules)}; |
| 100 | |
| 101 | int_servicecxx . . $ int_service# servicecxx . . $ int_service#int_service(49f6e7a06ebc5aa8).{}; |
| 102 | injector.inject_intocxx . . $ injeqt/v1/injector#inject_into(749de1b6ae65bddd).(&service); |
| 103 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(9, service.value()); |
| 104 | |
| 105 | int_sub_servicecxx . . $ int_sub_service# sub_servicecxx . . $ int_sub_service#int_sub_service(49f6e7a06ebc5aa8).{}; |
| 106 | injector.inject_intocxx . . $ injeqt/v1/injector#inject_into(749de1b6ae65bddd).(&sub_service); |
| 107 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(9, sub_service.value()); |
| 108 | } |
| 109 | |
| 110 | QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(inject_into_behavior_test) |
| 111 | #include "inject-into-behavior-test.moc"cxx . . $ `<file>/build/test/inject-into-behavior-test_autogen/include/inject-into-behavior-test.moc`/ |