key_assembler_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (KeyAssembler test)
2 
3 #include "boost/test/unit_test.hpp"
5 
6 #include <set>
7 #include <string>
8 #include <vector>
9 
10 using namespace fhicl;
11 
12 // KeyAssembler is used by ParameterSet::get_all_keys()
13 
14 BOOST_AUTO_TEST_SUITE(key_assembler_test)
15 
17 {
18  std::string const doc = "p1: {}\n"
19  "p3: {\n"
20  " a: else\n"
21  " b: []\n"
22  " d: [ 11, 12 ]\n"
23  " p4: { e: f }\n"
24  " g: [ {h1: i1}, {h2: i2} ]\n"
25  "}\n";
26  auto const pset = ParameterSet::make(doc);
27  auto const keys = pset.get_all_keys();
28  std::set<std::string> const sorted_keys{keys.begin(), keys.end()};
29 
30  auto const ref = {"p1",
31  "p3",
32  "p3.a",
33  "p3.b",
34  "p3.d",
35  "p3.d[0]",
36  "p3.d[1]",
37  "p3.p4",
38  "p3.p4.e",
39  "p3.g",
40  "p3.g[0]",
41  "p3.g[0].h1",
42  "p3.g[1]",
43  "p3.g[1].h2"};
44  std::set<std::string> const sorted_ref{ref.begin(), ref.end()};
45  BOOST_TEST(sorted_keys == sorted_ref);
46 }
47 
48 BOOST_AUTO_TEST_SUITE_END()
std::string string
Definition: nybbler.cc:12
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
QCString doc
BOOST_AUTO_TEST_CASE(t1)