keymap_t.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // test types keymap: verify that types 1-13 create the correct key
4 // maps for ParameterSet validation.
5 //
6 // ======================================================================
7 
8 #define BOOST_TEST_MODULE (keymap test)
9 
10 #include "boost/test/unit_test.hpp"
11 
12 #include "KeyMap.h"
13 #include "fhiclcpp/types/Atom.h"
15 #include "fhiclcpp/types/Tuple.h"
16 
17 #include <string>
18 
19 using namespace fhicl;
20 using namespace fhicl::detail;
21 using namespace std;
22 
23 BOOST_AUTO_TEST_SUITE(types_keymap_test)
24 
25 // [1] Atom<T>
27 {
28  auto map = KeyMap::get<Atom<int>>("atom");
29  auto ref = {"atom"};
30  BOOST_TEST(map == ref, boost::test_tools::per_element{});
31 }
32 
33 // [2] Sequence<T>
34 BOOST_AUTO_TEST_CASE(one_sequence_t)
35 {
36  auto map = KeyMap::get<Sequence<int>>("sequence");
37  auto ref = {"sequence", "sequence[0]"};
38  BOOST_TEST(map == ref, boost::test_tools::per_element{});
39 }
40 
41 // [3] Sequence<T,SZ>
42 BOOST_AUTO_TEST_CASE(one_sequence_2_t)
43 {
44  auto map = KeyMap::get<Sequence<int, 2>>("sequence");
45  auto ref = {"sequence", "sequence[0]", "sequence[1]"};
46  BOOST_TEST(map == ref, boost::test_tools::per_element{});
47 }
48 
49 // [4] Tuple<T...>
51 {
52  auto map = KeyMap::get<Tuple<int, double, bool>>("tuple");
53  auto ref = {"tuple", "tuple[0]", "tuple[1]", "tuple[2]"};
54  BOOST_TEST(map == ref, boost::test_tools::per_element{});
55 }
56 
57 // [5] Tuple< Sequence<T>, U...>
58 BOOST_AUTO_TEST_CASE(seq_in_tuple_t)
59 {
60  auto map = KeyMap::get<Tuple<Sequence<int>, double, bool>>("tuple");
61  auto ref = {"tuple", "tuple[0]", "tuple[0][0]", "tuple[1]", "tuple[2]"};
62  BOOST_TEST(map == ref, boost::test_tools::per_element{});
63 }
64 
65 // [6] Tuple< Sequence<T,SZ>, U...>
66 BOOST_AUTO_TEST_CASE(bounded_seq_in_tuple_t)
67 {
68  auto map = KeyMap::get<Tuple<Sequence<int, 2>, double, bool>>("tuple");
69  auto ref = {
70  "tuple", "tuple[0]", "tuple[0][0]", "tuple[0][1]", "tuple[1]", "tuple[2]"};
71  BOOST_TEST(map == ref, boost::test_tools::per_element{});
72 }
73 
74 // [7] Tuple< Tuple<T...>, U...>
75 BOOST_AUTO_TEST_CASE(tuple_in_tuple_t)
76 {
77  auto map = KeyMap::get<Tuple<Tuple<int, float>, double, bool>>("tuple");
78  auto ref = {
79  "tuple", "tuple[0]", "tuple[0][0]", "tuple[0][1]", "tuple[1]", "tuple[2]"};
80  BOOST_TEST(map == ref, boost::test_tools::per_element{});
81 }
82 
83 // [8] Sequence< Tuple<T...> >
84 BOOST_AUTO_TEST_CASE(tuple_in_seq_t)
85 {
86  auto map = KeyMap::get<Sequence<Tuple<int, float>>>("seqtuple");
87  auto ref = {"seqtuple", "seqtuple[0]", "seqtuple[0][0]", "seqtuple[0][1]"};
88  BOOST_TEST(map == ref, boost::test_tools::per_element{});
89 }
90 
91 // [9] Sequence< Tuple<T...>, SZ >
92 BOOST_AUTO_TEST_CASE(tuple_in_seq_2_t)
93 {
94  auto map = KeyMap::get<Sequence<Tuple<int, float>, 2>>("seqtuple");
95  auto ref = {"seqtuple",
96  "seqtuple[0]",
97  "seqtuple[0][0]",
98  "seqtuple[0][1]",
99  "seqtuple[1]",
100  "seqtuple[1][0]",
101  "seqtuple[1][1]"};
102  BOOST_TEST(map == ref, boost::test_tools::per_element{});
103 }
104 
105 // [10] Sequence< Sequence<T> >
106 BOOST_AUTO_TEST_CASE(seq_in_seq_t)
107 {
108  auto map = KeyMap::get<Sequence<Sequence<int>>>("seqseq");
109  auto ref = {"seqseq", "seqseq[0]", "seqseq[0][0]"};
110  BOOST_TEST(map == ref, boost::test_tools::per_element{});
111 }
112 
113 // [11] Sequence< Sequence<T,SZ> >
114 BOOST_AUTO_TEST_CASE(seq_2_in_seq_t)
115 {
116  auto map = KeyMap::get<Sequence<Sequence<int, 2>>>("seqseq");
117  auto ref = {"seqseq", "seqseq[0]", "seqseq[0][0]", "seqseq[0][1]"};
118  BOOST_TEST(map == ref, boost::test_tools::per_element{});
119 }
120 
121 // [12] Sequence< Sequence<T,SZ> >
122 BOOST_AUTO_TEST_CASE(seq_in_seq_2_t)
123 {
124  auto map = KeyMap::get<Sequence<Sequence<int>, 2>>("seqseq");
125  auto ref = {
126  "seqseq", "seqseq[0]", "seqseq[0][0]", "seqseq[1]", "seqseq[1][0]"};
127  BOOST_TEST(map == ref, boost::test_tools::per_element{});
128 }
129 
130 // [13] Sequence< Sequence<T,SZ>, SZ >
131 BOOST_AUTO_TEST_CASE(seq_2_in_seq_2_t)
132 {
133  auto map = KeyMap::get<Sequence<Sequence<int, 2>, 2>>("seqseq");
134  auto ref = {"seqseq",
135  "seqseq[0]",
136  "seqseq[0][0]",
137  "seqseq[0][1]",
138  "seqseq[1]",
139  "seqseq[1][0]",
140  "seqseq[1][1]"};
141  BOOST_TEST(map == ref, boost::test_tools::per_element{});
142 }
143 
144 BOOST_AUTO_TEST_SUITE_END()
STL namespace.
BOOST_AUTO_TEST_CASE(one_atom_t)
Definition: keymap_t.cc:26