10 #define BOOST_TEST_MODULE (return optional values from fcl) 12 #include "boost/test/unit_test.hpp" 27 using namespace fhicl;
33 constexpr
auto tolerance = std::numeric_limits<double>::epsilon();
56 Fixture() : FixtureBase(
"return_optionalValues_from_fcl_t.fcl") {}
61 BOOST_FIXTURE_TEST_SUITE(optionalValues_from_fcl, Fixture)
68 BOOST_TEST(
config().atom(i));
71 BOOST_TEST(
n.empty());
77 auto phys =
config().physics();
78 BOOST_REQUIRE(phys.has_value());
79 auto name = phys->moniker();
80 BOOST_REQUIRE(name.has_value());
81 BOOST_TEST(*name ==
"Johnny");
82 BOOST_TEST(phys->energyCutoff.get<0>() ==
"QGSP");
83 BOOST_TEST(phys->energyCutoff.get<1>() == 14.6,
tolerance);
89 std::vector<int> intList;
90 BOOST_TEST(!
config().list1.hasValue());
91 BOOST_TEST(!
config().list1(intList));
97 std::array<int, 4> intList;
98 auto ref = {1, 2, 4, 8};
99 BOOST_TEST(
config().list2.hasValue());
100 BOOST_TEST(
config().list2(intList));
101 BOOST_TEST(intList == ref, boost::test_tools::per_element{});
107 auto intLists =
config().list3();
108 BOOST_TEST(intLists.has_value());
110 decltype(intLists)::value_type
const ref{
111 {{0, 1}}, {{1, 2}}, {{2, 4}}, {{3, 8}}};
113 for (
auto const& list : *intLists) {
114 BOOST_TEST(list == ref[i], boost::test_tools::per_element{});
122 std::array<Composer, 4> composers;
123 BOOST_TEST(
config().list4(composers));
125 std::array<std::string, 4>
const ref{
126 {
"Mozart",
"Beethoven",
"Brahms",
"Mahler"}};
129 for (
auto const& comp : composers) {
130 BOOST_TEST(comp.composer() == ref[i]);
138 enum composer_t { Mozart, Beethoven, Brahms, Mahler };
140 std::array<Composer, 4> composers;
141 BOOST_TEST(
config().list4(composers));
143 std::array<int, 4>
const symphonyNumbers{{41, 3, 0, 8}};
144 std::array<std::string, 4>
const symphonyMonikers{
145 {
"Jupiter",
"Eroica",
"",
"Symphony for a Thousand"}};
147 for (
auto const& comp : composers) {
149 std::tuple<int, std::string> moniker;
150 if (i != static_cast<composer_t>(Brahms)) {
151 BOOST_TEST(comp.aSymphonyMoniker(moniker));
153 BOOST_TEST(!comp.aSymphonyMoniker(moniker));
156 BOOST_TEST(std::get<int>(moniker) == symphonyNumbers[i]);
157 BOOST_TEST(std::get<std::string>(moniker) == symphonyMonikers[i]);
162 BOOST_AUTO_TEST_SUITE_END()
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE(optAtom_t)