Macros | Functions
keymap_table_t.cc File Reference
#include "boost/test/unit_test.hpp"
#include "KeyMap.h"
#include "fhiclcpp/types/Atom.h"
#include "fhiclcpp/types/Sequence.h"
#include "fhiclcpp/types/Table.h"
#include "fhiclcpp/types/TableFragment.h"
#include "fhiclcpp/types/Tuple.h"
#include <string>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   (keymap test with tables)
 

Functions

 BOOST_AUTO_TEST_CASE (table_t)
 
 BOOST_AUTO_TEST_CASE (table_in_seq_t)
 
 BOOST_AUTO_TEST_CASE (table_in_seq_2_t)
 
 BOOST_AUTO_TEST_CASE (table_in_tuple_t)
 
 BOOST_AUTO_TEST_CASE (seqtable_in_tuple_t)
 
 BOOST_AUTO_TEST_CASE (seqtable_2_in_tuple_t)
 
 BOOST_AUTO_TEST_CASE (tuptable_in_seq_t)
 
 BOOST_AUTO_TEST_CASE (tuptable_in_seq_2_t)
 
 BOOST_AUTO_TEST_CASE (tablefragment_t)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (keymap test with tables)

Definition at line 10 of file keymap_table_t.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( table_t  )

Definition at line 38 of file keymap_table_t.cc.

39 {
40  auto map = KeyMap::get<Table<S>>("table");
41  auto ref = {"table",
42  "table.atom",
43  "table.sequence",
44  "table.sequence[0]",
45  "table.sequence[1]",
46  "table.tuple",
47  "table.tuple[0]",
48  "table.tuple[1]",
49  "table.tuple[2]"};
50  BOOST_TEST(map == ref, boost::test_tools::per_element{});
51 }
BOOST_AUTO_TEST_CASE ( table_in_seq_t  )

Definition at line 54 of file keymap_table_t.cc.

55 {
56  auto map = KeyMap::get<Sequence<Table<S>>>("seqtable");
57 
58  auto ref = {"seqtable",
59  "seqtable[0]",
60  "seqtable[0].atom",
61  "seqtable[0].sequence",
62  "seqtable[0].sequence[0]",
63  "seqtable[0].sequence[1]",
64  "seqtable[0].tuple",
65  "seqtable[0].tuple[0]",
66  "seqtable[0].tuple[1]",
67  "seqtable[0].tuple[2]"};
68  BOOST_TEST(map == ref, boost::test_tools::per_element{});
69 }
BOOST_AUTO_TEST_CASE ( table_in_seq_2_t  )

Definition at line 72 of file keymap_table_t.cc.

73 {
74  auto map = KeyMap::get<Sequence<Table<S>, 2>>("seqtable");
75  auto ref = {"seqtable",
76  "seqtable[0]",
77  "seqtable[0].atom",
78  "seqtable[0].sequence",
79  "seqtable[0].sequence[0]",
80  "seqtable[0].sequence[1]",
81  "seqtable[0].tuple",
82  "seqtable[0].tuple[0]",
83  "seqtable[0].tuple[1]",
84  "seqtable[0].tuple[2]",
85  "seqtable[1]",
86  "seqtable[1].atom",
87  "seqtable[1].sequence",
88  "seqtable[1].sequence[0]",
89  "seqtable[1].sequence[1]",
90  "seqtable[1].tuple",
91  "seqtable[1].tuple[0]",
92  "seqtable[1].tuple[1]",
93  "seqtable[1].tuple[2]"};
94  BOOST_TEST(map == ref, boost::test_tools::per_element{});
95 }
BOOST_AUTO_TEST_CASE ( table_in_tuple_t  )

Definition at line 98 of file keymap_table_t.cc.

99 {
100  auto map = KeyMap::get<Tuple<Table<S>, int, double>>("tuptable");
101  auto ref = {"tuptable",
102  "tuptable[0]",
103  "tuptable[0].atom",
104  "tuptable[0].sequence",
105  "tuptable[0].sequence[0]",
106  "tuptable[0].sequence[1]",
107  "tuptable[0].tuple",
108  "tuptable[0].tuple[0]",
109  "tuptable[0].tuple[1]",
110  "tuptable[0].tuple[2]",
111  "tuptable[1]",
112  "tuptable[2]"};
113  BOOST_TEST(map == ref, boost::test_tools::per_element{});
114 }
BOOST_AUTO_TEST_CASE ( seqtable_in_tuple_t  )

Definition at line 117 of file keymap_table_t.cc.

118 {
119  auto map = KeyMap::get<Tuple<Sequence<Table<S>>, int, double>>("seqtuptable");
120  auto ref = {"seqtuptable",
121  "seqtuptable[0]",
122  "seqtuptable[0][0]",
123  "seqtuptable[0][0].atom",
124  "seqtuptable[0][0].sequence",
125  "seqtuptable[0][0].sequence[0]",
126  "seqtuptable[0][0].sequence[1]",
127  "seqtuptable[0][0].tuple",
128  "seqtuptable[0][0].tuple[0]",
129  "seqtuptable[0][0].tuple[1]",
130  "seqtuptable[0][0].tuple[2]",
131  "seqtuptable[1]",
132  "seqtuptable[2]"};
133  BOOST_TEST(map == ref, boost::test_tools::per_element{});
134 }
BOOST_AUTO_TEST_CASE ( seqtable_2_in_tuple_t  )

