11 #define BOOST_TEST_MODULE ( intervals_fhicl_test )
12 #include <boost/test/unit_test.hpp>
20 #include "fhiclcpp/types/Table.h"
21 #include "fhiclcpp/types/Atom.h"
22 #include "fhiclcpp/ParameterSet.h"
25 #include <type_traits>
29 template <
typename Config>
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();
48 template <
typename Config>
50 return validateConfig<Config>(fhicl::ParameterSet::make(configStr));
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),
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),
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);
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);
215 BOOST_AUTO_TEST_SUITE(intervals_fhicl_test)
233 BOOST_AUTO_TEST_SUITE_END()
microseconds_as<> microseconds
Type of time interval stored in microseconds, in double precision.
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
fhicl::Table< Config > validateConfig(std::string const &configStr)
microsecond microseconds
Alias for common language habits.
microsecond_as<> microsecond
Type of time point stored in microseconds, in double precision.
auto end(FixedBins< T, C > const &) noexcept
BEGIN_PROLOG vertical distance to the surface Name
An interval (duration, length, distance) between two quantity points.
Utilities to read interval and point quantity FHiCL configuration.
String representing a quantity has no unit.
Dimensioned variables representing space or time quantities.
String representing a quantity has an invalid number.
BEGIN_PROLOG could also be cout