LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
testing Namespace Reference

LArSoft test utilities. More...

Namespaces

 details
 

Classes

struct  BasicEnvironmentConfiguration
 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  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::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...
 

Typedefs

template<typename Prov , typename... Args>
using setupProvider_t = std::function< std::unique_ptr< Prov >(Args...)>
 Generic setup provider function type. More...
 
using StandardStopWatch = StopWatch<>
 A StopWatch with default template arguments. More...
 

Functions

template<typename Prov , typename... Args>
std::unique_ptr< Prov > setupProvider (Args &&...args)
 Function calling ProviderSetupClass<>::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.

Typedef Documentation

template<typename Prov , typename... Args>
using testing::setupProvider_t = typedef std::function<std::unique_ptr<Prov>(Args...)>

Generic setup provider function type.

Definition at line 38 of file ProviderTestHelpers.h.

A StopWatch with default template arguments.

Definition at line 174 of file StopWatch.h.

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 1003 of file unit_test_base.h.

1004  {
1005  return TESTENV
1006  (std::forward<CONFIG>(config), std::forward<ARGS>(other_args)...);
1007  }
template<typename Prov , typename... Args>
std::unique_ptr<Prov> testing::setupProvider ( Args &&...  args)

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 100 of file ProviderTestHelpers.h.

References testing::DefaultSetupProviderClass< Prov >::setup().

101  { return ProviderSetupClass<Prov>::setup(std::forward<Args>(args)...); }
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 234 of file ProviderTestHelpers.h.

235  { return SimpleEnvironmentSetupClass<Prov, TestEnv>::setup(env); }
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 207 of file ProviderTestHelpers.h.

Referenced by testing::SimpleEnvironmentSetupClass < lar::example::ShowerCalibrationGaloreScale, TestEnv >::setup(), testing::SimpleEnvironmentSetupClass < lar::example::ShowerCalibrationGaloreFromPID, TestEnv >::setup(), testing::SimpleEnvironmentSetupClass< detinfo::LArPropertiesStandard, TestEnv >::setup(), and testing::SimpleEnvironmentSetupClass< detinfo::DetectorClocksStandard, TestEnv >::setup().

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

Definition at line 216 of file ProviderTestHelpers.h.

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