optionalDelegatedParameter_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (optionalDelegatedParameter test)
2 
3 #include "boost/test/unit_test.hpp"
4 
5 #include "FixtureBase.h"
7 
8 using namespace fhicl;
9 
10 namespace {
11  struct S {
12  OptionalDelegatedParameter nda{Name("nested_optional_delegated_atom")};
13  OptionalDelegatedParameter ndt{Name("pset")};
14  };
15 
16  struct Config {
17  OptionalDelegatedParameter dt{Name("optional_delegated_table")};
18  OptionalDelegatedParameter ds{Name("optional_delegated_sequence")};
19  Table<S> nested{Name("s")};
20  };
21 
22  struct Fixture : fhiclcpp_types::FixtureBase<Config> {
23  Fixture() : FixtureBase("optionalDelegatedParameter_t.fcl") {}
24  };
25 }
26 
27 BOOST_FIXTURE_TEST_SUITE(optionalDelegatedParameter_t, Fixture)
28 
29 BOOST_AUTO_TEST_CASE(optional_delegation_check)
30 {
32  BOOST_TEST(config().dt.get_if_present(ps));
33 
34  std::vector<int> nums;
35  BOOST_TEST(config().ds.get_if_present(nums));
36 
37  std::string greeting;
38  BOOST_TEST(config().nested().nda.get_if_present(greeting));
39  BOOST_TEST(greeting == "Hello, Billy");
40 
41  ps = ParameterSet{};
42  BOOST_TEST(not config().nested().ndt.get_if_present(ps));
43  BOOST_TEST(ps.is_empty());
44 }
45 
46 BOOST_AUTO_TEST_SUITE_END()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
static Config * config
Definition: config.cpp:1054
BOOST_AUTO_TEST_CASE(optional_delegation_check)
static constexpr double ps
Definition: Units.h:99
bool is_empty() const