44{
46
50 h.
set_line(
"detector",
"ccc ddd eee");
51
53 "detector",
54 "detector_1",
55 "detector_2"
56 };
58 "aaa bbb",
59 "ccc ddd",
60 "ccc ddd eee"
61 };
62
64 const auto lines = h.
get_lines(
"detector");
65 std::ostringstream output;
66
67 expect_equal(keys, expected_keys, "matching_keys");
68 expect_equal(lines, expected_lines, "get_lines");
69
70 expect_true(
write(h, output),
"write(Head, ostream) returned false");
71
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");
77
78 std::cout << "OK" << std::endl;
79 return 0;
80}
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
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.