7 #define BOOST_TEST_MODULE (document test) 9 #include "boost/test/unit_test.hpp" 15 using namespace fhicl;
18 BOOST_AUTO_TEST_SUITE(shimmeddocument_test)
45 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 3);
47 BOOST_TEST(fhicl_table.exists(
"a"));
48 auto const&
a = fhicl_table.find(
"a");
49 BOOST_TEST(a.in_prolog ==
true);
50 BOOST_TEST(std::any_cast<std::string>(a.value) ==
"1");
52 BOOST_TEST(fhicl_table.exists(
"b"));
53 auto const&
b = fhicl_table.find(
"b");
54 BOOST_TEST(b.in_prolog ==
true);
55 BOOST_TEST(std::any_cast<std::string>(b.value) ==
"\"bb\"");
57 BOOST_TEST(fhicl_table.exists(
"c"));
58 auto const&
c = fhicl_table.find(
"c");
59 BOOST_TEST(c.in_prolog ==
false);
60 BOOST_TEST(std::any_cast<std::string>(c.value) ==
"3");
77 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 2);
79 auto it = fhicl_table.begin();
81 BOOST_TEST(it->second.in_prolog ==
true);
82 BOOST_TEST(it->first ==
"z");
83 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"1.1");
87 BOOST_TEST(it->second.in_prolog ==
true);
88 BOOST_TEST(it->first ==
"a");
89 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"aa\"");
104 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 2);
106 auto it = fhicl_table.begin();
108 BOOST_TEST(it->second.in_prolog ==
false);
109 BOOST_TEST(it->first ==
"z");
110 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"1.1");
114 BOOST_TEST(it->second.in_prolog ==
false);
115 BOOST_TEST(it->first ==
"a");
116 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"aa\"");
135 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 4);
137 auto it = fhicl_table.begin();
138 BOOST_TEST(it->second.in_prolog ==
true);
139 BOOST_TEST(it->first ==
"z");
140 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"1.1");
143 BOOST_TEST(it->second.in_prolog ==
true);
144 BOOST_TEST(it->first ==
"a");
145 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"aa\"");
148 BOOST_TEST(it->second.in_prolog ==
false);
149 BOOST_TEST(it->first ==
"x");
150 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"xx\"");
153 BOOST_TEST(it->second.in_prolog ==
false);
154 BOOST_TEST(it->first ==
"c");
155 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"cc\"");
171 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 3);
173 BOOST_TEST(fhicl_table.exists(
"mm"));
174 auto const&
mm = fhicl_table.find(
"mm");
175 BOOST_TEST(mm.in_prolog ==
false);
176 BOOST_TEST(std::any_cast<std::string>(mm.value) ==
"\"@local::ss\"");
194 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 3);
196 BOOST_TEST(fhicl_table.exists(
"mm"));
197 auto const&
mm = fhicl_table.find(
"mm");
198 BOOST_TEST(mm.in_prolog ==
false);
199 BOOST_TEST(std::any_cast<std::string>(mm.value) ==
"\"@local::ss\"");
211 " tt: { a:1 b: 2 }\n" 213 "placeholder_table_001:@table::tt\n";
216 BOOST_TEST(fhicl_table.exists(
"placeholder_table_001"));
218 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 2);
220 auto const&
tt = fhicl_table.find(
"placeholder_table_001");
221 BOOST_TEST(
tt.in_prolog ==
false);
222 BOOST_TEST(std::any_cast<std::string>(
tt.value) ==
"\"@table::tt\"");
234 " tt: { a:1 b: 2 }\n" 235 " placeholder_table_001:@table::tt\n" 239 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 2);
241 BOOST_TEST(fhicl_table.exists(
"placeholder_table_001"));
243 auto const&
tt = fhicl_table.find(
"placeholder_table_001");
244 BOOST_TEST(tt.in_prolog ==
true);
245 BOOST_TEST(std::any_cast<std::string>(tt.value) ==
"\"@table::tt\"");
260 "sss:[@sequence::ss, 34, 35]\n";
263 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 3);
265 auto const& sss = fhicl_table.find(
"sss");
266 BOOST_TEST(sss.in_prolog ==
false);
268 BOOST_TEST(std::any_cast<std::string>(seq.at(0).value) ==
269 "\"@sequence::ss\"");
283 "sss:[@sequence::ss, 34, 35]\n" 286 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 3);
288 auto const& sss = fhicl_table.find(
"sss");
289 BOOST_TEST(sss.in_prolog ==
true);
291 BOOST_TEST(std::any_cast<std::string>(seq.at(0).value) ==
292 "\"@sequence::ss\"");
309 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 4);
311 BOOST_TEST(fhicl_table.exists(
"mm"));
313 auto const&
mm = fhicl_table.find(
"mm");
314 BOOST_TEST(mm.in_prolog ==
false);
315 BOOST_TEST(std::any_cast<std::string>(mm.value) ==
"\"@local::ss\"");
317 auto it = fhicl_table.begin();
318 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 1);
319 BOOST_TEST(it->second.in_prolog ==
false);
320 BOOST_TEST(it->first ==
"mm");
321 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"@erase\"");
339 BOOST_TEST(fhicl_table.exists(
"mm"));
340 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 3);
342 auto const&
mm = fhicl_table.find(
"mm");
343 BOOST_TEST(
mm.in_prolog ==
false);
346 auto const&
a = fhicl_table.find(
"a");
347 BOOST_TEST(a.in_prolog ==
true);
361 " h: { hh: {hhh:hhhh } } }\n" 365 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 3);
367 BOOST_TEST(fhicl_table.exists(
"h.hh.hhh"));
369 auto const&
h = fhicl_table.find(
"h.hh.hhh");
370 BOOST_TEST(h.in_prolog ==
false);
371 BOOST_TEST(std::any_cast<std::string>(h.value) ==
"\"h\"");
386 "c.cc.ccc:@local::c\n";
388 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 4);
390 BOOST_TEST(fhicl_table.exists(
"c"));
392 auto const&
c = fhicl_table.find(
"c");
393 BOOST_TEST(c.in_prolog ==
true);
394 BOOST_TEST(std::any_cast<std::string>(c.value) ==
"\"c1\"");
396 auto it = fhicl_table.begin();
397 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 2);
398 BOOST_TEST(it->second.in_prolog ==
false);
399 BOOST_TEST(it->first ==
"h.hh.hhh");
400 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"h\"");
402 it = fhicl_table.begin();
403 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 1);
404 BOOST_TEST(it->second.in_prolog ==
false);
405 BOOST_TEST(it->first ==
"c.cc.ccc");
406 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"@local::c\"");
421 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 4);
423 BOOST_TEST(fhicl_table.exists(
"c"));
425 auto const&
c = fhicl_table.find(
"c");
426 BOOST_TEST(c.in_prolog ==
false);
427 BOOST_TEST(std::any_cast<std::string>(c.value) ==
"\"c1\"");
429 auto it = fhicl_table.begin();
430 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 3);
431 BOOST_TEST(it->second.in_prolog ==
false);
432 BOOST_TEST(it->first ==
"c");
433 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"c2\"");
435 it = fhicl_table.begin();
436 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 2);
437 BOOST_TEST(it->second.in_prolog ==
false);
438 BOOST_TEST(it->first ==
"h");
439 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"h1\"");
441 it = fhicl_table.begin();
442 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 1);
443 BOOST_TEST(it->second.in_prolog ==
false);
444 BOOST_TEST(it->first ==
"c");
445 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"c3\"");
460 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 4);
462 BOOST_TEST(fhicl_table.exists(
"c.cc"));
464 auto const&
c = fhicl_table.find(
"c.cc");
465 BOOST_TEST(c.in_prolog ==
false);
466 BOOST_TEST(std::any_cast<std::string>(c.value) ==
"\"c1\"");
468 auto it = fhicl_table.begin();
469 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 3);
470 BOOST_TEST(it->second.in_prolog ==
false);
471 BOOST_TEST(it->first ==
"c.cc");
472 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"c2\"");
474 it = fhicl_table.begin();
475 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 2);
476 BOOST_TEST(it->second.in_prolog ==
false);
477 BOOST_TEST(it->first ==
"h");
478 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"h1\"");
480 it = fhicl_table.begin();
481 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 1);
482 BOOST_TEST(it->second.in_prolog ==
false);
483 BOOST_TEST(it->first ==
"c.cc");
484 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"c3\"");
499 BOOST_TEST(
std::distance(fhicl_table.begin(), fhicl_table.end()) == 4);
501 BOOST_TEST(fhicl_table.exists(
"c.cc"));
503 auto const&
c = fhicl_table.find(
"c.cc");
504 BOOST_TEST(c.in_prolog ==
false);
505 BOOST_TEST(std::any_cast<std::string>(c.value) ==
"\"c1\"");
507 auto it = fhicl_table.begin();
508 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 3);
509 BOOST_TEST(it->second.in_prolog ==
false);
510 BOOST_TEST(it->first ==
"c.cc");
511 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"c2\"");
513 it = fhicl_table.begin();
514 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 2);
515 BOOST_TEST(it->second.in_prolog ==
false);
516 BOOST_TEST(it->first ==
"h");
517 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"h1\"");
519 it = fhicl_table.begin();
520 std::advance(it,
std::distance(fhicl_table.begin(), fhicl_table.end()) - 1);
521 BOOST_TEST(it->second.in_prolog ==
false);
522 BOOST_TEST(it->first ==
"c.cc");
523 BOOST_TEST(std::any_cast<std::string>(it->second.value) ==
"\"@local::h\"");
526 BOOST_AUTO_TEST_SUITE_END()
bool isSnippetMode(bool m)
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
fhicl::extended_value::sequence_t sequence_t
BOOST_AUTO_TEST_CASE(enable_snippet_mode)
intermediate_table parse_document(std::string const &filename, cet::filepath_maker &maker)
static constexpr double mm