Unit test for intervals_fhicl.h
header.
More...
#include <boost/test/unit_test.hpp>
#include "lardataalg/Utilities/quantities/spacetime.h"
#include "lardataalg/Utilities/intervals_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 intervals_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/intervals_fhicl.h
Definition in file intervals_fhicl_test.cc.
#define BOOST_TEST_MODULE ( intervals_fhicl_test ) |
BOOST_AUTO_TEST_CASE |
( |
intervals_testcase |
| ) |
|
BOOST_AUTO_TEST_CASE |
( |
points_testcase |
| ) |
|
BOOST_AUTO_TEST_CASE |
( |
quantities_fhicl_testcase |
| ) |
|
void test_makeInterval |
( |
| ) |
|
Definition at line 57 of file intervals_fhicl_test.cc.
59 using namespace std::string_view_literals;
60 using namespace util::quantities::time_literals;
63 auto t = util::quantities::makeInterval<microseconds>(
"-7e1 ms"sv);
64 static_assert(std::is_same_v<decltype(t),
microseconds>);
65 BOOST_TEST(t == -70000_us);
66 BOOST_TEST(t == -70_ms);
68 t = util::quantities::makeInterval<microseconds>(
"7e1ms"sv);
69 BOOST_TEST(t == 70000_us);
70 BOOST_TEST(t == 70_ms);
72 t = util::quantities::makeInterval<microseconds>(
"7e1"sv,
true);
73 BOOST_TEST(t == 70_us);
76 util::quantities::makeInterval<microseconds>(
"7e1"sv),
81 util::quantities::makeInterval<microseconds>(
"7g ms"sv),
86 util::quantities::makeInterval<microseconds>(
"g7 ms"sv),
91 util::quantities::makeInterval<microseconds>(
""sv),
96 util::quantities::makeInterval<microseconds>(
""sv,
true),
microseconds_as<> microseconds
Type of time interval stored in microseconds, in double precision.
microsecond microseconds
Alias for common language habits.
String representing a quantity has no unit.
String representing a quantity has an invalid number.
Definition at line 104 of file intervals_fhicl_test.cc.
106 using namespace std::string_view_literals;
107 using namespace util::quantities::time_literals;
110 auto t = util::quantities::makePoint<microsecond>(
"-7e1 ms"sv);
111 static_assert(std::is_same_v<decltype(t),
microsecond>);
112 BOOST_TEST(t == -70000_us);
113 BOOST_TEST(t == -70_ms);
115 t = util::quantities::makePoint<microsecond>(
"7e1ms"sv);
116 BOOST_TEST(t == 70000_us);
117 BOOST_TEST(t == 70_ms);
119 t = util::quantities::makePoint<microsecond>(
"7e1"sv,
true);
120 BOOST_TEST(t == 70_us);
123 util::quantities::makePoint<microsecond>(
"7e1"sv),
128 util::quantities::makePoint<microsecond>(
"7g ms"sv),
133 util::quantities::makePoint<microsecond>(
"g7 ms"sv),
138 util::quantities::makePoint<microsecond>(
""sv),
143 util::quantities::makePoint<microsecond>(
""sv,
true),
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
microsecond_as<> microsecond
Type of time point stored in microseconds, in double precision.
String representing a quantity has no unit.
String representing a quantity has an invalid number.
Definition at line 151 of file intervals_fhicl_test.cc.
153 using namespace util::quantities::time_literals;
157 fhicl::Atom<util::quantities::points::microsecond> start
160 fhicl::Atom<util::quantities::points::microsecond>
end
163 fhicl::Atom<util::quantities::intervals::microseconds> duration
168 std::string
const configStr {
"start: 2ms duration: 16ms" };
173 auto validatedConfig = validateConfig<Config>(configStr);
174 BOOST_TEST(validatedConfig.start() == expectedStart);
175 BOOST_TEST(validatedConfig.end() == expectedEnd);
176 BOOST_TEST(validatedConfig.duration() == expectedDuration);
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
BEGIN_PROLOG vertical distance to the surface Name
An interval (duration, length, distance) between two quantity points.
Definition at line 182 of file intervals_fhicl_test.cc.
184 using namespace util::quantities::time_literals;
187 fhicl::Atom<util::quantities::points::microsecond> start
190 fhicl::Atom<util::quantities::points::microsecond>
end
193 fhicl::Atom<util::quantities::intervals::microseconds> duration
202 fhicl::ParameterSet pset;
203 pset.put(
"start", expectedStart);
204 pset.put(
"duration", expectedDuration);
206 auto validatedConfig = validateConfig<Config>(pset);
207 BOOST_TEST(validatedConfig.start() == expectedStart);
208 BOOST_TEST(validatedConfig.end() == expectedEnd);
209 BOOST_TEST(validatedConfig.duration() == expectedDuration);
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
BEGIN_PROLOG vertical distance to the surface Name
An interval (duration, length, distance) between two quantity points.
template<typename Config >
Config validateConfig |
( |
fhicl::ParameterSet const & |
pset | ) |
|
Definition at line 30 of file intervals_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 >
Config validateConfig |
( |
std::string const & |
configStr | ) |
|
Definition at line 49 of file intervals_fhicl_test.cc.
50 return validateConfig<Config>(fhicl::ParameterSet::make(configStr));