| 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/ambiguous-types.h>cxx . . $ `<file>/include/injeqt/exception/ambiguous-types.h`/ |
| 25 | #include <injeqt/exception/unresolvable-dependencies.h>cxx . . $ `<file>/include/injeqt/exception/unresolvable-dependencies.h`/ |
| 26 | #include <injeqt/type.h>cxx . . $ `<file>/include/injeqt/type.h`/ |
| 27 | |
| 28 | #include "internal/types-model.h"cxx . . $ `<file>/src/internal/types-model.h`/ |
| 29 | |
| 30 | #include <QtTest/QtTest> |
| 31 | |
| 32 | using namespace injeqtcxx . . $ injeqt/::internal; |
| 33 | using namespace injeqtcxx . . $ injeqt/::v1; |
| 34 | |
| 35 | class type_1cxx . . $ type_1# : public QObjectcxx . . $ QObject# |
| 36 | { |
| 37 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 38 | }; |
| 39 | |
| 40 | class type_1_subtype_1cxx . . $ type_1_subtype_1# : public type_1cxx . . $ type_1# |
| 41 | { |
| 42 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 43 | }; |
| 44 | |
| 45 | class type_1_subtype_2cxx . . $ type_1_subtype_2# : public type_1cxx . . $ type_1# |
| 46 | { |
| 47 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 48 | }; |
| 49 | |
| 50 | class type_1_subtype_2_subtype_1cxx . . $ type_1_subtype_2_subtype_1# : public type_1_subtype_2cxx . . $ type_1_subtype_2# |
| 51 | { |
| 52 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 53 | }; |
| 54 | |
| 55 | class type_1_subtype_3cxx . . $ type_1_subtype_3# : public type_1cxx . . $ type_1# |
| 56 | { |
| 57 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 58 | |
| 59 | public slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 60 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void set_type_1_subtype_1cxx . . $ type_1_subtype_3#set_type_1_subtype_1(72615fbd6fce6ca8).(type_1_subtype_1cxx . . $ type_1_subtype_1# *) {} |
| 61 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void set_type_1_subtype_2cxx . . $ type_1_subtype_3#set_type_1_subtype_2(be21a9fd69ceed24).(type_1_subtype_2cxx . . $ type_1_subtype_2# *) {} |
| 62 | |
| 63 | }; |
| 64 | |
| 65 | class types_model_testcxx . . $ types_model_test# : public QObjectcxx . . $ QObject# |
| 66 | { |
| 67 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 68 | |
| 69 | public: |
| 70 | types_model_testcxx . . $ types_model_test#types_model_test(49f6e7a06ebc5aa8).(); |
| 71 | |
| 72 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 73 | void should_create_empty_types_modelcxx . . $ types_model_test#should_create_empty_types_model(49f6e7a06ebc5aa8).(); |
| 74 | void should_create_one_type_types_modelcxx . . $ types_model_test#should_create_one_type_types_model(49f6e7a06ebc5aa8).(); |
| 75 | void should_throw_when_one_type_duplicatedcxx . . $ types_model_test#should_throw_when_one_type_duplicated(49f6e7a06ebc5aa8).(); |
| 76 | void should_throw_when_type_and_subtype_passedcxx . . $ types_model_test#should_throw_when_type_and_subtype_passed(49f6e7a06ebc5aa8).(); |
| 77 | void should_create_with_common_supertypecxx . . $ types_model_test#should_create_with_common_supertype(49f6e7a06ebc5aa8).(); |
| 78 | void should_create_with_dependenciescxx . . $ types_model_test#should_create_with_dependencies(49f6e7a06ebc5aa8).(); |
| 79 | void should_throw_when_unresolvable_dependencycxx . . $ types_model_test#should_throw_when_unresolvable_dependency(49f6e7a06ebc5aa8).(); |
| 80 | |
| 81 | private: |
| 82 | types_by_namecxx . . $ injeqt/internal/types_by_name# known_typescxx . . $ types_model_test#known_types.; |
| 83 | typecxx . . $ injeqt/v1/type# type_1_typecxx . . $ types_model_test#type_1_type.; |
| 84 | typecxx . . $ injeqt/v1/type# type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type.; |
| 85 | typecxx . . $ injeqt/v1/type# type_1_subtype_2_typecxx . . $ types_model_test#type_1_subtype_2_type.; |
| 86 | typecxx . . $ injeqt/v1/type# type_1_subtype_2_subtype_1_typecxx . . $ types_model_test#type_1_subtype_2_subtype_1_type.; |
| 87 | typecxx . . $ injeqt/v1/type# type_1_subtype_3_typecxx . . $ types_model_test#type_1_subtype_3_type.; |
| 88 | |
| 89 | }; |
| 90 | |
| 91 | types_model_testcxx . . $ types_model_test#::types_model_testcxx . . $ types_model_test#types_model_test(49f6e7a06ebc5aa8).() : |
| 92 | type_1_typecxx . . $ types_model_test#type_1_type.{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>()}, |
| 93 | type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type.{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_1cxx . . $ type_1_subtype_1#>()}, |
| 94 | type_1_subtype_2_typecxx . . $ types_model_test#type_1_subtype_2_type.{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_2cxx . . $ type_1_subtype_2#>()}, |
| 95 | type_1_subtype_2_subtype_1_typecxx . . $ types_model_test#type_1_subtype_2_subtype_1_type.{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_2_subtype_1cxx . . $ type_1_subtype_2_subtype_1#>()}, |
| 96 | type_1_subtype_3_typecxx . . $ types_model_test#type_1_subtype_3_type.{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_3cxx . . $ type_1_subtype_3#>()} |
| 97 | { |
| 98 | known_typescxx . . $ types_model_test#known_types. =cxx . . $ injeqt/internal/sorted_unique_vector#`operator=`(21c4a51877e06114). types_by_namecxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(26e8deb829554aa).{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{ |
| 99 | make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), |
| 100 | make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_1cxx . . $ type_1_subtype_1#>(), |
| 101 | make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_2cxx . . $ type_1_subtype_2#>(), |
| 102 | make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_2_subtype_1cxx . . $ type_1_subtype_2_subtype_1#>(), |
| 103 | make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_3cxx . . $ type_1_subtype_3#>() |
| 104 | }}; |
| 105 | } |
| 106 | |
| 107 | void types_model_testcxx . . $ types_model_test#::should_create_empty_types_modelcxx . . $ types_model_test#should_create_empty_types_model(49f6e7a06ebc5aa8).() |
| 108 | { |
| 109 | auto empty_1 = types_modelcxx . . $ injeqt/internal/types_model#types_model(49f6e7a06ebc5aa8).{}; |
| 110 | auto empty_2 = make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(known_typescxx . . $ types_model_test#known_types., stdcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{}, stdcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{}); |
| 111 | |
| 112 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(empty_1.available_types(), implemented_by_mapping{}); |
| 113 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(empty_1.mapped_dependencies(), types_dependencies{}); |
| 114 | } |
| 115 | |
| 116 | void types_model_testcxx . . $ types_model_test#::should_create_one_type_types_modelcxx . . $ types_model_test#should_create_one_type_types_model(49f6e7a06ebc5aa8).() |
| 117 | { |
| 118 | auto m1 = make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(known_typescxx . . $ types_model_test#known_types., {cxx . . $ std/vector#vector(9619226211e5a241).type_1_typecxx . . $ types_model_test#type_1_type.}, {cxx . . $ std/vector#vector(9619226211e5a241).type_1_typecxx . . $ types_model_test#type_1_type.}); |
| 119 | |
| 120 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(m1.available_types(), (implemented_by_mapping |
| 121 | { |
| 122 | implemented_by{type_1_type, type_1_type} |
| 123 | })); |
| 124 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(m1.mapped_dependencies(), (types_dependencies |
| 125 | { |
| 126 | make_type_dependencies(known_types, type_1_type) |
| 127 | })); |
| 128 | |
| 129 | auto m2 = make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(known_typescxx . . $ types_model_test#known_types., {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type.}, {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type.}); |
| 130 | |
| 131 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(m2.available_types(), (implemented_by_mapping |
| 132 | { |
| 133 | implemented_by{type_1_type, type_1_subtype_1_type}, |
| 134 | implemented_by{type_1_subtype_1_type, type_1_subtype_1_type} |
| 135 | })); |
| 136 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(m2.mapped_dependencies(), (types_dependencies |
| 137 | { |
| 138 | make_type_dependencies(known_types, type_1_subtype_1_type) |
| 139 | })); |
| 140 | } |
| 141 | |
| 142 | void types_model_testcxx . . $ types_model_test#::should_throw_when_one_type_duplicatedcxx . . $ types_model_test#should_throw_when_one_type_duplicated(49f6e7a06ebc5aa8).() |
| 143 | { |
| 144 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::ambiguous_typescxx . . $ injeqt/v1/exception/ambiguous_types#>({cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 145 | make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(known_typescxx . . $ types_model_test#known_types., {cxx . . $ std/vector#vector(9619226211e5a241).type_1_typecxx . . $ types_model_test#type_1_type., type_1_typecxx . . $ types_model_test#type_1_type.}, {cxx . . $ std/vector#vector(9619226211e5a241).type_1_typecxx . . $ types_model_test#type_1_type., type_1_typecxx . . $ types_model_test#type_1_type.}); |
| 146 | }); |
| 147 | } |
| 148 | |
| 149 | void types_model_testcxx . . $ types_model_test#::should_throw_when_type_and_subtype_passedcxx . . $ types_model_test#should_throw_when_type_and_subtype_passed(49f6e7a06ebc5aa8).() |
| 150 | { |
| 151 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::ambiguous_typescxx . . $ injeqt/v1/exception/ambiguous_types#>({cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 152 | make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(known_typescxx . . $ types_model_test#known_types., {cxx . . $ std/vector#vector(9619226211e5a241).type_1_typecxx . . $ types_model_test#type_1_type., type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type.}, {cxx . . $ std/vector#vector(9619226211e5a241).type_1_typecxx . . $ types_model_test#type_1_type., type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type.}); |
| 153 | }); |
| 154 | |
| 155 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::ambiguous_typescxx . . $ injeqt/v1/exception/ambiguous_types#>({cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 156 | make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(known_typescxx . . $ types_model_test#known_types., {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type., type_1_typecxx . . $ types_model_test#type_1_type.}, {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type., type_1_typecxx . . $ types_model_test#type_1_type.}); |
| 157 | }); |
| 158 | } |
| 159 | |
| 160 | void types_model_testcxx . . $ types_model_test#::should_create_with_common_supertypecxx . . $ types_model_test#should_create_with_common_supertype(49f6e7a06ebc5aa8).() |
| 161 | { |
| 162 | auto m = make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(known_typescxx . . $ types_model_test#known_types., {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type., type_1_subtype_2_typecxx . . $ types_model_test#type_1_subtype_2_type.}, {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type., type_1_subtype_2_typecxx . . $ types_model_test#type_1_subtype_2_type.}); |
| 163 | |
| 164 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(m.available_types(), (implemented_by_mapping |
| 165 | { |
| 166 | implemented_by{type_1_subtype_1_type, type_1_subtype_1_type}, |
| 167 | implemented_by{type_1_subtype_2_type, type_1_subtype_2_type} |
| 168 | })); |
| 169 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(m.mapped_dependencies(), (types_dependencies |
| 170 | { |
| 171 | make_type_dependencies(known_types, type_1_subtype_1_type), |
| 172 | make_type_dependencies(known_types, type_1_subtype_2_type) |
| 173 | })); |
| 174 | } |
| 175 | |
| 176 | void types_model_testcxx . . $ types_model_test#::should_create_with_dependenciescxx . . $ types_model_test#should_create_with_dependencies(49f6e7a06ebc5aa8).() |
| 177 | { |
| 178 | auto m1 = make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(known_typescxx . . $ types_model_test#known_types., |
| 179 | {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type., type_1_subtype_2_typecxx . . $ types_model_test#type_1_subtype_2_type., type_1_subtype_3_typecxx . . $ types_model_test#type_1_subtype_3_type.}, |
| 180 | {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type., type_1_subtype_2_typecxx . . $ types_model_test#type_1_subtype_2_type., type_1_subtype_3_typecxx . . $ types_model_test#type_1_subtype_3_type.}); |
| 181 | |
| 182 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(m1.available_types(), (implemented_by_mapping |
| 183 | { |
| 184 | implemented_by{type_1_subtype_1_type, type_1_subtype_1_type}, |
| 185 | implemented_by{type_1_subtype_2_type, type_1_subtype_2_type}, |
| 186 | implemented_by{type_1_subtype_3_type, type_1_subtype_3_type} |
| 187 | })); |
| 188 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(m1.mapped_dependencies(), (types_dependencies |
| 189 | { |
| 190 | make_type_dependencies(known_types, type_1_subtype_1_type), |
| 191 | make_type_dependencies(known_types, type_1_subtype_2_type), |
| 192 | make_type_dependencies(known_types, type_1_subtype_3_type) |
| 193 | })); |
| 194 | |
| 195 | auto m2 = make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(known_typescxx . . $ types_model_test#known_types., |
| 196 | {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type., type_1_subtype_2_subtype_1_typecxx . . $ types_model_test#type_1_subtype_2_subtype_1_type., type_1_subtype_3_typecxx . . $ types_model_test#type_1_subtype_3_type.}, |
| 197 | {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_1_typecxx . . $ types_model_test#type_1_subtype_1_type., type_1_subtype_2_subtype_1_typecxx . . $ types_model_test#type_1_subtype_2_subtype_1_type., type_1_subtype_3_typecxx . . $ types_model_test#type_1_subtype_3_type.}); |
| 198 | |
| 199 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(m2.available_types(), (implemented_by_mapping |
| 200 | { |
| 201 | implemented_by{type_1_subtype_1_type, type_1_subtype_1_type}, |
| 202 | implemented_by{type_1_subtype_2_type, type_1_subtype_2_subtype_1_type}, |
| 203 | implemented_by{type_1_subtype_2_subtype_1_type, type_1_subtype_2_subtype_1_type}, |
| 204 | implemented_by{type_1_subtype_3_type, type_1_subtype_3_type} |
| 205 | })); |
| 206 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(m2.mapped_dependencies(), (types_dependencies |
| 207 | { |
| 208 | make_type_dependencies(known_types, type_1_subtype_1_type), |
| 209 | make_type_dependencies(known_types, type_1_subtype_2_subtype_1_type), |
| 210 | make_type_dependencies(known_types, type_1_subtype_3_type) |
| 211 | })); |
| 212 | } |
| 213 | |
| 214 | void types_model_testcxx . . $ types_model_test#::should_throw_when_unresolvable_dependencycxx . . $ types_model_test#should_throw_when_unresolvable_dependency(49f6e7a06ebc5aa8).() |
| 215 | { |
| 216 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::unresolvable_dependenciescxx . . $ injeqt/v1/exception/unresolvable_dependencies#>({cxx . . $ std/vector#vector(9619226211e5a241)."set_type_1_subtype_1", "set_type_1_subtype_2"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 217 | make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(known_typescxx . . $ types_model_test#known_types., {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_3_typecxx . . $ types_model_test#type_1_subtype_3_type.}, {cxx . . $ std/vector#vector(9619226211e5a241).type_1_subtype_3_typecxx . . $ types_model_test#type_1_subtype_3_type.}); |
| 218 | }); |
| 219 | } |
| 220 | |
| 221 | QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(types_model_test) |
| 222 | #include "types-model-test.moc"cxx . . $ `<file>/build/test/types-model-test_autogen/include/types-model-test.moc`/ |