| 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 <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 default_constructiblecxx . . $ default_constructible# : 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`! default_constructiblecxx . . $ default_constructible#default_constructible(49f6e7a06ebc5aa8).() {} |
| 32 | |
| 33 | }; |
| 34 | |
| 35 | class int_containercxx . . $ int_container# : public QObjectcxx . . $ QObject# |
| 36 | { |
| 37 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 38 | |
| 39 | public: |
| 40 | int_containercxx . . $ int_container#int_container(49f6e7a06ebc5aa8).() {} |
| 41 | virtual ~cxx . . $ int_container#`~int_container`(49f6e7a06ebc5aa8).int_containercxx . . $ int_container#() {} |
| 42 | virtual int valuecxx . . $ int_container#value(455f465bc33b4cdf).() const = 0; |
| 43 | |
| 44 | }; |
| 45 | |
| 46 | class simple_int_containercxx . . $ simple_int_container# : public int_containercxx . . $ int_container# |
| 47 | { |
| 48 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 49 | |
| 50 | public: |
| 51 | simple_int_containercxx . . $ simple_int_container#simple_int_container(d4f767463ce0a6b3).(int value) : _valuecxx . . $ simple_int_container#_value.{value} {} |
| 52 | virtual ~cxx . . $ simple_int_container#`~simple_int_container`(49f6e7a06ebc5aa8).simple_int_containercxx . . $ simple_int_container#() {} |
| 53 | virtual int valuecxx . . $ simple_int_container#value(455f465bc33b4cdf).() const override { return _valuecxx . . $ simple_int_container#_value.; } |
| 54 | |
| 55 | private: |
| 56 | int _valuecxx . . $ simple_int_container#_value.; |
| 57 | |
| 58 | }; |
| 59 | |
| 60 | class int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter# : public int_containercxx . . $ int_container# |
| 61 | { |
| 62 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 63 | |
| 64 | public: |
| 65 | int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#int_container_with_ignored_setter(d4f767463ce0a6b3).(int value) : _valuecxx . . $ int_container_with_ignored_setter#_value.{value} {} |
| 66 | virtual ~cxx . . $ int_container_with_ignored_setter#`~int_container_with_ignored_setter`(49f6e7a06ebc5aa8).int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#() {} |
| 67 | virtual int valuecxx . . $ int_container_with_ignored_setter#value(455f465bc33b4cdf).() const override { return _valuecxx . . $ int_container_with_ignored_setter#_value.; } |
| 68 | default_constructiblecxx . . $ default_constructible# * objectcxx . . $ int_container_with_ignored_setter#object(dadcd6d3f0a81101).() const { return _objectcxx . . $ int_container_with_ignored_setter#_object.; } |
| 69 | |
| 70 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 71 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void set_default_constructiblecxx . . $ int_container_with_ignored_setter#set_default_constructible(d6420a22eb66c112).(default_constructiblecxx . . $ default_constructible# *object) |
| 72 | { |
| 73 | _objectcxx . . $ int_container_with_ignored_setter#_object. =cxx . . $ QPointer#`operator=`(500fb76d9e491ab0). object; |
| 74 | } |
| 75 | |
| 76 | private: |
| 77 | int _valuecxx . . $ int_container_with_ignored_setter#_value.; |
| 78 | QPointercxx . . $ QPointer#<default_constructiblecxx . . $ default_constructible#> _objectcxx . . $ int_container_with_ignored_setter#_object.; |
| 79 | |
| 80 | }; |
| 81 | |
| 82 | class int_servicecxx . . $ int_service# : public QObjectcxx . . $ QObject# |
| 83 | { |
| 84 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 85 | |
| 86 | public: |
| 87 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! int_servicecxx . . $ int_service#int_service(49f6e7a06ebc5aa8).() {} |
| 88 | int valuecxx . . $ int_service#value(455f465bc33b4cdf).() const { return _int_containercxx . . $ int_service#_int_container.->cxx . . $ QPointer#`operator->`(5a2a78a048fb49a8).valuecxx . . $ int_container#value(455f465bc33b4cdf).(); } |
| 89 | |
| 90 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 91 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void set_int_containercxx . . $ int_service#set_int_container(e6e2b3d20ed44962).(int_containercxx . . $ int_container# *container) |
| 92 | { |
| 93 | _int_containercxx . . $ int_service#_int_container. =cxx . . $ QPointer#`operator=`(500fb76d9e491ab0). container; |
| 94 | } |
| 95 | |
| 96 | private: |
| 97 | QPointercxx . . $ QPointer#<int_containercxx . . $ int_container#> _int_containercxx . . $ int_service#_int_container.; |
| 98 | |
| 99 | }; |
| 100 | |
| 101 | class ready_object_behavior_testcxx . . $ ready_object_behavior_test# : public QObjectcxx . . $ QObject# |
| 102 | { |
| 103 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 104 | |
| 105 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 106 | void should_create_proper_object_structurecxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).(); |
| 107 | void should_ignore_invalid_setters_in_ready_objectcxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).(); |
| 108 | void should_ignore_valid_setters_in_ready_objectcxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).(); |
| 109 | |
| 110 | }; |
| 111 | |
| 112 | void ready_object_behavior_testcxx . . $ ready_object_behavior_test#::should_create_proper_object_structurecxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).() |
| 113 | { |
| 114 | class mcxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).m# : public injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module# |
| 115 | { |
| 116 | public: |
| 117 | mcxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).m#m(d4f767463ce0a6b3).(int value) |
| 118 | { |
| 119 | _containercxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).m#_container. =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<simple_int_containercxx . . $ simple_int_container#>(new simple_int_containercxx . . $ simple_int_container#{value}); |
| 120 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<int_servicecxx . . $ int_service#>(); |
| 121 | add_ready_objectcxx . . $ injeqt/v1/module#add_ready_object(749de1b6ae65bddd).<simple_int_containercxx . . $ simple_int_container#>(_containercxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).m#_container..getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 122 | } |
| 123 | virtual ~cxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).m#`~m`(49f6e7a06ebc5aa8).mcxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).m#() {} |
| 124 | private: |
| 125 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<simple_int_containercxx . . $ simple_int_container#> _containercxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).m#_container.; |
| 126 | }; |
| 127 | |
| 128 | auto modules = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module#>>{}; |
| 129 | modules.emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(stdcxx . . $ std/unique_ptr#unique_ptr(57bc6b0441bf5294).::unique_ptrcxx . . $ std/unique_ptr#<mcxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).m#>{new mcxx . . $ ready_object_behavior_test#should_create_proper_object_structure(49f6e7a06ebc5aa8).m#{9}}); |
| 130 | auto injector = injeqtcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).::injectorcxx . . $ injeqt/v1/injector#{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::movecxx . . $ std/move(e7c6c0c8363dcc46).(modules)}; |
| 131 | auto service = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<int_servicecxx . . $ int_service#>(); |
| 132 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(9, service->value()); |
| 133 | } |
| 134 | |
| 135 | void ready_object_behavior_testcxx . . $ ready_object_behavior_test#::should_ignore_invalid_setters_in_ready_objectcxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).() |
| 136 | { |
| 137 | class mcxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).m# : public injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module# |
| 138 | { |
| 139 | public: |
| 140 | mcxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).m#m(d4f767463ce0a6b3).(int value) |
| 141 | { |
| 142 | _containercxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).m#_container. =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#>(new int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#{value}); |
| 143 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<int_servicecxx . . $ int_service#>(); |
| 144 | add_ready_objectcxx . . $ injeqt/v1/module#add_ready_object(749de1b6ae65bddd).<int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#>(_containercxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).m#_container..getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 145 | } |
| 146 | virtual ~cxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).m#`~m`(49f6e7a06ebc5aa8).mcxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).m#() {} |
| 147 | private: |
| 148 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#> _containercxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).m#_container.; |
| 149 | }; |
| 150 | |
| 151 | auto modules = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module#>>{}; |
| 152 | modules.emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(stdcxx . . $ std/unique_ptr#unique_ptr(57bc6b0441bf5294).::unique_ptrcxx . . $ std/unique_ptr#<mcxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).m#>{new mcxx . . $ ready_object_behavior_test#should_ignore_invalid_setters_in_ready_object(49f6e7a06ebc5aa8).m#{9}}); |
| 153 | auto injector = injeqtcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).::injectorcxx . . $ injeqt/v1/injector#{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::movecxx . . $ std/move(e7c6c0c8363dcc46).(modules)}; |
| 154 | auto service = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<int_servicecxx . . $ int_service#>(); |
| 155 | auto container = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#>(); |
| 156 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(9, service->value()); |
| 157 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(static_cast<QObject *>(nullptr), container->object()); |
| 158 | } |
| 159 | |
| 160 | void ready_object_behavior_testcxx . . $ ready_object_behavior_test#::should_ignore_valid_setters_in_ready_objectcxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).() |
| 161 | { |
| 162 | class mcxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).m# : public injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module# |
| 163 | { |
| 164 | public: |
| 165 | mcxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).m#m(d4f767463ce0a6b3).(int value) |
| 166 | { |
| 167 | _containercxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).m#_container. =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#>(new int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#{value}); |
| 168 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<int_servicecxx . . $ int_service#>(); |
| 169 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<default_constructiblecxx . . $ default_constructible#>(); |
| 170 | add_ready_objectcxx . . $ injeqt/v1/module#add_ready_object(749de1b6ae65bddd).<int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#>(_containercxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).m#_container..getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 171 | } |
| 172 | virtual ~cxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).m#`~m`(49f6e7a06ebc5aa8).mcxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).m#() {} |
| 173 | private: |
| 174 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#> _containercxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).m#_container.; |
| 175 | }; |
| 176 | |
| 177 | auto modules = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module#>>{}; |
| 178 | modules.emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(stdcxx . . $ std/unique_ptr#unique_ptr(57bc6b0441bf5294).::unique_ptrcxx . . $ std/unique_ptr#<mcxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).m#>{new mcxx . . $ ready_object_behavior_test#should_ignore_valid_setters_in_ready_object(49f6e7a06ebc5aa8).m#{9}}); |
| 179 | auto injector = injeqtcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).::injectorcxx . . $ injeqt/v1/injector#{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::movecxx . . $ std/move(e7c6c0c8363dcc46).(modules)}; |
| 180 | auto service = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<int_servicecxx . . $ int_service#>(); |
| 181 | auto container = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<int_container_with_ignored_settercxx . . $ int_container_with_ignored_setter#>(); |
| 182 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(9, service->value()); |
| 183 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(static_cast<QObject *>(nullptr), container->object()); |
| 184 | } |
| 185 | |
| 186 | QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(ready_object_behavior_test) |
| 187 | #include "ready-object-behavior-test.moc"cxx . . $ `<file>/build/test/ready-object-behavior-test_autogen/include/ready-object-behavior-test.moc`/ |