| 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/interface-not-implemented.h>cxx . . $ `<file>/include/injeqt/exception/interface-not-implemented.h`/ |
| 25 | #include <injeqt/exception/invalid-qobject.h>cxx . . $ `<file>/include/injeqt/exception/invalid-qobject.h`/ |
| 26 | #include <injeqt/exception/qobject-type.h>cxx . . $ `<file>/include/injeqt/exception/qobject-type.h`/ |
| 27 | |
| 28 | #include "internal/injector-core.h"cxx . . $ `<file>/src/internal/injector-core.h`/ |
| 29 | #include "internal/provider-ready-configuration.h"cxx . . $ `<file>/src/internal/provider-ready-configuration.h`/ |
| 30 | |
| 31 | #include <QtTest/QtTest> |
| 32 | #include <memory> |
| 33 | |
| 34 | using namespace injeqtcxx . . $ injeqt/::v1; |
| 35 | using namespace injeqtcxx . . $ injeqt/::internal; |
| 36 | |
| 37 | class type_1cxx . . $ type_1# : public QObjectcxx . . $ QObject# |
| 38 | { |
| 39 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 40 | }; |
| 41 | |
| 42 | class type_2cxx . . $ type_2# : public QObjectcxx . . $ QObject# |
| 43 | { |
| 44 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 45 | }; |
| 46 | |
| 47 | class provider_ready_configuration_testcxx . . $ provider_ready_configuration_test# : public QObjectcxx . . $ QObject# |
| 48 | { |
| 49 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 50 | |
| 51 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 52 | void should_accept_qobject_type_and_throw_on_createcxx . . $ provider_ready_configuration_test#should_accept_qobject_type_and_throw_on_create(49f6e7a06ebc5aa8).(); |
| 53 | void should_accept_nullptr_object_and_throw_on_createcxx . . $ provider_ready_configuration_test#should_accept_nullptr_object_and_throw_on_create(49f6e7a06ebc5aa8).(); |
| 54 | void should_accept_not_implemented_interface_and_throw_on_createcxx . . $ provider_ready_configuration_test#should_accept_not_implemented_interface_and_throw_on_create(49f6e7a06ebc5aa8).(); |
| 55 | void should_accept_valid_configurationcxx . . $ provider_ready_configuration_test#should_accept_valid_configuration(49f6e7a06ebc5aa8).(); |
| 56 | |
| 57 | }; |
| 58 | |
| 59 | void provider_ready_configuration_testcxx . . $ provider_ready_configuration_test#::should_accept_qobject_type_and_throw_on_createcxx . . $ provider_ready_configuration_test#should_accept_qobject_type_and_throw_on_create(49f6e7a06ebc5aa8).() |
| 60 | { |
| 61 | auto pc = provider_ready_configurationcxx . . $ injeqt/internal/provider_ready_configuration#provider_ready_configuration(9ea1470f0de69db5).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<QObjectcxx . . $ QObject#>(), nullptr}; |
| 62 | |
| 63 | expectcxx . . $ expect(13411efb8aeb1b14).<exceptioncxx . . $ injeqt/v1/exception/::qobject_typecxx . . $ injeqt/v1/exception/qobject_type#>([cxx . . $ std/function#function(a4b4b0c4acad1616).&](){ |
| 64 | pc.create_providercxx . . $ injeqt/internal/provider_ready_configuration#create_provider(2c251cf15db9f22d).({cxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(49f6e7a06ebc5aa8).}); |
| 65 | }); |
| 66 | } |
| 67 | |
| 68 | void provider_ready_configuration_testcxx . . $ provider_ready_configuration_test#::should_accept_nullptr_object_and_throw_on_createcxx . . $ provider_ready_configuration_test#should_accept_nullptr_object_and_throw_on_create(49f6e7a06ebc5aa8).() |
| 69 | { |
| 70 | auto pc = provider_ready_configurationcxx . . $ injeqt/internal/provider_ready_configuration#provider_ready_configuration(9ea1470f0de69db5).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), nullptr}; |
| 71 | |
| 72 | expectcxx . . $ expect(13411efb8aeb1b14).<exceptioncxx . . $ injeqt/v1/exception/::invalid_qobjectcxx . . $ injeqt/v1/exception/invalid_qobject#>([cxx . . $ std/function#function(a4b4b0c4acad1616).&](){ |
| 73 | pc.create_providercxx . . $ injeqt/internal/provider_ready_configuration#create_provider(2c251cf15db9f22d).({cxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(49f6e7a06ebc5aa8).}); |
| 74 | }); |
| 75 | } |
| 76 | |
| 77 | void provider_ready_configuration_testcxx . . $ provider_ready_configuration_test#::should_accept_not_implemented_interface_and_throw_on_createcxx . . $ provider_ready_configuration_test#should_accept_not_implemented_interface_and_throw_on_create(49f6e7a06ebc5aa8).() |
| 78 | { |
| 79 | auto o = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_2cxx . . $ type_2#>(); |
| 80 | auto pc = provider_ready_configurationcxx . . $ injeqt/internal/provider_ready_configuration#provider_ready_configuration(9ea1470f0de69db5).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), o.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()}; |
| 81 | |
| 82 | expectcxx . . $ expect(13411efb8aeb1b14).<exceptioncxx . . $ injeqt/v1/exception/::interface_not_implementedcxx . . $ injeqt/v1/exception/interface_not_implemented#>([cxx . . $ std/function#function(a4b4b0c4acad1616).&](){ |
| 83 | pc.create_providercxx . . $ injeqt/internal/provider_ready_configuration#create_provider(2c251cf15db9f22d).({cxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(49f6e7a06ebc5aa8).}); |
| 84 | }); |
| 85 | } |
| 86 | |
| 87 | void provider_ready_configuration_testcxx . . $ provider_ready_configuration_test#::should_accept_valid_configurationcxx . . $ provider_ready_configuration_test#should_accept_valid_configuration(49f6e7a06ebc5aa8).() |
| 88 | { |
| 89 | auto i = injector_corecxx . . $ injeqt/internal/injector_core#injector_core(528a6fa5a342ea28).{}; |
| 90 | auto o = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<type_1cxx . . $ type_1#>(); |
| 91 | auto pc = provider_ready_configurationcxx . . $ injeqt/internal/provider_ready_configuration#provider_ready_configuration(9ea1470f0de69db5).{make_typecxx . . $ injeqt/v1/make_type(10a1ed948a80d481).<type_1cxx . . $ type_1#>(), o.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()}; |
| 92 | auto p = pccxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4)..create_providercxx . . $ injeqt/internal/provider_ready_configuration#create_provider(2c251cf15db9f22d).({cxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(49f6e7a06ebc5aa8).}); |
| 93 | |
| 94 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(o.get(), p->provide(i)); |
| 95 | } |
| 96 | |
| 97 | QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(provider_ready_configuration_test) |
| 98 | #include "provider-ready-configuration-test.moc"cxx . . $ `<file>/build/test/provider-ready-configuration-test_autogen/include/provider-ready-configuration-test.moc`/ |