19 #define BOOST_TEST_MODULE ( ServiceUtil_test ) 30 #include <boost/test/unit_test.hpp> 42 template <
typename Prov
ider>
44 Provider* prov =
nullptr;
63 template struct ServiceProviderRequirementsChecker<MyProvider>;
65 template struct ServiceRequirementsChecker<MyService>;
77 std::unique_ptr<MyService> myServicePtr;
84 template <
typename Service>
98 struct ServiceHelper<MyService> {
156 GlobalServices.
myServicePtr = std::make_unique<MyService>();
157 BOOST_CHECK_EXCEPTION(lar::providerFrom<MyService>(),
art::Exception,
164 GlobalServices.
myServicePtr = std::make_unique<MyService>(&prov);
165 BOOST_TEST(lar::providerFrom<MyService>() == &prov);
179 GlobalServices.
myServicePtr = std::make_unique<MyService>(&prov);
183 auto provPack1 = lar::providersFrom<MyService>();
184 BOOST_TEST(provPack1.get<
MyProvider>() == &prov);
185 BOOST_CHECK_EXCEPTION(lar::providersFrom<MyOtherService>(),
art::Exception,
189 BOOST_CHECK_EXCEPTION(
190 (lar::providersFrom<MyService, MyOtherService>()),
art::Exception,
200 = std::make_unique<YetAnotherService>(&yaprov);
203 = lar::providersFrom<MyService, MyOtherService, YetAnotherService>();
206 BOOST_TEST(lar::providerFrom<MyService>() == &prov);
207 BOOST_TEST(lar::providerFrom<MyOtherService>() == &oprov);
208 BOOST_TEST(lar::providerFrom<YetAnotherService>() == &yaprov);
BOOST_AUTO_TEST_CASE(providerFromTest)
An empty class that can't be copied nor moved.
std::unique_ptr< MyService > myServicePtr
Defines classes that can't be copied nor moved.
const std::string instance
std::unique_ptr< MyOtherService > myOtherServicePtr
std::unique_ptr< YetAnotherService > yetAnotherServicePtr
provider_type const * provider() const
Service & operator*() const
MyServiceTemplate(Provider *ptr=nullptr)
ProviderPack< Providers... > makeProviderPack(Providers const *...providers)
Function to create a ProviderPack from the function arguments.
GlobalServicesClass GlobalServices
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
LArSoft-specific namespace.
Service * operator->() const