Classes | Namespaces | Macros | Functions | Variables
ServiceUtil_test.cc File Reference
#include "CoreUtils/UncopiableAndUnmovableClass.h"
#include "CoreUtils/ServiceUtil.h"
#include "canvas/Utilities/Exception.h"
#include "art/Framework/Services/Registry/ServiceScope.h"
#include <cetlib/quiet_unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <type_traits>

Go to the source code of this file.

Classes

struct  MyProvider
 
class  MyService
 
struct  GlobalServicesClass
 
struct  art::detail::ServiceHelper< MyService >
 
struct  art::ServiceHandle< MyService, art::ServiceScope::LEGACY >
 

Namespaces

 gar
 General GArSoft Utilities.
 
 gar::details
 
 art
 
 art::detail
 

Macros

#define BOOST_TEST_MODULE   ( ServiceUtil_test )
 

Functions

 BOOST_AUTO_TEST_CASE (providerFromTest)
 

Variables

GlobalServicesClass GlobalServices
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( ServiceUtil_test )

Definition at line 19 of file ServiceUtil_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( providerFromTest  )

Definition at line 93 of file ServiceUtil_test.cc.

93  {
94 
95  // on the first try, there is no service provider.
96 
97  GlobalServices.myServicePtr = std::make_unique<MyService>();
98  BOOST_CHECK_EXCEPTION(gar::providerFrom<MyService>(), art::Exception,
99  [](art::Exception const& e)
100  { return e.categoryCode() == art::errors::NotFound; }
101  );
102 
103  // now let's create a "real" provider
104  MyProvider prov;
105  GlobalServices.myServicePtr = std::make_unique<MyService>(&prov);
106  BOOST_CHECK_EQUAL(gar::providerFrom<MyService>(), &prov);
107 
108  // that's enough; let's clean up
110 
111 } // BOOST_AUTO_TEST_CASE(larProviderFromTest)
std::unique_ptr< MyService > myServicePtr
const double e
GlobalServicesClass GlobalServices
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66

Variable Documentation

GlobalServicesClass GlobalServices

Definition at line 69 of file ServiceUtil_test.cc.