1 #define BOOST_TEST_MODULE (ParameterSet test) 3 #include "boost/test/unit_test.hpp" 11 using namespace fhicl;
33 BOOST_TEST(j == orig);
34 BOOST_TEST(orig.get<
int>(
"y") == -1);
35 BOOST_TEST(pset.get<std::vector<int>>(
"m")[0] == -1);
36 for (
auto n : pset.get_names())
47 BOOST_TEST(k == orig);
49 BOOST_TEST(orig.get<
int>(
"l.zz") == -2);
55 BOOST_TEST(pset.get_if_present(
"e", s));
56 BOOST_TEST(s ==
"rain");
59 pset.get<
double>(
"e", 2.0);
60 BOOST_FAIL(
"Failed to throw an exception as expected");
66 BOOST_FAIL(
"Wrong exception type thrown");
73 pset.get<
double>(
"e");
74 BOOST_FAIL(
"Failed to throw an exception as expected");
80 BOOST_FAIL(
"Wrong exception type thrown");
92 pset.get<
double>(
"zz");
93 BOOST_FAIL(
"Failed to throw an exception as expected");
96 BOOST_TEST(e.categoryCode() ==
cant_find);
99 BOOST_FAIL(
"Wrong exception type thrown");
105 using vv_t = std::vector<std::vector<uint32_t>>;
107 BOOST_CHECK_NO_THROW(vv = pset.get<vv_t>(
"vv"));
108 BOOST_TEST(vv.front().back() == 3u);
109 BOOST_TEST(vv.back().front() == 2u);
110 BOOST_TEST(vv.back().back() == 4u);
124 std::vector<int>
const js{3, 2, 67};
143 BOOST_CHECK_NO_THROW(pset.put(
"putTest", sval));
144 BOOST_TEST(pset.get<
std::string>(
"putTest") == sval);
145 BOOST_CHECK_EXCEPTION(
155 BOOST_CHECK_NO_THROW(pset.put_or_replace(
"putOrReplaceTest", sval));
156 BOOST_TEST(pset.get<
std::string>(
"putOrReplaceTest") == sval);
157 BOOST_CHECK_NO_THROW(pset.put_or_replace(
"putOrReplaceTest", sval2));
158 BOOST_TEST(pset.get<
std::string>(
"putOrReplaceTest") == sval2);
164 std::vector<int> vval{1, 2, 3, 5, 7, 11, 13};
166 psval.
put(
"junk", 3);
167 BOOST_CHECK_NO_THROW(
168 pset.put_or_replace(
"putOrReplaceCompatibleTest"));
169 BOOST_CHECK_NO_THROW(
170 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", sval));
171 BOOST_TEST(pset.get<
std::string>(
"putOrReplaceCompatibleTest") == sval);
172 BOOST_CHECK_NO_THROW(
173 pset.put_or_replace(
"putOrReplaceCompatibleTest"));
174 BOOST_CHECK_NO_THROW(
175 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", vval.front()));
176 BOOST_TEST(pset.get<
int>(
"putOrReplaceCompatibleTest") == vval.front());
177 BOOST_CHECK_NO_THROW(
178 pset.put_or_replace(
"putOrReplaceCompatibleTest"));
179 BOOST_CHECK_NO_THROW(
180 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", vval));
181 BOOST_TEST(pset.get<decltype(vval)>(
"putOrReplaceCompatibleTest") == vval);
182 BOOST_CHECK_NO_THROW(
183 pset.put_or_replace(
"putOrReplaceCompatibleTest"));
184 BOOST_CHECK_NO_THROW(
185 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", psval));
186 BOOST_TEST(pset.get<decltype(psval)>(
"putOrReplaceCompatibleTest") == psval);
193 std::vector<int> vval{1, 2, 3, 5, 7, 11, 13};
195 BOOST_CHECK_NO_THROW(
196 pset.put_or_replace(
"putOrReplaceCompatibleTest"));
197 BOOST_CHECK_NO_THROW(
198 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", sval));
199 BOOST_TEST(pset.get<
std::string>(
"putOrReplaceCompatibleTest") == sval);
200 BOOST_CHECK_NO_THROW(
201 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", sval2));
202 BOOST_TEST(pset.get<
std::string>(
"putOrReplaceCompatibleTest") == sval2);
203 BOOST_CHECK_EXCEPTION(
204 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", vval),
209 BOOST_CHECK_EXCEPTION(
210 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", psval),
215 BOOST_CHECK_NO_THROW(
216 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", vval.front()));
217 BOOST_TEST(pset.get<
int>(
"putOrReplaceCompatibleTest") == vval.front());
218 BOOST_CHECK_NO_THROW(
219 pset.put_or_replace(
"putOrReplaceCompatibleTest"));
225 std::vector<int> vval{1, 2, 3, 5, 7, 11, 13};
226 std::vector<int> vval2{4, 6, 8, 9, 10, 12, 14};
228 BOOST_CHECK_NO_THROW(
229 pset.put_or_replace(
"putOrReplaceCompatibleTest"));
230 BOOST_CHECK_NO_THROW(
231 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", vval));
232 BOOST_TEST(pset.get<decltype(vval)>(
"putOrReplaceCompatibleTest") == vval);
233 BOOST_CHECK_NO_THROW(
234 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", vval2));
235 BOOST_TEST(pset.get<decltype(vval)>(
"putOrReplaceCompatibleTest") == vval2);
236 BOOST_CHECK_EXCEPTION(
237 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", sval),
242 BOOST_CHECK_EXCEPTION(
243 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", psval),
248 BOOST_CHECK_NO_THROW(
249 pset.put_or_replace(
"putOrReplaceCompatibleTest"));
255 std::vector<int> vval{1, 2, 3, 5, 7, 11, 13};
257 psval.
put(
"junk", 3);
258 psval.
put(
"ethel", 3);
259 BOOST_CHECK_NO_THROW(
260 pset.put_or_replace(
"putOrReplaceCompatibleTest"));
261 BOOST_CHECK_NO_THROW(
262 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", psval));
263 BOOST_TEST(pset.get<decltype(psval)>(
"putOrReplaceCompatibleTest") == psval);
264 BOOST_CHECK_NO_THROW(
265 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", psval2));
266 BOOST_TEST(pset.get<decltype(psval)>(
"putOrReplaceCompatibleTest") == psval2);
267 BOOST_CHECK_EXCEPTION(
268 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", sval),
273 BOOST_CHECK_EXCEPTION(
274 pset.put_or_replace_compatible(
"putOrReplaceCompatibleTest", vval),
279 BOOST_CHECK_NO_THROW(
280 pset.put_or_replace(
"putOrReplaceCompatibleTest"));
313 throw std::string(
"ctox(): invalid hex character");
320 if (from.size() < 3 || from[0] !=
'0' || (from[1] !=
'x' && from[1] !=
'X'))
327 result = 16u * result +
ctox(*it);
335 BOOST_TEST(pset.get_if_present(
"n", u,
hex));
336 BOOST_TEST(pset.get<
unsigned>(
"n",
hex) == u);
337 BOOST_TEST(pset.get<
unsigned>(
"n",
hex), (((1u) * 16u + 2u) * 16u + 3u));
341 BOOST_AUTO_TEST_SUITE_END()
unsigned hex(std::string const &from)
static ParameterSet make(intermediate_table const &tbl)
BOOST_AUTO_TEST_CASE(Local)
bool is_key_to_sequence(std::string const &key) const
bool is_key_to_table(std::string const &key) const
T get(std::string const &key) const
static constexpr double ps
bool is_key_to_atom(std::string const &key) const
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception