keys_to_ignore_t.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Test KeysToIgnore functionality of table
4 //
5 // ======================================================================
6 
7 #define BOOST_TEST_MODULE (keys_to_ignore)
8 
9 #include "boost/test/unit_test.hpp"
10 
11 #include "fhiclcpp/ParameterSet.h"
13 #include "fhiclcpp/types/Table.h"
14 
15 using namespace fhicl;
16 using namespace fhicl::detail;
17 using namespace std;
18 
19 namespace {
20  // Config to test against is empty.
21  struct Config {
22  struct KeysToIgnore {
23  std::set<std::string>
24  operator()()
25  {
26  return {"testing"};
27  }
28  };
29  };
30 
31  struct KeysToIgnore2 {
32  std::set<std::string>
33  operator()()
34  {
35  return {"a", "z"};
36  }
37  };
38 }
39 
40 BOOST_AUTO_TEST_SUITE(keys_to_ignore_t)
41 
43 {
44  std::string const config{"testing: \"it works\""};
45  auto const pset = ParameterSet::make(config);
47  test.print_allowed_configuration(std::cout);
48 }
49 
50 BOOST_AUTO_TEST_CASE(simple_case_2)
51 {
52  std::string const config{"testing: { if: \"it works\" }"};
53  auto const pset = ParameterSet::make(config);
54  auto test = Table<Config>{pset, Config::KeysToIgnore{}()};
55  test.print_allowed_configuration(std::cout);
56 }
57 
58 BOOST_AUTO_TEST_CASE(template_test_1)
59 {
60  auto const& ref = Config::KeysToIgnore{}();
62  BOOST_TEST(test == ref);
63 }
64 
65 BOOST_AUTO_TEST_CASE(template_test_2)
66 {
67  auto const& ref = {"a", "testing", "z"};
68  auto const& test =
70  BOOST_TEST(test == ref, boost::test_tools::per_element{});
71 }
72 
73 BOOST_AUTO_TEST_SUITE_END()
std::string string
Definition: nybbler.cc:12
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
BOOST_AUTO_TEST_CASE(simple_case)
STL namespace.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
static Config * config
Definition: config.cpp:1054