9 #define BOOST_TEST_MODULE ( geo_types_fhicl_test ) 10 #include "boost/test/unit_test.hpp" 25 #include <type_traits> 29 template <
typename Config>
36 std::cout <<
"===> FHiCL configuration:";
37 if (configStr.empty()) std::cout <<
" <empty>";
38 else std::cout <<
"\n" << configStr;
40 validatedConfig.print_allowed_configuration
41 (std::cout <<
"===> Expected configuration: ");
44 validatedConfig.validate_ParameterSet(pset);
45 return validatedConfig;
57 ID_t
const expectedID { 2U };
59 auto validatedConfig = validateConfig<Config>(configStr)();
62 static_assert(std::is_same_v<decltype(
id), ID_t
const>);
63 BOOST_TEST(
id.isValid == expectedID.isValid);
64 if (expectedID.isValid) {
65 BOOST_TEST(validatedConfig.Cryo().ID() == expectedID);
66 BOOST_TEST(
id == expectedID);
76 std::string const configStr {
"Cryo: { isValid:false }" };
77 ID_t
const expectedID {};
79 auto validatedConfig = validateConfig<Config>(configStr)();
82 static_assert(std::is_same_v<decltype(
id), ID_t
const>);
83 BOOST_TEST(
id.isValid == expectedID.isValid);
84 if (expectedID.isValid) {
85 BOOST_TEST(validatedConfig.Cryo().ID() == expectedID);
86 BOOST_TEST(
id == expectedID);
97 auto const expectedID = std::make_optional<ID_t>(1U);
99 auto validatedConfig = validateConfig<Config>(configStr)();
101 std::optional<ID_t>
const id =
readOptionalID(validatedConfig.Cryo);
102 BOOST_TEST(
id.has_value() == expectedID.has_value());
103 if (expectedID.has_value()) {
104 BOOST_TEST(id->isValid == expectedID->isValid);
105 if (expectedID->isValid) BOOST_TEST(
id.
value() == expectedID.value());
118 std::optional<ID_t>
const expectedID;
120 auto validatedConfig = validateConfig<Config>(configStr)();
122 std::optional<ID_t>
const id 124 BOOST_TEST(
id.has_value() == expectedID.has_value());
125 if (expectedID.has_value()) {
126 BOOST_TEST(id->isValid == expectedID->isValid);
127 if (expectedID->isValid) BOOST_TEST(
id.
value() == expectedID.value());
139 std::string const configStr {
"Cryos: [ { C:0 }, { C:2 } ]" };
142 std::array<ID_t, 2U>
const expectedIDs {{ ID_t{ 0U }, ID_t{ 2U } }};
144 auto validatedConfig = validateConfig<Config>(configStr)();
147 static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
149 BOOST_TEST(ids.size() == expectedIDs.size());
150 auto const n =
std::min(ids.size(), expectedIDs.size());
151 for (std::size_t i = 0; i <
n; ++i) {
152 auto const&
id = ids[i];
153 ID_t
const& expectedID = expectedIDs[i];
155 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
156 BOOST_TEST(
id.isValid == expectedID.isValid);
157 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
172 auto validatedConfig = validateConfig<Config>(configStr)();
175 static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
177 BOOST_TEST(ids.size() == 0U);
188 std::string const configStr {
"Cryos: [ { C:0 }, { C:2 } ]" };
189 std::optional<std::vector<ID_t>>
const expectedIDs
190 (std::in_place, { ID_t{ 0U }, ID_t{ 2U } });
192 auto validatedConfig = validateConfig<Config>(configStr)();
196 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
198 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
199 if (expectedIDs.has_value()) {
200 BOOST_TEST(ids->size() == expectedIDs->size());
201 auto const n =
std::min(ids->size(), expectedIDs->size());
202 for (std::size_t i = 0; i <
n; ++i) {
203 auto const&
id = ids.value()[i];
204 ID_t
const& expectedID = expectedIDs.value()[i];
206 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
207 BOOST_TEST(
id.isValid == expectedID.isValid);
208 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
223 std::optional<std::vector<ID_t>>
const expectedIDs(std::in_place);
225 auto validatedConfig = validateConfig<Config>(configStr)();
229 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
231 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
232 if (expectedIDs.has_value()) {
233 BOOST_TEST(ids->size() == expectedIDs->size());
234 auto const n =
std::min(ids->size(), expectedIDs->size());
235 for (std::size_t i = 0; i <
n; ++i) {
236 auto const&
id = ids.value()[i];
237 ID_t
const& expectedID = expectedIDs.value()[i];
239 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
240 BOOST_TEST(
id.isValid == expectedID.isValid);
241 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
256 std::optional<std::vector<ID_t>>
const expectedIDs(std::nullopt);
258 auto validatedConfig = validateConfig<Config>(configStr)();
262 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
264 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
265 if (expectedIDs.has_value()) {
266 BOOST_TEST(ids->size() == expectedIDs->size());
267 auto const n =
std::min(ids->size(), expectedIDs->size());
268 for (std::size_t i = 0; i <
n; ++i) {
269 auto const&
id = ids.value()[i];
270 ID_t
const& expectedID = expectedIDs.value()[i];
272 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
273 BOOST_TEST(
id.isValid == expectedID.isValid);
274 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
292 std::string const configStr {
"OpDet: { C:2 O:3 }" };
293 ID_t
const expectedID { 2U, 3U };
295 auto validatedConfig = validateConfig<Config>(configStr)();
298 static_assert(std::is_same_v<decltype(
id), ID_t
const>);
299 BOOST_TEST(
id.isValid == expectedID.isValid);
300 if (expectedID.isValid) {
301 BOOST_TEST(validatedConfig.OpDet().ID() == expectedID);
302 BOOST_TEST(
id == expectedID);
312 std::string const configStr {
"OpDet: { isValid:false }" };
313 ID_t
const expectedID {};
315 auto validatedConfig = validateConfig<Config>(configStr)();
318 static_assert(std::is_same_v<decltype(
id), ID_t
const>);
319 BOOST_TEST(
id.isValid == expectedID.isValid);
320 if (expectedID.isValid) {
321 BOOST_TEST(validatedConfig.OpDet().ID() == expectedID);
322 BOOST_TEST(
id == expectedID);
332 std::string const configStr {
"OpDet: { C:1 O:2 }" };
333 std::optional<ID_t>
const expectedID { std::in_place, 1U, 2U };
335 auto validatedConfig = validateConfig<Config>(configStr)();
337 std::optional<ID_t>
const id =
readOptionalID(validatedConfig.OpDet);
338 BOOST_TEST(
id.has_value() == expectedID.has_value());
339 if (expectedID.has_value()) {
340 BOOST_TEST(id->isValid == expectedID->isValid);
341 if (expectedID->isValid) BOOST_TEST(
id.
value() == expectedID.value());
354 std::optional<ID_t>
const expectedID { std::nullopt };
356 auto validatedConfig = validateConfig<Config>(configStr)();
358 std::optional<ID_t>
const id 360 BOOST_TEST(
id.has_value() == expectedID.has_value());
361 if (expectedID.has_value()) {
362 BOOST_TEST(id->isValid == expectedID->isValid);
363 if (expectedID->isValid) BOOST_TEST(
id.
value() == expectedID.value());
375 std::string const configStr {
"OpDets: [ { C:0 O:1 }, { C:2 O:3 } ]" };
378 std::array<ID_t, 2U>
const expectedIDs {{ ID_t{ 0U, 1U }, ID_t{ 2U, 3U } }};
380 auto validatedConfig = validateConfig<Config>(configStr)();
383 static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
385 BOOST_TEST(ids.size() == expectedIDs.size());
386 auto const n =
std::min(ids.size(), expectedIDs.size());
387 for (std::size_t i = 0; i <
n; ++i) {
388 auto const&
id = ids[i];
389 ID_t
const& expectedID = expectedIDs[i];
391 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
392 BOOST_TEST(
id.isValid == expectedID.isValid);
393 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
408 auto validatedConfig = validateConfig<Config>(configStr)();
411 static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
413 BOOST_TEST(ids.size() == 0U);
424 std::string const configStr {
"OpDets: [ { C:0 O:1 }, { C:2 O:3 } ]" };
425 std::optional<std::vector<ID_t>>
const expectedIDs
426 (std::in_place, { ID_t{ 0U, 1U }, ID_t{ 2U, 3U } });
428 auto validatedConfig = validateConfig<Config>(configStr)();
432 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
434 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
435 if (expectedIDs.has_value()) {
436 BOOST_TEST(ids->size() == expectedIDs->size());
437 auto const n =
std::min(ids->size(), expectedIDs->size());
438 for (std::size_t i = 0; i <
n; ++i) {
439 auto const&
id = ids.value()[i];
440 ID_t
const& expectedID = expectedIDs.value()[i];
442 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
443 BOOST_TEST(
id.isValid == expectedID.isValid);
444 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
459 std::optional<std::vector<ID_t>>
const expectedIDs(std::in_place);
461 auto validatedConfig = validateConfig<Config>(configStr)();
465 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
467 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
468 if (expectedIDs.has_value()) {
469 BOOST_TEST(ids->size() == expectedIDs->size());
470 auto const n =
std::min(ids->size(), expectedIDs->size());
471 for (std::size_t i = 0; i <
n; ++i) {
472 auto const&
id = ids.value()[i];
473 ID_t
const& expectedID = expectedIDs.value()[i];
475 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
476 BOOST_TEST(
id.isValid == expectedID.isValid);
477 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
492 std::optional<std::vector<ID_t>>
const expectedIDs(std::nullopt);
494 auto validatedConfig = validateConfig<Config>(configStr)();
498 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
500 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
501 if (expectedIDs.has_value()) {
502 BOOST_TEST(ids->size() == expectedIDs->size());
503 auto const n =
std::min(ids->size(), expectedIDs->size());
504 for (std::size_t i = 0; i <
n; ++i) {
505 auto const&
id = ids.value()[i];
506 ID_t
const& expectedID = expectedIDs.value()[i];
508 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
509 BOOST_TEST(
id.isValid == expectedID.isValid);
510 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
527 std::string const configStr {
"TPC: { C:2 T:3 }" };
528 ID_t
const expectedID { 2U, 3U };
530 auto validatedConfig = validateConfig<Config>(configStr)();
533 static_assert(std::is_same_v<decltype(
id), ID_t
const>);
534 BOOST_TEST(
id.isValid == expectedID.isValid);
535 if (expectedID.isValid) {
536 BOOST_TEST(validatedConfig.TPC().ID() == expectedID);
537 BOOST_TEST(
id == expectedID);
547 std::string const configStr {
"TPC: { isValid:false }" };
548 ID_t
const expectedID {};
550 auto validatedConfig = validateConfig<Config>(configStr)();
553 static_assert(std::is_same_v<decltype(
id), ID_t
const>);
554 BOOST_TEST(
id.isValid == expectedID.isValid);
555 if (expectedID.isValid) {
556 BOOST_TEST(validatedConfig.TPC().ID() == expectedID);
557 BOOST_TEST(
id == expectedID);
567 std::string const configStr {
"TPC: { C:1 T:2 }" };
568 std::optional<ID_t>
const expectedID { std::in_place, 1U, 2U };
570 auto validatedConfig = validateConfig<Config>(configStr)();
572 std::optional<ID_t>
const id =
readOptionalID(validatedConfig.TPC);
573 BOOST_TEST(
id.has_value() == expectedID.has_value());
574 if (expectedID.has_value()) {
575 BOOST_TEST(id->isValid == expectedID->isValid);
576 if (expectedID->isValid) BOOST_TEST(
id.
value() == expectedID.value());
589 std::optional<ID_t>
const expectedID { std::nullopt };
591 auto validatedConfig = validateConfig<Config>(configStr)();
593 std::optional<ID_t>
const id 595 BOOST_TEST(
id.has_value() == expectedID.has_value());
596 if (expectedID.has_value()) {
597 BOOST_TEST(id->isValid == expectedID->isValid);
598 if (expectedID->isValid) BOOST_TEST(
id.
value() == expectedID.value());
610 std::string const configStr {
"TPCs: [ { C:0 T:1 }, { C:2 T:3 } ]" };
613 std::array<ID_t, 2U>
const expectedIDs {{ ID_t{ 0U, 1U }, ID_t{ 2U, 3U } }};
615 auto validatedConfig = validateConfig<Config>(configStr)();
618 static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
620 BOOST_TEST(ids.size() == expectedIDs.size());
621 auto const n =
std::min(ids.size(), expectedIDs.size());
622 for (std::size_t i = 0; i <
n; ++i) {
623 auto const&
id = ids[i];
624 ID_t
const& expectedID = expectedIDs[i];
626 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
627 BOOST_TEST(
id.isValid == expectedID.isValid);
628 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
643 auto validatedConfig = validateConfig<Config>(configStr)();
646 static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
648 BOOST_TEST(ids.size() == 0U);
659 std::string const configStr {
"TPCs: [ { C:0 T:1 }, { C:2 T:3 } ]" };
660 std::optional<std::vector<ID_t>>
const expectedIDs
661 (std::in_place, { ID_t{ 0U, 1U }, ID_t{ 2U, 3U } });
663 auto validatedConfig = validateConfig<Config>(configStr)();
667 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
669 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
670 if (expectedIDs.has_value()) {
671 BOOST_TEST(ids->size() == expectedIDs->size());
672 auto const n =
std::min(ids->size(), expectedIDs->size());
673 for (std::size_t i = 0; i <
n; ++i) {
674 auto const&
id = ids.value()[i];
675 ID_t
const& expectedID = expectedIDs.value()[i];
677 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
678 BOOST_TEST(
id.isValid == expectedID.isValid);
679 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
694 std::optional<std::vector<ID_t>>
const expectedIDs(std::in_place);
696 auto validatedConfig = validateConfig<Config>(configStr)();
700 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
702 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
703 if (expectedIDs.has_value()) {
704 BOOST_TEST(ids->size() == expectedIDs->size());
705 auto const n =
std::min(ids->size(), expectedIDs->size());
706 for (std::size_t i = 0; i <
n; ++i) {
707 auto const&
id = ids.value()[i];
708 ID_t
const& expectedID = expectedIDs.value()[i];
710 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
711 BOOST_TEST(
id.isValid == expectedID.isValid);
712 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
727 std::optional<std::vector<ID_t>>
const expectedIDs(std::nullopt);
729 auto validatedConfig = validateConfig<Config>(configStr)();
733 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
735 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
736 if (expectedIDs.has_value()) {
737 BOOST_TEST(ids->size() == expectedIDs->size());
738 auto const n =
std::min(ids->size(), expectedIDs->size());
739 for (std::size_t i = 0; i <
n; ++i) {
740 auto const&
id = ids.value()[i];
741 ID_t
const& expectedID = expectedIDs.value()[i];
743 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
744 BOOST_TEST(
id.isValid == expectedID.isValid);
745 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
762 std::string const configStr {
"Plane: { C:2 T:3 P:1 }" };
763 ID_t
const expectedID { 2U, 3U, 1U };
765 auto validatedConfig = validateConfig<Config>(configStr)();
768 static_assert(std::is_same_v<decltype(
id), ID_t
const>);
769 BOOST_TEST(
id.isValid == expectedID.isValid);
770 if (expectedID.isValid) {
771 BOOST_TEST(validatedConfig.Plane().ID() == expectedID);
772 BOOST_TEST(
id == expectedID);
782 std::string const configStr {
"Plane: { isValid:false }" };
783 ID_t
const expectedID {};
785 auto validatedConfig = validateConfig<Config>(configStr)();
788 static_assert(std::is_same_v<decltype(
id), ID_t
const>);
789 BOOST_TEST(
id.isValid == expectedID.isValid);
790 if (expectedID.isValid) {
791 BOOST_TEST(validatedConfig.Plane().ID() == expectedID);
792 BOOST_TEST(
id == expectedID);
802 std::string const configStr {
"Plane: { C:1 T:2 P:1 }" };
803 std::optional<ID_t>
const expectedID { std::in_place, 1U, 2U, 1U };
805 auto validatedConfig = validateConfig<Config>(configStr)();
807 std::optional<ID_t>
const id =
readOptionalID(validatedConfig.Plane);
808 BOOST_TEST(
id.has_value() == expectedID.has_value());
809 if (expectedID.has_value()) {
810 BOOST_TEST(id->isValid == expectedID->isValid);
811 if (expectedID->isValid) BOOST_TEST(
id.
value() == expectedID.value());
824 std::optional<ID_t>
const expectedID { std::nullopt };
826 auto validatedConfig = validateConfig<Config>(configStr)();
828 std::optional<ID_t>
const id 830 BOOST_TEST(
id.has_value() == expectedID.has_value());
831 if (expectedID.has_value()) {
832 BOOST_TEST(id->isValid == expectedID->isValid);
833 if (expectedID->isValid) BOOST_TEST(
id.
value() == expectedID.value());
846 {
"Planes: [ { C:0 T:1 P:1 }, { C:2 T:3 P:0 } ]" };
847 std::array<ID_t, 2U>
const expectedIDs
850 {{ ID_t{ 0U, 1U, 1U }, ID_t{ 2U, 3U, 0U } }};
852 auto validatedConfig = validateConfig<Config>(configStr)();
855 static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
857 BOOST_TEST(ids.size() == expectedIDs.size());
858 auto const n =
std::min(ids.size(), expectedIDs.size());
859 for (std::size_t i = 0; i <
n; ++i) {
860 auto const&
id = ids[i];
861 ID_t
const& expectedID = expectedIDs[i];
863 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
864 BOOST_TEST(
id.isValid == expectedID.isValid);
865 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
880 auto validatedConfig = validateConfig<Config>(configStr)();
883 static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
885 BOOST_TEST(ids.size() == 0U);
897 {
"Planes: [ { C:0 T:1 P:1 }, { C:2 T:3 P:0 } ]" };
898 std::optional<std::vector<ID_t>>
const expectedIDs
899 (std::in_place, { ID_t{ 0U, 1U, 1U }, ID_t{ 2U, 3U, 0U } });
901 auto validatedConfig = validateConfig<Config>(configStr)();
905 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
907 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
908 if (expectedIDs.has_value()) {
909 BOOST_TEST(ids->size() == expectedIDs->size());
910 auto const n =
std::min(ids->size(), expectedIDs->size());
911 for (std::size_t i = 0; i <
n; ++i) {
912 auto const&
id = ids.value()[i];
913 ID_t
const& expectedID = expectedIDs.value()[i];
915 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
916 BOOST_TEST(
id.isValid == expectedID.isValid);
917 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
932 std::optional<std::vector<ID_t>>
const expectedIDs(std::in_place);
934 auto validatedConfig = validateConfig<Config>(configStr)();
938 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
940 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
941 if (expectedIDs.has_value()) {
942 BOOST_TEST(ids->size() == expectedIDs->size());
943 auto const n =
std::min(ids->size(), expectedIDs->size());
944 for (std::size_t i = 0; i <
n; ++i) {
945 auto const&
id = ids.value()[i];
946 ID_t
const& expectedID = expectedIDs.value()[i];
948 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
949 BOOST_TEST(
id.isValid == expectedID.isValid);
950 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
965 std::optional<std::vector<ID_t>>
const expectedIDs(std::nullopt);
967 auto validatedConfig = validateConfig<Config>(configStr)();
971 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
973 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
974 if (expectedIDs.has_value()) {
975 BOOST_TEST(ids->size() == expectedIDs->size());
976 auto const n =
std::min(ids->size(), expectedIDs->size());
977 for (std::size_t i = 0; i <
n; ++i) {
978 auto const&
id = ids.value()[i];
979 ID_t
const& expectedID = expectedIDs.value()[i];
981 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
982 BOOST_TEST(
id.isValid == expectedID.isValid);
983 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
1000 std::string const configStr {
"Wire: { C:2 T:3 P:1 W:9 }" };
1001 ID_t
const expectedID { 2U, 3U, 1U, 9U };
1003 auto validatedConfig = validateConfig<Config>(configStr)();
1006 static_assert(std::is_same_v<decltype(
id), ID_t
const>);
1007 BOOST_TEST(
id.isValid == expectedID.isValid);
1008 if (expectedID.isValid) {
1009 BOOST_TEST(validatedConfig.Wire().ID() == expectedID);
1010 BOOST_TEST(
id == expectedID);
1020 std::string const configStr {
"Wire: { isValid:false }" };
1021 ID_t
const expectedID {};
1023 auto validatedConfig = validateConfig<Config>(configStr)();
1026 static_assert(std::is_same_v<decltype(
id), ID_t
const>);
1027 BOOST_TEST(
id.isValid == expectedID.isValid);
1028 if (expectedID.isValid) {
1029 BOOST_TEST(validatedConfig.Wire().ID() == expectedID);
1030 BOOST_TEST(
id == expectedID);
1040 std::string const configStr {
"Wire: { C:1 T:2 P:1 W:9 }" };
1041 std::optional<ID_t>
const expectedID { std::in_place, 1U, 2U, 1U, 9U };
1043 auto validatedConfig = validateConfig<Config>(configStr)();
1045 std::optional<ID_t>
const id =
readOptionalID(validatedConfig.Wire);
1046 BOOST_TEST(
id.has_value() == expectedID.has_value());
1047 if (expectedID.has_value()) {
1048 BOOST_TEST(id->isValid == expectedID->isValid);
1049 if (expectedID->isValid) BOOST_TEST(
id.
value() == expectedID.value());
1062 std::optional<ID_t>
const expectedID { std::nullopt };
1064 auto validatedConfig = validateConfig<Config>(configStr)();
1066 std::optional<ID_t>
const id 1068 BOOST_TEST(
id.has_value() == expectedID.has_value());
1069 if (expectedID.has_value()) {
1070 BOOST_TEST(id->isValid == expectedID->isValid);
1071 if (expectedID->isValid) BOOST_TEST(
id.
value() == expectedID.value());
1084 {
"Wires: [ { C:0 T:1 P:1 W:9 }, { C:2 T:3 P:0 W:7 } ]" };
1085 std::array<ID_t, 2U>
const expectedIDs
1088 {{ ID_t{ 0U, 1U, 1U, 9U }, ID_t{ 2U, 3U, 0U, 7U } }};
1090 auto validatedConfig = validateConfig<Config>(configStr)();
1093 static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
1095 BOOST_TEST(ids.size() == expectedIDs.size());
1096 auto const n =
std::min(ids.size(), expectedIDs.size());
1097 for (std::size_t i = 0; i <
n; ++i) {
1098 auto const&
id = ids[i];
1099 ID_t
const& expectedID = expectedIDs[i];
1101 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
1102 BOOST_TEST(
id.isValid == expectedID.isValid);
1103 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
1118 auto validatedConfig = validateConfig<Config>(configStr)();
1121 static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
1123 BOOST_TEST(ids.size() == 0U);
1135 {
"Wires: [ { C:0 T:1 P:1 W:9 }, { C:2 T:3 P:0 W:7 } ]" };
1136 std::optional<std::vector<ID_t>>
const expectedIDs
1137 (std::in_place, { ID_t{ 0U, 1U, 1U, 9U }, ID_t{ 2U, 3U, 0U, 7U } });
1139 auto validatedConfig = validateConfig<Config>(configStr)();
1143 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
1145 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
1146 if (expectedIDs.has_value()) {
1147 BOOST_TEST(ids->size() == expectedIDs->size());
1148 auto const n =
std::min(ids->size(), expectedIDs->size());
1149 for (std::size_t i = 0; i <
n; ++i) {
1150 auto const&
id = ids.value()[i];
1151 ID_t
const& expectedID = expectedIDs.value()[i];
1153 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
1154 BOOST_TEST(
id.isValid == expectedID.isValid);
1155 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
1170 std::optional<std::vector<ID_t>>
const expectedIDs(std::in_place);
1172 auto validatedConfig = validateConfig<Config>(configStr)();
1176 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
1178 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
1179 if (expectedIDs.has_value()) {
1180 BOOST_TEST(ids->size() == expectedIDs->size());
1181 auto const n =
std::min(ids->size(), expectedIDs->size());
1182 for (std::size_t i = 0; i <
n; ++i) {
1183 auto const&
id = ids.value()[i];
1184 ID_t
const& expectedID = expectedIDs.value()[i];
1186 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
1187 BOOST_TEST(
id.isValid == expectedID.isValid);
1188 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
1203 std::optional<std::vector<ID_t>>
const expectedIDs(std::nullopt);
1205 auto validatedConfig = validateConfig<Config>(configStr)();
1209 (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
1211 BOOST_TEST(ids.has_value() == expectedIDs.has_value());
1212 if (expectedIDs.has_value()) {
1213 BOOST_TEST(ids->size() == expectedIDs->size());
1214 auto const n =
std::min(ids->size(), expectedIDs->size());
1215 for (std::size_t i = 0; i <
n; ++i) {
1216 auto const&
id = ids.value()[i];
1217 ID_t
const& expectedID = expectedIDs.value()[i];
1219 BOOST_TEST_CONTEXT(
"Item [" << i <<
"]") {
1220 BOOST_TEST(
id.isValid == expectedID.isValid);
1221 if (expectedID.isValid) BOOST_TEST(
id == expectedID);
1249 "Wire: { C:1 T:5 P:2 W:9 }" 1250 "\nMaybeWire: { C:1 T:5 P:2 W:8 }" 1253 "\nWires: [ { C:1 T:5 P:2 W:7 }, { C:1 T:5 P:2 W:6 } ] " 1254 "\nMaybeWires: [ { C:1 T:5 P:2 W:5 } ] " 1259 auto const&
config = validateConfig<Config>(configStr);
1261 ID_t
const expected1 { 1U, 5U, 2U, 9U };
1262 ID_t
const expected2 { 1U, 5U, 2U, 8U };
1263 std::array<ID_t, 2U>
const expected4
1266 {{ ID_t{ 1U, 5U, 2U, 7U }, ID_t{ 1U, 5U, 2U, 6U } }};
1267 std::array<ID_t, 1U>
const expected5
1270 {{ ID_t{ 1U, 5U, 2U, 5U } }};
1272 ID_t
const default3 { 1U, 5U, 0U, 9U };
1273 auto default3value = default3;
1275 std::vector<ID_t>
const default6({
1276 ID_t{ 1U, 5U, 0U, 4U }, ID_t{ 1U, 5U, 0U, 3U }, ID_t{ 1U, 5U, 0U, 2U }
1278 auto default6value = default6;
1284 static_assert(std::is_same_v<decltype(id11), ID_t>);
1285 BOOST_TEST(id11 == expected1);
1293 static_assert(std::is_same_v<decltype(id21), std::optional<ID_t>>);
1294 BOOST_TEST(id21.has_value());
1295 if (id21.has_value()) BOOST_TEST(id21.value() == expected2);
1297 default3value = default3;
1299 static_assert(std::is_same_v<decltype(id22), ID_t>);
1300 BOOST_TEST(id22 == expected2);
1301 BOOST_TEST(default3value == default3);
1303 default3value = default3;
1306 static_assert(std::is_same_v<decltype(id23), ID_t>);
1307 BOOST_TEST(id23 == expected2);
1308 BOOST_TEST(default3value == default3);
1312 static_assert(std::is_same_v<decltype(id31), std::optional<ID_t>>);
1313 BOOST_TEST(!id31.has_value());
1315 default3value = default3;
1317 static_assert(std::is_same_v<decltype(id32), ID_t>);
1318 BOOST_TEST(id32 == default3);
1319 BOOST_TEST(default3value == default3);
1321 default3value = default3;
1323 static_assert(std::is_same_v<decltype(id33), ID_t>);
1324 BOOST_TEST(id33 == default3);
1328 BOOST_TEST(id34 == (
geo::WireID{ 1U, 3U, 6U, 9U }));
1335 static_assert(std::is_same_v<decltype(id41), std::vector<ID_t>>);
1336 BOOST_TEST(id41.size() == expected4.size());
1337 std::size_t max41 =
std::max(id41.size(), expected4.size());
1338 for (std::size_t i = 0U; i < max41; ++i) BOOST_TEST_CONTEXT(
"element " << i) {
1339 BOOST_TEST(id41[i] == expected4[i]);
1348 (std::is_same_v<decltype(id51), std::optional<std::vector<ID_t>>>);
1349 BOOST_TEST(id51.has_value());
1350 if (id51.has_value()) {
1351 BOOST_CHECK_EQUAL_COLLECTIONS
1352 (id51->begin(), id51->end(), expected5.begin(), expected5.end());
1355 default6value = default6;
1357 static_assert(std::is_same_v<decltype(id52), std::vector<ID_t>>);
1358 BOOST_CHECK_EQUAL_COLLECTIONS
1359 (id52.begin(), id52.end(), expected5.begin(), expected5.end());
1360 BOOST_CHECK_EQUAL_COLLECTIONS(
1361 default6value.begin(), default6value.end(),
1362 default6.begin(), default6.end()
1365 default6value = default6;
1368 static_assert(std::is_same_v<decltype(id53), std::vector<ID_t>>);
1369 BOOST_CHECK_EQUAL_COLLECTIONS
1370 (id53.begin(), id53.end(), expected5.begin(), expected5.end());
1371 BOOST_CHECK_EQUAL_COLLECTIONS(
1372 default6value.begin(), default6value.end(),
1373 default6.begin(), default6.end()
1379 (std::is_same_v<decltype(id61), std::optional<std::vector<ID_t>>>);
1380 BOOST_TEST(!id61.has_value());
1382 default6value = default6;
1384 static_assert(std::is_same_v<decltype(id62), std::vector<ID_t>>);
1385 BOOST_CHECK_EQUAL_COLLECTIONS
1386 (id62.begin(), id62.end(), default6.begin(), default6.end());
1387 BOOST_CHECK_EQUAL_COLLECTIONS(
1388 default6value.begin(), default6value.end(),
1389 default6.begin(), default6.end()
1392 default6value = default6;
1395 static_assert(std::is_same_v<decltype(id63), std::vector<ID_t>>);
1396 BOOST_CHECK_EQUAL_COLLECTIONS
1397 (id63.begin(), id63.end(), default6.begin(), default6.end());
1401 BOOST_TEST(default6value.empty());
1474 "\n { C:0 T:1 P:0 }," 1475 "\n { C:0 T:1 P:1 }," 1476 "\n { C:0 T:1 P:2 }" 1478 "\nReferencePlane: { C:0 T:1 P:2 }" 1485 std::vector<geo::PlaneID>
const planes
1487 if (planes.empty()) {
1488 throw std::runtime_error(
"At least one plane is needed.");
1493 .value_or(planes.front())
1499 BOOST_TEST(planes.size() == 3U);
1539 fhicl::Comment(
"anode planes to process (omit or empty processes all)")
1549 "\n { C:0 T:1 P:0 }," 1550 "\n { C:0 T:1 P:1 }," 1551 "\n { C:0 T:1 P:2 }" 1558 std::vector<geo::PlaneID> planes
1561 BOOST_TEST(planes.size() == 3U);
1575 BOOST_TEST(planes.empty());
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
void test_WireIDsequence_normal()
void test_OptionalCryostatIDsequence_omitted()
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
void test_PlaneIDsequence_normal()
void test_CryostatID_invalid()
void test_WireID_normal()
void test_OptionalOpDetIDsequence_omitted()
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
void test_CryostatID_normal()
void test_OptionalOpDetIDsequence_empty()
static ParameterSet make(intermediate_table const &tbl)
void test_OptionalWireID_omitted()
fhicl::Table< Config > validateConfig(std::string const &configStr)
void test_OptionalTPCIDsequence_omitted()
The data type to uniquely identify a Plane.
void test_WireIDsequence_empty()
ChannelGroupService::Name Name
void test_OpDetIDsequence_empty()
void test_OptionalCryostatID_omitted()
void test_WireID_invalid()
BOOST_AUTO_TEST_CASE(CryostatID_testcase)
void test_OptionalWireID_present()
void test_OptionalTPCIDsequence_empty()
void test_OptionalCryostatID_present()
void test_OptionalTPCIDsequence_normal()
void test_PlaneID_invalid()
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
void test_OptionalPlaneID_present()
typename config_impl< T >::type Config
void test_OptionalOpDetID_omitted()
void test_OptionalPlaneIDsequence_normal()
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
void test_groupDocumentation_example2()
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
void test_OptionalOpDetIDsequence_normal()
void test_CryostatIDsequence_empty()
static int max(int a, int b)
void test_TPCIDsequence_normal()
Definition of data types for geometry description.
void test_PlaneIDsequence_empty()
void test_OpDetID_invalid()
void test_OptionalPlaneIDsequence_omitted()
void test_OptionalPlaneID_omitted()
void test_OptionalWireIDsequence_omitted()
void test_OptionalWireIDsequence_normal()
void test_groupDocumentation_example1()
void test_WireUnifiedInterface()
void test_TPCID_invalid()
void test_OptionalCryostatIDsequence_empty()
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
void test_OpDetID_normal()
void test_OptionalPlaneIDsequence_empty()
void test_OpDetIDsequence_normal()
void test_OptionalWireIDsequence_empty()
void test_OptionalTPCID_omitted()
detail::Node< FrameID, bool > PlaneID
void test_CryostatIDsequence_normal()
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
Utilities for using geometry IDs in FHiCL validated configuration.
void test_OptionalOpDetID_present()
recob::tracking::Plane Plane
void test_TPCIDsequence_empty()
ID readParameter(IDparameter< SrcID > const &atom)
void test_OptionalTPCID_present()
void test_PlaneID_normal()
QTextStream & endl(QTextStream &s)
void test_OptionalCryostatIDsequence_normal()