| 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 | #include "utils.h"cxx . . $ `<file>/test/unit/utils.h`/ |
| 23 | |
| 24 | #include <injeqt/exception/invalid-setter.h>cxx . . $ `<file>/include/injeqt/exception/invalid-setter.h`/ |
| 25 | |
| 26 | #include "internal/types-by-name.h"cxx . . $ `<file>/src/internal/types-by-name.h`/ |
| 27 | |
| 28 | #include <QtTest/QtTest> |
| 29 | |
| 30 | #ifndef Q_MOC_RUN |
| 31 | # define INVALID_SETTER_TAGcxx . . $ `test/unit/setter-method-test.cpp:31:11`! |
| 32 | #endif |
| 33 | |
| 34 | using namespace injeqtcxx . . $ injeqt/::internal; |
| 35 | using namespace injeqtcxx . . $ injeqt/::v1; |
| 36 | |
| 37 | class injectable_type1cxx . . $ injectable_type1# : public QObjectcxx . . $ QObject# |
| 38 | { |
| 39 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 40 | }; |
| 41 | |
| 42 | class injectable_type2cxx . . $ injectable_type2# : public QObjectcxx . . $ QObject# |
| 43 | { |
| 44 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 45 | }; |
| 46 | |
| 47 | class test_typecxx . . $ test_type# : public QObjectcxx . . $ QObject# |
| 48 | { |
| 49 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 50 | |
| 51 | public: |
| 52 | injectable_type1cxx . . $ injectable_type1# *_1cxx . . $ test_type#_1. = nullptr; |
| 53 | |
| 54 | test_typecxx . . $ test_type#test_type(49f6e7a06ebc5aa8).() {} |
| 55 | |
| 56 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! test_typecxx . . $ test_type#test_type(b3b2a74a60f39174).(injectable_type1cxx . . $ injectable_type1# *) {} |
| 57 | |
| 58 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void tagged_setter_method_1cxx . . $ test_type#tagged_setter_method_1(b3b2a74a60f39174).(injectable_type1cxx . . $ injectable_type1# *a) { _1cxx . . $ test_type#_1. = a; } |
| 59 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! INJEQT_SETTERcxx . . $ `include/injeqt/injeqt.h:36:11`! void tagged_setter_method_2cxx . . $ test_type#tagged_setter_method_2(b3b2a74a60f39174).(injectable_type1cxx . . $ injectable_type1# *a) { _1cxx . . $ test_type#_1. = a; } |
| 60 | |
| 61 | public slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 62 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void tagged_setter_slot_1cxx . . $ test_type#tagged_setter_slot_1(b3b2a74a60f39174).(injectable_type1cxx . . $ injectable_type1# *a) { _1cxx . . $ test_type#_1. = a; } |
| 63 | INJEQT_SETTERcxx . . $ `include/injeqt/injeqt.h:36:11`! void tagged_setter_slot_2cxx . . $ test_type#tagged_setter_slot_2(b3b2a74a60f39174).(injectable_type1cxx . . $ injectable_type1# *a) { _1cxx . . $ test_type#_1. = a; } |
| 64 | INJEQT_SETTERcxx . . $ `include/injeqt/injeqt.h:36:11`! void invalid_setter_multi_argumentscxx . . $ test_type#invalid_setter_multi_arguments(a24b30f23a4297bd).(injectable_type1cxx . . $ injectable_type1# *, injectable_type2cxx . . $ injectable_type2# *) { } |
| 65 | INVALID_SETTER_TAGcxx . . $ `test/unit/setter-method-test.cpp:31:11`! void invalid_setter_invalid_tagcxx . . $ test_type#invalid_setter_invalid_tag(b3b2a74a60f39174).(injectable_type1cxx . . $ injectable_type1# *) { } |
| 66 | void invalid_setter_no_tagcxx . . $ test_type#invalid_setter_no_tag(b3b2a74a60f39174).(injectable_type1cxx . . $ injectable_type1# *) { } |
| 67 | |
| 68 | signalscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:89:14`!: |
| 69 | INJEQT_SETTERcxx . . $ `include/injeqt/injeqt.h:36:11`! void invalid_setter_signalcxx . . $ test_type#invalid_setter_signal(b3b2a74a60f39174).(injectable_type1cxx . . $ injectable_type1# *); |
| 70 | |
| 71 | }; |
| 72 | |
| 73 | class setter_method_testcxx . . $ setter_method_test# : public QObjectcxx . . $ QObject# |
| 74 | { |
| 75 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 76 | |
| 77 | public: |
| 78 | setter_method_testcxx . . $ setter_method_test#setter_method_test(49f6e7a06ebc5aa8).(); |
| 79 | |
| 80 | private: |
| 81 | types_by_namecxx . . $ injeqt/internal/types_by_name# _known_typescxx . . $ setter_method_test#_known_types.; |
| 82 | |
| 83 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 84 | void should_create_emptycxx . . $ setter_method_test#should_create_empty(49f6e7a06ebc5aa8).(); |
| 85 | void should_create_valid_from_tagged_setter_methodcxx . . $ setter_method_test#should_create_valid_from_tagged_setter_method(49f6e7a06ebc5aa8).(); |
| 86 | void should_create_valid_from_tagged_setter_slotcxx . . $ setter_method_test#should_create_valid_from_tagged_setter_slot(49f6e7a06ebc5aa8).(); |
| 87 | void should_invoke_have_resultscxx . . $ setter_method_test#should_invoke_have_results(49f6e7a06ebc5aa8).(); |
| 88 | void should_throw_when_empty_methodcxx . . $ setter_method_test#should_throw_when_empty_method(49f6e7a06ebc5aa8).(); |
| 89 | void should_throw_when_multiple_argumentscxx . . $ setter_method_test#should_throw_when_multiple_arguments(49f6e7a06ebc5aa8).(); |
| 90 | void should_throw_when_invalid_tagcxx . . $ setter_method_test#should_throw_when_invalid_tag(49f6e7a06ebc5aa8).(); |
| 91 | void should_throw_when_no_tagcxx . . $ setter_method_test#should_throw_when_no_tag(49f6e7a06ebc5aa8).(); |
| 92 | void should_throw_when_signalcxx . . $ setter_method_test#should_throw_when_signal(49f6e7a06ebc5aa8).(); |
| 93 | void should_throw_when_constructorcxx . . $ setter_method_test#should_throw_when_constructor(49f6e7a06ebc5aa8).(); |
| 94 | |
| 95 | }; |
| 96 | |
| 97 | setter_method_testcxx . . $ setter_method_test#::setter_method_testcxx . . $ setter_method_test#setter_method_test(49f6e7a06ebc5aa8).() : |
| 98 | _known_typescxx . . $ setter_method_test#_known_types.{ |
| 99 | make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<injectable_type1cxx . . $ injectable_type1#>(), |
| 100 | make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<injectable_type2cxx . . $ injectable_type2#>(), |
| 101 | make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<test_typecxx . . $ test_type#>() |
| 102 | } |
| 103 | { |
| 104 | } |
| 105 | |
| 106 | void setter_method_testcxx . . $ setter_method_test#::should_create_emptycxx . . $ setter_method_test#should_create_empty(49f6e7a06ebc5aa8).() |
| 107 | { |
| 108 | auto setter = setter_methodcxx . . $ injeqt/internal/setter_method#setter_method(49f6e7a06ebc5aa8).{}; |
| 109 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(setter.is_empty()); |
| 110 | } |
| 111 | |
| 112 | void setter_method_testcxx . . $ setter_method_test#::should_create_valid_from_tagged_setter_methodcxx . . $ setter_method_test#should_create_valid_from_tagged_setter_method(49f6e7a06ebc5aa8).() |
| 113 | { |
| 114 | auto setter = make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("tagged_setter_method_1(injectable_type1*)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 115 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!setter.is_empty()); |
| 116 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setter.object_type(), make_type<test_type>()); |
| 117 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setter.parameter_type(), make_type<injectable_type1>()); |
| 118 | |
| 119 | setter =cxx . . $ injeqt/internal/setter_method#`operator=`(c1421b81abc78768). make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("tagged_setter_method_2(injectable_type1*)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 120 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!setter.is_empty()); |
| 121 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setter.object_type(), make_type<test_type>()); |
| 122 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setter.parameter_type(), make_type<injectable_type1>()); |
| 123 | } |
| 124 | |
| 125 | void setter_method_testcxx . . $ setter_method_test#::should_create_valid_from_tagged_setter_slotcxx . . $ setter_method_test#should_create_valid_from_tagged_setter_slot(49f6e7a06ebc5aa8).() |
| 126 | { |
| 127 | auto setter = make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("tagged_setter_slot_1(injectable_type1*)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 128 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!setter.is_empty()); |
| 129 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setter.object_type(), make_type<test_type>()); |
| 130 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setter.parameter_type(), make_type<injectable_type1>()); |
| 131 | |
| 132 | setter =cxx . . $ injeqt/internal/setter_method#`operator=`(c1421b81abc78768). make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("tagged_setter_slot_2(injectable_type1*)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 133 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!setter.is_empty()); |
| 134 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setter.object_type(), make_type<test_type>()); |
| 135 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setter.parameter_type(), make_type<injectable_type1>()); |
| 136 | } |
| 137 | |
| 138 | void setter_method_testcxx . . $ setter_method_test#::should_invoke_have_resultscxx . . $ setter_method_test#should_invoke_have_results(49f6e7a06ebc5aa8).() |
| 139 | { |
| 140 | auto setter = make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("tagged_setter_slot_1(injectable_type1*)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 141 | auto on = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<test_typecxx . . $ test_type#>(); |
| 142 | auto with = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<injectable_type1cxx . . $ injectable_type1#>(); |
| 143 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(static_cast<QObject *>(nullptr), static_cast<test_type *>(on.get())->_1); |
| 144 | |
| 145 | setter.invokecxx . . $ injeqt/internal/setter_method#invoke(77edfd4708c3eca3).(on.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).(), with.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 146 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(with.get(), static_cast<test_type *>(on.get())->_1); |
| 147 | } |
| 148 | |
| 149 | void setter_method_testcxx . . $ setter_method_test#::should_throw_when_empty_methodcxx . . $ setter_method_test#should_throw_when_empty_method(49f6e7a06ebc5aa8).() |
| 150 | { |
| 151 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_settercxx . . $ injeqt/v1/exception/invalid_setter#>({cxx . . $ std/vector#vector(9619226211e5a241)."setter does not have enclosing meta object"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 152 | make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., QMetaMethodcxx . . $ QMetaMethod#QMetaMethod(49f6e7a06ebc5aa8).{}); |
| 153 | }); |
| 154 | } |
| 155 | |
| 156 | void setter_method_testcxx . . $ setter_method_test#::should_throw_when_multiple_argumentscxx . . $ setter_method_test#should_throw_when_multiple_arguments(49f6e7a06ebc5aa8).() |
| 157 | { |
| 158 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_settercxx . . $ injeqt/v1/exception/invalid_setter#>({cxx . . $ std/vector#vector(9619226211e5a241)."invalid parameter count"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 159 | make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("invalid_setter_multi_arguments(injectable_type1*,injectable_type2*)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 160 | }); |
| 161 | } |
| 162 | |
| 163 | void setter_method_testcxx . . $ setter_method_test#::should_throw_when_invalid_tagcxx . . $ setter_method_test#should_throw_when_invalid_tag(49f6e7a06ebc5aa8).() |
| 164 | { |
| 165 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_settercxx . . $ injeqt/v1/exception/invalid_setter#>({cxx . . $ std/vector#vector(9619226211e5a241)."setter does not have valid tag"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 166 | make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("invalid_setter_invalid_tag(injectable_type1*)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 167 | }); |
| 168 | } |
| 169 | |
| 170 | void setter_method_testcxx . . $ setter_method_test#::should_throw_when_no_tagcxx . . $ setter_method_test#should_throw_when_no_tag(49f6e7a06ebc5aa8).() |
| 171 | { |
| 172 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_settercxx . . $ injeqt/v1/exception/invalid_setter#>({cxx . . $ std/vector#vector(9619226211e5a241)."setter does not have valid tag"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 173 | make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("invalid_setter_no_tag(injectable_type1*)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 174 | }); |
| 175 | } |
| 176 | |
| 177 | void setter_method_testcxx . . $ setter_method_test#::should_throw_when_signalcxx . . $ setter_method_test#should_throw_when_signal(49f6e7a06ebc5aa8).() |
| 178 | { |
| 179 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_settercxx . . $ injeqt/v1/exception/invalid_setter#>({cxx . . $ std/vector#vector(9619226211e5a241)."setter is signal"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 180 | make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("invalid_setter_signal(injectable_type1*)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 181 | }); |
| 182 | } |
| 183 | |
| 184 | void setter_method_testcxx . . $ setter_method_test#::should_throw_when_constructorcxx . . $ setter_method_test#should_throw_when_constructor(49f6e7a06ebc5aa8).() |
| 185 | { |
| 186 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_settercxx . . $ injeqt/v1/exception/invalid_setter#>({cxx . . $ std/vector#vector(9619226211e5a241)."setter is constructor"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 187 | make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(_known_typescxx . . $ setter_method_test#_known_types., get_constructorcxx . . $ injeqt/v1/get_constructor(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("test_type(injectable_type1*)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 188 | }); |
| 189 | } |
| 190 | |
| 191 | QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(setter_method_test) |
| 192 | #include "setter-method-test.moc"cxx . . $ `<file>/build/test/setter-method-test_autogen/include/setter-method-test.moc`/ |