Definition at line 137 of file keymap_table_t.cc.

138 {
139  auto map =
140  KeyMap::get<Tuple<Sequence<Table<S>, 2>, int, double>>("seqtuptable");
141  auto ref = {"seqtuptable",
142  "seqtuptable[0]",
143  "seqtuptable[0][0]",
144  "seqtuptable[0][0].atom",
145  "seqtuptable[0][0].sequence",
146  "seqtuptable[0][0].sequence[0]",
147  "seqtuptable[0][0].sequence[1]",
148  "seqtuptable[0][0].tuple",
149  "seqtuptable[0][0].tuple[0]",
150  "seqtuptable[0][0].tuple[1]",
151  "seqtuptable[0][0].tuple[2]",
152  "seqtuptable[0][1]",
153  "seqtuptable[0][1].atom",
154  "seqtuptable[0][1].sequence",
155  "seqtuptable[0][1].sequence[0]",
156  "seqtuptable[0][1].sequence[1]",
157  "seqtuptable[0][1].tuple",
158  "seqtuptable[0][1].tuple[0]",
159  "seqtuptable[0][1].tuple[1]",
160  "seqtuptable[0][1].tuple[2]",
161  "seqtuptable[1]",
162  "seqtuptable[2]"};
163  BOOST_TEST(map == ref, boost::test_tools::per_element{});
164 }
BOOST_AUTO_TEST_CASE ( tuptable_in_seq_t  )

Definition at line 167 of file keymap_table_t.cc.

168 {
169  auto map = KeyMap::get<Sequence<Tuple<Table<S>, int, double>>>("tupseqtable");
170  auto ref = {"tupseqtable",
171  "tupseqtable[0]",
172  "tupseqtable[0][0]",
173  "tupseqtable[0][0].atom",
174  "tupseqtable[0][0].sequence",
175  "tupseqtable[0][0].sequence[0]",
176  "tupseqtable[0][0].sequence[1]",
177  "tupseqtable[0][0].tuple",
178  "tupseqtable[0][0].tuple[0]",
179  "tupseqtable[0][0].tuple[1]",
180  "tupseqtable[0][0].tuple[2]",
181  "tupseqtable[0][1]",
182  "tupseqtable[0][2]"};
183  BOOST_TEST(map == ref, boost::test_tools::per_element{});
184 }
BOOST_AUTO_TEST_CASE ( tuptable_in_seq_2_t  )

Definition at line 187 of file keymap_table_t.cc.

188 {
189  auto map =
190  KeyMap::get<Sequence<Tuple<Table<S>, int, double>, 2>>("tupseqtable");
191  auto ref = {"tupseqtable",
192  "tupseqtable[0]",
193  "tupseqtable[0][0]",
194  "tupseqtable[0][0].atom",
195  "tupseqtable[0][0].sequence",
196  "tupseqtable[0][0].sequence[0]",
197  "tupseqtable[0][0].sequence[1]",
198  "tupseqtable[0][0].tuple",
199  "tupseqtable[0][0].tuple[0]",
200  "tupseqtable[0][0].tuple[1]",
201  "tupseqtable[0][0].tuple[2]",
202  "tupseqtable[0][1]",
203  "tupseqtable[0][2]",
204  "tupseqtable[1]",
205  "tupseqtable[1][0]",
206  "tupseqtable[1][0].atom",
207  "tupseqtable[1][0].sequence",
208  "tupseqtable[1][0].sequence[0]",
209  "tupseqtable[1][0].sequence[1]",
210  "tupseqtable[1][0].tuple",
211  "tupseqtable[1][0].tuple[0]",
212  "tupseqtable[1][0].tuple[1]",
213  "tupseqtable[1][0].tuple[2]",
214  "tupseqtable[1][1]",
215  "tupseqtable[1][2]"};
216  BOOST_TEST(map == ref, boost::test_tools::per_element{});
217 }
BOOST_AUTO_TEST_CASE ( tablefragment_t  )

Definition at line 220 of file keymap_table_t.cc.

221 {
223  BOOST_TEST(tf().test.key() == "atom");
224 
225  {
226  KeyMap km;
227  km.walk_over(tf().seq);
228  auto mapseq = km.result();
229  auto refseq = {"sequence", "sequence[0]", "sequence[1]"};
230  BOOST_TEST(mapseq == refseq, boost::test_tools::per_element{});
231  }
232 
233  {
234  KeyMap km;
235  km.walk_over(tf().tuple);
236  auto maptup = km.result();
237  auto reftup = {"tuple", "tuple[0]", "tuple[1]", "tuple[2]"};
238  BOOST_TEST(maptup == reftup, boost::test_tools::per_element{});
239  }
240 }
static constexpr double km
Definition: Units.h:64
void walk_over(tt::maybe_const_t< ParameterBase, C > &)
auto const & result() const
Definition: KeyMap.h:16