1 #define BOOST_TEST_MODULE (Nested Validation) 3 #include "boost/test/unit_test.hpp" 14 using namespace fhicl;
16 using namespace string_literals;
23 using Default_t =
typename Val_t::default_type;
24 using DefaultElement_t =
typename Val_t::default_type::value_type;
26 explicit NestedConfig(Default_t defaultPars = {})
36 Name(
"nestedWithDef"),
37 NestedConfig::Default_t{
38 NestedConfig::DefaultElement_t{
"T", {
"U",
"V",
"W"}}}};
46 validatedConfig.validate(
ps);
47 return validatedConfig;
51 BOOST_AUTO_TEST_SUITE(Nested_Validation)
55 string const good{
"nested: { pars: [[A, [B]], [X, [Y, Z]]] }"s};
56 std::vector<std::string>
const ref1{
"B"s};
57 std::vector<std::string>
const ref2{
"Y"s,
"Z"s};
58 std::vector<std::string>
const ref3{
"U"s,
"V"s,
"W"s};
60 auto const& pars = validatedConfig().nested().pars();
62 BOOST_TEST(std::get<0>(pars[0]) ==
"A"s);
63 BOOST_TEST(std::get<1>(pars[0]) == ref1);
64 BOOST_TEST(std::get<0>(pars[1]) ==
"X"s);
65 BOOST_TEST(std::get<1>(pars[1]) == ref2);
66 auto const& defaultedPars = validatedConfig().nestedWithDef().pars();
68 BOOST_TEST(std::get<0>(defaultedPars[0]) ==
"T"s);
69 BOOST_TEST(std::get<1>(defaultedPars[0]) == ref3);
74 string const good{
"nested: { pars: [[A, [B]], [X, [Y, Z]]] }\n"s +
75 "nestedWithDef: { pars: [[M, [N, O, P, Q]], [R, [S]]] }"s};
76 std::vector<std::string>
const ref1{
"B"s};
77 std::vector<std::string>
const ref2{
"Y"s,
"Z"s};
78 std::vector<std::string>
const ref3{
"N"s,
"O"s,
"P"s,
"Q"s};
79 std::vector<std::string>
const ref4{
"S"s};
81 auto const& pars = validatedConfig().nested().pars();
83 BOOST_TEST(std::get<0>(pars[0]) ==
"A"s);
84 BOOST_TEST(std::get<1>(pars[0]) == ref1);
85 BOOST_TEST(std::get<0>(pars[1]) ==
"X"s);
86 BOOST_TEST(std::get<1>(pars[1]) == ref2);
87 auto const& defaultedPars = validatedConfig().nestedWithDef().pars();
89 BOOST_TEST(std::get<0>(defaultedPars[0]) ==
"M"s);
90 BOOST_TEST(std::get<1>(defaultedPars[0]) == ref3);
91 BOOST_TEST(std::get<0>(defaultedPars[1]) ==
"R"s);
92 BOOST_TEST(std::get<1>(defaultedPars[1]) == ref4);
97 string const bad{
"nested: { pars: [[A], [X, [Y, Z]]] }"s};
104 string const bad{
"nested: { pars: [[A]] }"s};
111 string const bad{
"nested: { pars: [[A, 7]] }"s};
118 string const bad{
"nested: { pars: [[A, [7]]] }\n"s +
119 "nestedWithDef: { pars: [[A]]}"s};
124 BOOST_AUTO_TEST_SUITE_END()
static ParameterSet make(intermediate_table const &tbl)
fhicl::Table< Config > validateConfig(std::string const &configStr)
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE(GoodTuple1)
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
typename config_impl< T >::type Config
static constexpr double ps
cet::coded_exception< error, detail::translate > exception