searchAllowedConfiguration_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (search allowed configuration test)
2 
3 #include "boost/test/unit_test.hpp"
4 
5 #include "fhiclcpp/types/Atom.h"
7 #include "fhiclcpp/types/Table.h"
8 #include "fhiclcpp/types/Tuple.h"
10 
11 #include <string>
12 
13 using namespace fhicl;
14 using namespace fhicl::detail;
15 using namespace std;
17 
18 namespace {
19 
20  struct S {
21  Atom<int> test{Name{"atom"}};
22  Sequence<int, 2> seq{Name{"sequence"}};
23  Tuple<int, double, bool> tuple{Name{"tuple"}};
24  struct U {
25  Atom<int> test{Name{"nested_atom"}};
26  };
27  Tuple<Sequence<int, 2>, bool> tuple2{Name{"tuple2"}};
28  Table<U> table2{Name{"table2"}};
29  };
30 }
31 
32 BOOST_AUTO_TEST_SUITE(searchAllowedConfiguration_test)
33 
35 {
36  Table<S> t{Name{"table"}};
37  BOOST_TEST(supports_key(t, "atom"));
38  BOOST_TEST(!supports_key(t, "table.atom"));
39  BOOST_TEST(!supports_key(t, "table.sequence"));
40  BOOST_TEST(supports_key(t, "sequence"));
41  BOOST_TEST(supports_key(t, "sequence[0]"));
42  BOOST_TEST(!supports_key(t, "[0]"));
43  BOOST_TEST(supports_key(t, "table2"));
44  BOOST_TEST(supports_key(t, "tuple2[0][1]"));
45  BOOST_TEST(supports_key(t, "tuple2[1]"));
46 }
47 
49 {
50  Sequence<Sequence<int, 2>> s{Name{"nestedSequence"}};
51  BOOST_TEST(supports_key(s, "[0]"));
52  BOOST_TEST(supports_key(s, "[0][0]"));
53  BOOST_TEST(supports_key(s, "[0][1]"));
54 }
55 
56 BOOST_AUTO_TEST_SUITE_END()
STL namespace.
BOOST_AUTO_TEST_CASE(table_t)
static bool supports_key(ParameterBase const &pb, std::string const &searched_for_key)
static QCString * s
Definition: config.cpp:1042