13 const std::string& label)
19 std::cerr << label <<
" mismatch" << std::endl;
20 std::cerr <<
" expected:";
22 std::cerr <<
" [" << value <<
"]";
24 std::cerr << std::endl;
25 std::cerr <<
" actual:";
26 for (
const auto& value : actual) {
27 std::cerr <<
" [" << value <<
"]";
29 std::cerr << std::endl;
33void expect_true(
bool condition,
const std::string& message)
36 std::cerr << message << std::endl;
50 h.
set_line(
"detector",
"ccc ddd eee");
64 const auto lines = h.
get_lines(
"detector");
65 std::ostringstream output;
67 expect_equal(keys, expected_keys,
"matching_keys");
68 expect_equal(lines, expected_lines,
"get_lines");
70 expect_true(
write(h, output),
"write(Head, ostream) returned false");
72 const std::string rendered = output.str();
73 expect_true(rendered.find(
"seed: 42") != std::string::npos,
74 "Rendered header does not contain the seed line");
75 expect_true(rendered.find(
"detector_2: ccc ddd eee") != std::string::npos,
76 "Rendered header does not contain the final detector line");
78 std::cout <<
"OK" << std::endl;
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
const Waveform< float > expected
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
std::vector< std::string > matching_keys(const std::string &tag) const
In case of duplicate keys, they are internally stored in the map with a suffix "_n".
std::string set_line(std::string tag, std::string line, bool ensure_unique=true)
Set data with the given tag.
std::vector< std::string > get_lines(const std::string &tag) const
Get all data compatible with the given key.