#include "boost/test/unit_test.hpp"
#include "fhiclcpp/ParameterSet.h"
#include "fhiclcpp/test/boost_test_print_pset.h"
#include <cstddef>
#include <string>
#include <vector>
Go to the source code of this file.
BOOST_AUTO_TEST_CASE |
( |
Local |
| ) |
|
Definition at line 28 of file ParameterSet_t.cc.
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())
void put(std::string const &key)
BOOST_AUTO_TEST_CASE |
( |
DeepInjection |
| ) |
|
Definition at line 40 of file ParameterSet_t.cc.
47 BOOST_TEST(k == orig);
49 BOOST_TEST(orig.get<
int>(
"l.zz") == -2);
T get(std::string const &key) const
void put(std::string const &key)
BOOST_AUTO_TEST_CASE |
( |
DoubleStringMismatchDefaulted |
| ) |
|
Definition at line 52 of file ParameterSet_t.cc.
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");
cet::coded_exception< error, detail::translate > exception
BOOST_AUTO_TEST_CASE |
( |
DoubleStringMismatchNoDefault |
| ) |
|
Definition at line 70 of file ParameterSet_t.cc.
73 pset.get<
double>(
"e");
74 BOOST_FAIL(
"Failed to throw an exception as expected");
80 BOOST_FAIL(
"Wrong exception type thrown");
cet::coded_exception< error, detail::translate > exception
BOOST_AUTO_TEST_CASE |
( |
StringSuccess |
| ) |
|
BOOST_AUTO_TEST_CASE |
( |
NotFound |
| ) |
|
Definition at line 89 of file ParameterSet_t.cc.
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");
cet::coded_exception< error, detail::translate > exception
BOOST_AUTO_TEST_CASE |
( |
DeepVector |
| ) |
|
Definition at line 103 of file ParameterSet_t.cc.
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);
BOOST_AUTO_TEST_CASE |
( |
is_key_to |
| ) |
|
Definition at line 113 of file ParameterSet_t.cc.
124 std::vector<int>
const js{3, 2, 67};
bool is_key_to_sequence(std::string const &key) const
bool is_key_to_table(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)
BOOST_AUTO_TEST_CASE |
( |
put |
| ) |
|
Definition at line 139 of file ParameterSet_t.cc.
143 BOOST_CHECK_NO_THROW(pset.put(
"putTest", sval));
144 BOOST_TEST(pset.get<
std::string>(
"putTest") == sval);
145 BOOST_CHECK_EXCEPTION(
cet::coded_exception< error, detail::translate > exception
BOOST_AUTO_TEST_CASE |
( |
put_or_replace |
| ) |
|
Definition at line 151 of file ParameterSet_t.cc.
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);
BOOST_AUTO_TEST_CASE |
( |
put_or_replace_compatible_nil |
| ) |
|
Definition at line 161 of file ParameterSet_t.cc.
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);
void put(std::string const &key)
BOOST_AUTO_TEST_CASE |
( |
put_or_replace_compatible_atom |
| ) |
|
Definition at line 189 of file ParameterSet_t.cc.
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"));
cet::coded_exception< error, detail::translate > exception
BOOST_AUTO_TEST_CASE |
( |
put_or_replace_compatible_sequence |
| ) |
|
Definition at line 222 of file ParameterSet_t.cc.
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"));
cet::coded_exception< error, detail::translate > exception
BOOST_AUTO_TEST_CASE |
( |
put_or_replace_compatible_table |
| ) |
|
Definition at line 252 of file ParameterSet_t.cc.
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"));
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
BOOST_AUTO_TEST_CASE |
( |
Custom |
| ) |
|
Definition at line 331 of file ParameterSet_t.cc.
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));
unsigned hex(std::string const &from)
Definition at line 318 of file ParameterSet_t.cc.
320 if (from.size() < 3 || from[0] !=
'0' || (from[1] !=
'x' && from[1] !=
'X'))
327 result = 16u * result +
ctox(*it);