get_via_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (get via converter test)
2 #include "boost/test/unit_test.hpp"
3 
6 
7 #include <string>
8 #include <vector>
9 
10 using namespace fhicl;
11 using namespace std::string_literals;
12 
13 namespace {
14  struct SortedNames {
15  std::vector<std::string> names;
16  };
17 
18  SortedNames
19  to_sorted_names(std::vector<std::string> const& names)
20  {
21  SortedNames result{names};
22  cet::sort_all(result.names);
23  return result;
24  }
25 }
26 
27 BOOST_AUTO_TEST_SUITE(via_test)
28 
30 {
31  auto const config = "number: 5 "
32  "names: ['Esther', 'Julian', 'Bobby']"s;
33  auto const pset = ParameterSet::make(config);
34  BOOST_TEST(pset.get<int>("number") == 5);
35 
36  auto check_value = [](int const& i) { return i == 5; };
37  auto const supplied_5 = pset.get<bool, int>("number", check_value);
38  BOOST_TEST(supplied_5);
39 
40  auto const sorted_names = pset.get("names", to_sorted_names);
41  std::vector const ref{"Bobby"s, "Esther"s, "Julian"s};
42  BOOST_TEST(sorted_names.names == ref);
43 }
44 
45 BOOST_AUTO_TEST_SUITE_END()
static QCString result
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
struct vector vector
void sort_all(RandCont &)
static Config * config
Definition: config.cpp:1054
static std::vector< std::string > const names
Definition: FragmentType.hh:8
BOOST_AUTO_TEST_CASE(via_test)
Definition: get_via_t.cc:29
int bool
Definition: qglobal.h:345
static QCString * s
Definition: config.cpp:1042