Unit test for quantities_fhicl.h
header.
More...
#include <boost/test/unit_test.hpp>
#include "lardataalg/Utilities/quantities/spacetime.h"
#include "lardataalg/Utilities/quantities_fhicl.h"
#include "test/Utilities/disable_boost_fpc_tolerance.hpp"
#include "fhiclcpp/types/Table.h"
#include "fhiclcpp/types/Atom.h"
#include "fhiclcpp/ParameterSet.h"
#include <type_traits>
Go to the source code of this file.
Unit test for quantities_fhicl.h
header.
- Author
- Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
- Date
- November 27, 2019
- See Also
- lardataalg/Utilities/quantities_fhicl.h
Definition in file quantities_fhicl_test.cc.
#define BOOST_TEST_MODULE ( quantities_fhicl_test ) |
BOOST_AUTO_TEST_CASE |
( |
quantities_testcase |
| ) |
|
BOOST_AUTO_TEST_CASE |
( |
quantities_fhicl_testcase |
| ) |
|
void test_makeQuantity |
( |
| ) |
|
Definition at line 58 of file quantities_fhicl_test.cc.
60 using namespace std::string_view_literals;
61 using namespace util::quantities::time_literals;
64 auto t = util::quantities::makeQuantity<microsecond>(
"-7e1 ms"sv);
65 static_assert(std::is_same_v<decltype(t),
microsecond>);
66 BOOST_TEST(t == -70000_us);
67 BOOST_TEST(t == -70_ms);
69 t = util::quantities::makeQuantity<microsecond>(
"7e1ms"sv);
70 BOOST_TEST(t == 70000_us);
71 BOOST_TEST(t == 70_ms);
73 t = util::quantities::makeQuantity<microsecond>(
"7e1"sv,
true);
74 BOOST_TEST(t == 70_us);
77 util::quantities::makeQuantity<microsecond>(
"7e1"sv),
82 util::quantities::makeQuantity<microsecond>(
"7g ms"sv),
87 util::quantities::makeQuantity<microsecond>(
"g7 ms"sv),
92 util::quantities::makeQuantity<microsecond>(
""sv),
97 util::quantities::makeQuantity<microsecond>(
""sv,
true),
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
String representing a quantity has no unit.
String representing a quantity has an invalid number.
void test_readQuantity |
( |
| ) |
|
Definition at line 105 of file quantities_fhicl_test.cc.
107 using namespace util::quantities::time_literals;
112 fhicl::Atom<util::quantities::microsecond> start
115 fhicl::Atom<util::quantities::microsecond>
end
120 std::string
const configStr {
"end: 16ms" };
124 auto validatedConfig = validateConfig<Config>(configStr)();
125 BOOST_TEST(validatedConfig.start() == expectedStart);
126 BOOST_TEST(validatedConfig.end() == expectedEnd);
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
A value measured in the specified unit.
BEGIN_PROLOG vertical distance to the surface Name
void test_writeQuantity |
( |
| ) |
|
Definition at line 132 of file quantities_fhicl_test.cc.
134 using namespace util::quantities::time_literals;
139 fhicl::Atom<util::quantities::microsecond> start
142 fhicl::Atom<util::quantities::microsecond>
end
147 fhicl::ParameterSet pset;
152 auto validatedConfig = validateConfig<Config>(pset)();
153 BOOST_TEST(validatedConfig.start() == expectedStart);
154 BOOST_TEST(validatedConfig.end() == expectedEnd);
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
A value measured in the specified unit.
BEGIN_PROLOG vertical distance to the surface Name
template<typename Config >
fhicl::Table<Config> validateConfig |
( |
fhicl::ParameterSet const & |
pset | ) |
|
Definition at line 30 of file quantities_fhicl_test.cc.
31 fhicl::Table<Config> validatedConfig {
fhicl::Name(
"validatedConfig") };
33 std::cout << std::string(80,
'-') << std::endl;
35 if (pset.is_empty())
std::cout <<
" <empty>";
36 else std::cout <<
"\n" << pset.to_indented_string();
38 validatedConfig.print_allowed_configuration
39 (
std::cout <<
"===> Expected configuration: ");
42 validatedConfig.validate_ParameterSet(pset);
43 return validatedConfig;
BEGIN_PROLOG vertical distance to the surface Name
BEGIN_PROLOG could also be cout
template<typename Config >
fhicl::Table<Config> validateConfig |
( |
std::string const & |
configStr | ) |
|
Definition at line 49 of file quantities_fhicl_test.cc.
50 auto pset = fhicl::ParameterSet::make(configStr);
51 return validateConfig<Config>(pset);