Namespaces | Classes | Functions
testing Namespace Reference

LArSoft test utilities. More...

Namespaces

 details
 

Classes

struct  BasicEnvironmentConfiguration
 Class holding a configuration for a test environment. More...
 
struct  BasicGeometryEnvironmentConfiguration
 Class holding a configuration for a test environment. More...
 
class  BasicTesterEnvironment
 Environment for a test. More...
 
struct  BoostCommandLineConfiguration
 Class holding a configuration for a Boost test fixture. More...
 
struct  DefaultSetupProviderClass
 A default implementation for provider setup class. More...
 
class  GeometryTesterEnvironment
 Environment for a geometry test. More...
 
class  NameSelector
 Manages a set of names. More...
 
class  ProviderList
 Container of service providers accessed by type and optional label. More...
 
struct  ProviderSetupClass
 Class to create and set up a new provider. More...
 
struct  ProviderSetupClass< detinfo::DetectorClocksStandard >
 Set up a detinfo::DetectorClocksStandard from a parameter set. More...
 
struct  ProviderSetupClass< detinfo::DetectorPropertiesStandard >
 Set up a detinfo::DetectorPropertiesStandard from a parameter set. More...
 
struct  ProviderSetupClass< detinfo::LArPropertiesStandard >
 Set up a detinfo::LArPropertiesStandard from a parameter set. More...
 
struct  SimpleEnvironmentSetupClass
 Environment helper to set up a service provider. More...
 
struct  SimpleEnvironmentSetupClass < detinfo::DetectorPropertiesStandard, TestEnv >
 Environment setup helper for DetectorPropertiesStandard. More...
 
struct  SimpleEnvironmentSetupClass < lar::example::ShowerCalibrationGaloreFromPID, TestEnv >
 Environment setup helper for ShowerCalibrationGaloreFromPID. More...
 
struct  SimpleEnvironmentSetupClass < lar::example::ShowerCalibrationGaloreScale, TestEnv >
 Environment setup helper for ShowerCalibrationGaloreScale. More...
 
struct  SimpleEnvironmentSetupClass< detinfo::DetectorClocksStandard, TestEnv >
 Environment setup helper for DetectorClocksStandard. More...
 
struct  SimpleEnvironmentSetupClass< detinfo::DetectorPropertiesStandard, TestEnv >
 Environment setup helper for DetectorPropertiesStandard. More...
 
struct  SimpleEnvironmentSetupClass< detinfo::LArPropertiesStandard, TestEnv >
 Environment setup helper for LArPropertiesStandard. More...
 
class  StopWatch
 Provides time interval measurements. More...
 
class  TesterEnvironment
 A test environment with some support for service providers. More...
 
class  TestSharedGlobalResource
 Utility class providing singleton objects to the derived classes. More...
 

Functions

template<>
std::unique_ptr< UnmovableDatumClasssetupProvider< UnmovableDatumClass > ()
 
template<typename Prov , typename... Args>
std::unique_ptr< Prov > setupProvider (Args &&...args)
 Function calling ProviderSetup<>::setup for the specified provider. More...
 
template<typename Prov , typename Interface , typename TestEnv >
Prov * SimpleEnvironmentStandardSetupByName (TestEnv &env, std::string service_name)
 Basic implementation of a environment setup helper. More...
 
template<typename Prov , typename TestEnv >
Prov * SimpleEnvironmentStandardSetupByName (TestEnv &env, std::string service_name)
 
template<typename Prov , typename TestEnv >
Prov * simpleEnvironmentSetup (TestEnv &env)
 Sets up a provider in a specified test environment. More...
 
template<typename CONFIG , typename TESTENV = TesterEnvironment<std::decay_t<CONFIG>>, typename... ARGS>
TESTENV CreateTesterEnvironment (CONFIG &&config, ARGS...other_args)
 Constructs and returns a TesterEnvironment object. More...
 

Detailed Description

LArSoft test utilities.

LArSoft libraries.

Function Documentation

template<typename CONFIG , typename TESTENV = TesterEnvironment<std::decay_t<CONFIG>>, typename... ARGS>
TESTENV testing::CreateTesterEnvironment ( CONFIG &&  config,
ARGS...  other_args 
)

Constructs and returns a TesterEnvironment object.

Template Parameters
CONFIGtype of configuration object (detected from arguments)
TESTENVtype of the tester environment (default: TesterEnvironment)
ARGSpack of types of the remining constructor arguments (optional)
Parameters
configthe configuration object to be used
other_argsthe remaining arguments of the tester constructor

This function creates and returns a tester environment. By default, the tester environment class is TesterEnvironment<CONFIG> and no additional constructor arguments are needed except for special needs. The simplest way to use the function with an already available configuration is:

