delegatedParameter_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (delegatedParameter test)
2 
3 #include "boost/test/unit_test.hpp"
4 
5 #include "FixtureBase.h"
8 
9 #include <string>
10 
11 using namespace fhicl;
12 using namespace std::string_literals;
13 
14 namespace {
15  struct S {
16  DelegatedParameter da{Name("delegated_atom")};
17  OptionalDelegatedParameter oda{Name("optional_delegated_atom")};
18  };
19 
20  struct Config {
21  DelegatedParameter dt{Name("delegated_table")};
22  DelegatedParameter ds{Name("delegated_sequence")};
23  Table<S> nested{Name("s")};
24  };
25 
26  struct Fixture : fhiclcpp_types::FixtureBase<Config> {
27  Fixture() : FixtureBase("delegatedParameter_t.fcl") {}
28  };
29 
30  void
31  receive_PSet(ParameterSet const& pset)
32  {
33  std::set<std::string> const ref{
34  "everything", "everything[0]", "you", "imagine"};
35  auto const& test = pset.get_all_keys();
36  BOOST_TEST(test == ref, boost::test_tools::per_element{});
37  }
38 
39  void
40  receive_vector(std::vector<int> const& v)
41  {
42  std::vector const ref{1, 2, 3};
43  BOOST_TEST(v == ref);
44  }
45 
46  void
47  receive_int(int const i)
48  {
49  BOOST_TEST(i == 3);
50  }
51 }
52 
53 BOOST_FIXTURE_TEST_SUITE(delegatedParameter_t, Fixture)
54 
55 BOOST_AUTO_TEST_CASE(delegation_check)
56 {
57  receive_PSet(config().dt.get<ParameterSet>());
58  receive_vector(config().ds.get<std::vector<int>>());
59  receive_int(config().nested().da.get<int>());
60  std::string maybe_string;
61  config().nested().oda.get_if_present(maybe_string);
62  BOOST_TEST("Hello, Billy"s == maybe_string);
63 }
64 
65 BOOST_AUTO_TEST_SUITE_END()
std::string string
Definition: nybbler.cc:12
struct vector vector
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
static Config * config
Definition: config.cpp:1054
std::vector< std::string > get_all_keys() const
BOOST_AUTO_TEST_CASE(delegation_check)
static QCString * s
Definition: config.cpp:1042