All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes
AtomicNumber_test.cc File Reference

Tests the AtomicNumber service provider. More...

#include "larexamples/Services/AtomicNumber/Providers/AtomicNumber.h"
#include "larcorealg/TestUtils/unit_test_base.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include <string>

Go to the source code of this file.

Classes

struct  Results_t
 Structure to hold enough information to computed the expected results. More...
 

Functions

unsigned int TestConfiguration (std::string testName, std::string configuration, Results_t const &expected)
 
unsigned int TestDefaultConfiguration ()
 
unsigned int TestXenonConfiguration ()
 
int main (int argc, char **argv)
 

Detailed Description

Tests the AtomicNumber service provider.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)
Date
April 13, 2016
See Also
AtomicNumber.h

The exit code of the test is the number of triggered errors. This text is expected to pass with 0 errors.

This test does not exercise the configuration via file.

Definition in file AtomicNumber_test.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 116 of file AtomicNumber_test.cc.

116  {
117 
118  unsigned int nErrors = 0;
119  nErrors += TestDefaultConfiguration();
120  nErrors += TestXenonConfiguration();
121 
122  return nErrors;
123 } // main()
unsigned int TestXenonConfiguration()
unsigned int TestDefaultConfiguration()
unsigned int TestConfiguration ( std::string  testName,
std::string  configuration,
Results_t const &  expected 
)

Definition at line 48 of file AtomicNumber_test.cc.

49 {
50 
51  //
52  // configuration of the test
53  //
54 
55  // provide a test name and a push a configuration for "AtomicNumberService"
57  config.AddDefaultServiceConfiguration("AtomicNumberService", configuration);
58 
59  // set up a basic testing environment with that configuration
60  auto TesterEnv = testing::CreateTesterEnvironment(config);
61 
62  //
63  // computation of expected values
64  //
65  unsigned int nErrors = 0; // error count
66 
67  // create a new service provider with configuration from the environment
69  (TesterEnv.ServiceParameters("AtomicNumberService"));
70 
71  //
72  // here goes the test...
73  //
74  unsigned int Z = Zprov.Z();
75  if (Z != expected.Z) {
76  mf::LogError("AtomicNumber_test") << testName
77  << ": wrong atomic number: " << Z
78  << " (expected: " << expected.Z << ")";
79  ++nErrors;
80  }
81 
82  //
83  // done!
84  //
85  return nErrors;
86 } // TestConfiguration()
Class holding a configuration for a test environment.
unsigned int Z() const
Returns the atomic number.
Definition: AtomicNumber.h:87
TESTENV CreateTesterEnvironment(CONFIG &&config, ARGS...other_args)
Constructs and returns a TesterEnvironment object.
Provides information about the active material in the TPC.
Definition: AtomicNumber.h:41
unsigned int TestDefaultConfiguration ( )

Definition at line 90 of file AtomicNumber_test.cc.

90  {
91  Results_t expected;
92  expected.Z = 18;
93 
94  return TestConfiguration("TestDefaultConfiguration", "", expected);
95 
96 } // TestDefaultConfiguration()
Structure to hold enough information to computed the expected results.
unsigned int TestConfiguration(std::string testName, std::string configuration, Results_t const &expected)
unsigned int Z
atomic number
unsigned int TestXenonConfiguration ( )

Definition at line 100 of file AtomicNumber_test.cc.

100  {
101 
102  Results_t expected;
103  expected.Z = 54;
104 
105  return TestConfiguration(
106  "TestXenonConfiguration", // test name
107  R"( AtomicNumber: 54 )", // provider configuration
108  expected // expected values
109  );
110 } // TestXenonConfiguration()
111 
Structure to hold enough information to computed the expected results.
unsigned int TestConfiguration(std::string testName, std::string configuration, Results_t const &expected)
unsigned int Z
atomic number