| 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/empty-type.h>cxx . . $ `<file>/include/injeqt/exception/empty-type.h`/ |
| 25 | #include <injeqt/exception/interface-not-implemented.h>cxx . . $ `<file>/include/injeqt/exception/interface-not-implemented.h`/ |
| 26 | #include <injeqt/exception/invalid-qobject.h>cxx . . $ `<file>/include/injeqt/exception/invalid-qobject.h`/ |
| 27 | #include <injeqt/exception/qobject-type.h>cxx . . $ `<file>/include/injeqt/exception/qobject-type.h`/ |
| 28 | |
| 29 | #include "internal/implementation.h"cxx . . $ `<file>/src/internal/implementation.h`/ |
| 30 | |
| 31 | #include <QtTest/QtTest> |
| 32 | |
| 33 | using namespace injeqtcxx . . $ injeqt/::internal; |
| 34 | using namespace injeqtcxx . . $ injeqt/::v1; |
| 35 | |
| 36 | class type_1cxx . . $ type_1# : public QObjectcxx . . $ QObject# |
| 37 | { |
| 38 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 39 | }; |
| 40 | |
| 41 | class type_2cxx . . $ type_2# : public QObjectcxx . . $ QObject# |
| 42 | { |
| 43 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 44 | }; |
| 45 | |
| 46 | class type_1_subtype_1cxx . . $ type_1_subtype_1# : public type_1cxx . . $ type_1# |
| 47 | { |
| 48 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 49 | }; |
| 50 | |
| 51 | class type_1_subtype_1_subtype_1cxx . . $ type_1_subtype_1_subtype_1# : public type_1_subtype_1cxx . . $ type_1_subtype_1# |
| 52 | { |
| 53 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 54 | }; |
| 55 | |
| 56 | class implementation_testcxx . . $ implementation_test# : public QObjectcxx . . $ QObject# |
| 57 | { |
| 58 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 59 | |
| 60 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 61 | void should_throw_when_type_is_emptycxx . . $ implementation_test#should_throw_when_type_is_empty(49f6e7a06ebc5aa8).(); |
| 62 | void should_throw_when_type_is_qobjectcxx . . $ implementation_test#should_throw_when_type_is_qobject(49f6e7a06ebc5aa8).(); |
| 63 | void should_throw_when_object_is_nullcxx . . $ implementation_test#should_throw_when_object_is_null(49f6e7a06ebc5aa8).(); |
| 64 | void should_accept_object_of_typecxx . . $ implementation_test#should_accept_object_of_type(49f6e7a06ebc5aa8).(); |
| 65 | void should_accept_object_of_sub_typecxx . . $ implementation_test#should_accept_object_of_sub_type(49f6e7a06ebc5aa8).(); |
| 66 | void should_accept_object_of_sub_sub_typecxx . . $ implementation_test#should_accept_object_of_sub_sub_type(49f6e7a06ebc5aa8).(); |
| 67 | void should_not_accept_object_of_super_typecxx . . $ implementation_test#should_not_accept_object_of_super_type(49f6e7a06ebc5aa8).(); |
| 68 | void should_not_accept_object_of_other_typecxx . . $ implementation_test#should_not_accept_object_of_other_type(49f6e7a06ebc5aa8).(); |
| 69 | void should_properly_comparecxx . . $ implementation_test#should_properly_compare(49f6e7a06ebc5aa8).(); |
| 70 | |
| 71 | }; |
| 72 | |
| 73 | void implementation_testcxx . . $ implementation_test#::should_throw_when_type_is_emptycxx . . $ implementation_test#should_throw_when_type_is_empty(49f6e7a06ebc5aa8).() |
| 74 | { |
| 75 | auto object = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_1cxx . . $ type_1#>(); |
| 76 | expectcxx . . $ expect(13411efb8aeb1b14).<exceptioncxx . . $ injeqt/v1/exception/::empty_typecxx . . $ injeqt/v1/exception/empty_type#>([cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 77 | make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(typecxx . . $ injeqt/v1/type#type(49f6e7a06ebc5aa8).{}, object.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 78 | }); |
| 79 | } |
| 80 | |
| 81 | void implementation_testcxx . . $ implementation_test#::should_throw_when_type_is_qobjectcxx . . $ implementation_test#should_throw_when_type_is_qobject(49f6e7a06ebc5aa8).() |
| 82 | { |
| 83 | auto object = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_1cxx . . $ type_1#>(); |
| 84 | expectcxx . . $ expect(13411efb8aeb1b14).<exceptioncxx . . $ injeqt/v1/exception/::qobject_typecxx . . $ injeqt/v1/exception/qobject_type#>([cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 85 | make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<QObjectcxx . . $ QObject#>(), object.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 86 | }); |
| 87 | } |
| 88 | |
| 89 | void implementation_testcxx . . $ implementation_test#::should_throw_when_object_is_nullcxx . . $ implementation_test#should_throw_when_object_is_null(49f6e7a06ebc5aa8).() |
| 90 | { |
| 91 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_qobjectcxx . . $ injeqt/v1/exception/invalid_qobject#>({cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 92 | make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), nullptr); |
| 93 | }); |
| 94 | } |
| 95 | |
| 96 | void implementation_testcxx . . $ implementation_test#::should_accept_object_of_typecxx . . $ implementation_test#should_accept_object_of_type(49f6e7a06ebc5aa8).() |
| 97 | { |
| 98 | auto object = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_1cxx . . $ type_1#>(); |
| 99 | auto i = make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), object.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 100 | |
| 101 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(make_type<type_1>(), i.interface_type()); |
| 102 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(object.get(), i.object()); |
| 103 | } |
| 104 | |
| 105 | void implementation_testcxx . . $ implementation_test#::should_accept_object_of_sub_typecxx . . $ implementation_test#should_accept_object_of_sub_type(49f6e7a06ebc5aa8).() |
| 106 | { |
| 107 | auto object = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_1_subtype_1cxx . . $ type_1_subtype_1#>(); |
| 108 | auto i = make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), object.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 109 | |
| 110 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(make_type<type_1>(), i.interface_type()); |
| 111 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(object.get(), i.object()); |
| 112 | } |
| 113 | |
| 114 | void implementation_testcxx . . $ implementation_test#::should_accept_object_of_sub_sub_typecxx . . $ implementation_test#should_accept_object_of_sub_sub_type(49f6e7a06ebc5aa8).() |
| 115 | { |
| 116 | auto object = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_1_subtype_1_subtype_1cxx . . $ type_1_subtype_1_subtype_1#>(); |
| 117 | auto i = make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), object.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 118 | |
| 119 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(make_type<type_1>(), i.interface_type()); |
| 120 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(object.get(), i.object()); |
| 121 | } |
| 122 | |
| 123 | void implementation_testcxx . . $ implementation_test#::should_not_accept_object_of_super_typecxx . . $ implementation_test#should_not_accept_object_of_super_type(49f6e7a06ebc5aa8).() |
| 124 | { |
| 125 | auto object = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_1cxx . . $ type_1#>(); |
| 126 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::interface_not_implementedcxx . . $ injeqt/v1/exception/interface_not_implemented#>({cxx . . $ std/vector#vector(9619226211e5a241)."type_1", "type_1_subtype_1_subtype_1"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 127 | make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1_subtype_1_subtype_1cxx . . $ type_1_subtype_1_subtype_1#>(), object.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 128 | }); |
| 129 | } |
| 130 | |
| 131 | void implementation_testcxx . . $ implementation_test#::should_not_accept_object_of_other_typecxx . . $ implementation_test#should_not_accept_object_of_other_type(49f6e7a06ebc5aa8).() |
| 132 | { |
| 133 | auto object = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_1cxx . . $ type_1#>(); |
| 134 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::interface_not_implementedcxx . . $ injeqt/v1/exception/interface_not_implemented#>({cxx . . $ std/vector#vector(9619226211e5a241)."type_1", "type_2"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 135 | make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_2cxx . . $ type_2#>(), object.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 136 | }); |
| 137 | } |
| 138 | |
| 139 | void implementation_testcxx . . $ implementation_test#::should_properly_comparecxx . . $ implementation_test#should_properly_compare(49f6e7a06ebc5aa8).() |
| 140 | { |
| 141 | auto o1a = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_1cxx . . $ type_1#>(); |
| 142 | auto o1b = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_1cxx . . $ type_1#>(); |
| 143 | auto o2 = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_2cxx . . $ type_2#>(); |
| 144 | |
| 145 | auto i1a = make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), o1a.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 146 | auto i1b = make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), o1a.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 147 | auto i2a = make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), o1b.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 148 | auto i2b = make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), o1b.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 149 | auto i3a = make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_2cxx . . $ type_2#>(), o2.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 150 | auto i3b = make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_2cxx . . $ type_2#>(), o2.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 151 | |
| 152 | test_comparecxx . . $ injeqt/v1/test_compare(1f10a48923f889af).<implementationcxx . . $ injeqt/internal/implementation#>({cxx . . $ std/vector#vector(9619226211e5a241).{i1a, i1b}, {i2a, i2b}, {i3a, i3b}}); |
| 153 | } |
| 154 | |
| 155 | QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(implementation_test) |
| 156 | #include "implementation-test.moc"cxx . . $ `<file>/build/test/implementation-test_autogen/include/implementation-test.moc`/ |