auto TestEnv = testing::CreateTesterEnvironment(config);

where TestEnv is assigned a specialization of TesterEnvironment.

The template class TESTENV undergoes the following requirement:

  • it must have a constructor using a CONFIG constant reference as first argument

The CONFIG object is subject to no special requirements besides the ones from TESTENV constructor.

Definition at line 985 of file unit_test_base.h.

986  {
987  return TESTENV
988  (std::forward<CONFIG>(config), std::forward<ARGS>(other_args)...);
989  }
static Config * config
Definition: config.cpp:1054
template<typename Prov , typename... Args>
std::unique_ptr<Prov> testing::setupProvider ( Args &&...  args)

Function calling ProviderSetup<>::setup for the specified provider.

Function calling ProviderSetupClass<>::setup for the specified provider.

Template Parameters
Provtype of the provider to be created and set up
Argstypes of arguments to the setup function
Parameters
argsarguments to the setup function
Returns
a pointer to the newly created and set up provider
See also
ProviderSetup

This function provides a function-like interface to the ProviderSetup classes. An example of its use to create an instance of MyProvider is:

auto prov = testing::setupProvider<MyProv>
  (pset.get<fhicl::ParameterSet>("services.MyProviderService"));

if MyProvider provider has a constructor taking a fhicl::ParameterSet.

Definition at line 99 of file ProviderTestHelpers.h.

100  { return ProviderSetupClass<Prov>::setup(std::forward<Args>(args)...); }
static QCString args
Definition: declinfo.cpp:674
static void setup()
Definition: qtextcodec.cpp:110

Definition at line 74 of file ProviderList_test.cc.

74  {
75  BOOST_TEST_MESSAGE
76  (" *** special setup for UnmovableDatumClass *** ");
77  return std::make_unique<UnmovableDatumClass>();
78  } // setupProvider<UnmovableDatumClass>()
template<typename Prov , typename TestEnv >
Prov* testing::simpleEnvironmentSetup ( TestEnv &  env)

Sets up a provider in a specified test environment.

Template Parameters
Provtype of the provider to be set up
TestEnvtype of the environment
Parameters
envthe environment to be set up
Returns
a pointer to the newly set up provider
See also
SimpleEnvironmentSetupClass

This function performs the over-simple set up of a provider. The set up is completely delegated to a SimpleEnvironmentSetupClass class. No such class is provided by default, and service implementers must write their own to allow this one to work.

Definition at line 233 of file ProviderTestHelpers.h.

static void setup()
Definition: qtextcodec.cpp:110
template<typename Prov , typename Interface , typename TestEnv >
Prov* testing::SimpleEnvironmentStandardSetupByName ( TestEnv &  env,
std::string  service_name 
)
inline

Basic implementation of a environment setup helper.

Template Parameters
Provtype of provider being set up
TestEnvtype of environment to set up
Interface(optional) type of interface being implemented
See also
SimpleEnvironmentSetupClass()

The setup() static method of this class implements a simple set up of a service provider Prov in an existing testing environment.

The setup() function:

  • finds a suitable configuration for the service from the environment
  • instantiates and sets up the provider
  • registers the provider and the interface it implements into the environment

The environment is expected to expose an interface equivalent to the one of testing::TesterEnvironment. Use this as:

template <typename TestEnv>
struct SimpleEnvironmentSetupClass<MyProv, TestEnv>
  : public SimpleEnvironmentStandardSetupClass<MyProv, TestEnv, MyInterface>
{
  SimpleEnvironmentSetupClass():
    SimpleEnvironmentStandardSetupClass<MyProvider, TestEnv, MyInterface>("MyService")
    {}
};

to register a provider of type MyProvider that implements a provider interface MyInterface, reading its configuration from the service configuration of "MyService" (that is, services.MyService).

The environment is then expected to react to both MyProvider and MyInterface types:

env.Provider<MyProvider>();
env.Provider<MyInterface>();

both return a pointer to the same provider. If instead MyInterface is void (default), no interface is registered.

Note
This class itself is not suitable for direct use in the test environment, lacking a default constructor. The setup class can inherit from it, as in the example above.

Definition at line 206 of file ProviderTestHelpers.h.

207  {
208  return
209  env.template SetupProviderFromServiceFor<Interface, Prov>(service_name);
210  }
template<typename Prov , typename TestEnv >
Prov* testing::SimpleEnvironmentStandardSetupByName ( TestEnv &  env,
std::string  service_name 
)
inline

Definition at line 215 of file ProviderTestHelpers.h.

216  { return env.template SetupProviderFromService<Prov>(service_name); }