Macros | Functions
geo_types_fhicl_test.cc File Reference

Test of larcoreobj/SimpleTypesAndConstants/geo_types_fhicl.h. More...

#include "boost/test/unit_test.hpp"
#include "larcoreobj/SimpleTypesAndConstants/geo_types_fhicl.h"
#include "larcoreobj/SimpleTypesAndConstants/geo_types.h"
#include "fhiclcpp/types/Table.h"
#include "fhiclcpp/ParameterSet.h"
#include <iostream>
#include <string>
#include <array>
#include <type_traits>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   ( geo_types_fhicl_test )
 

Functions

template<typename Config >
fhicl::Table< ConfigvalidateConfig (std::string const &configStr)
 
void test_CryostatID_normal ()
 
void test_CryostatID_invalid ()
 
void test_OptionalCryostatID_present ()
 
void test_OptionalCryostatID_omitted ()
 
void test_CryostatIDsequence_normal ()
 
void test_CryostatIDsequence_empty ()
 
void test_OptionalCryostatIDsequence_normal ()
 
void test_OptionalCryostatIDsequence_empty ()
 
void test_OptionalCryostatIDsequence_omitted ()
 
void test_OpDetID_normal ()
 
void test_OpDetID_invalid ()
 
void test_OptionalOpDetID_present ()
 
void test_OptionalOpDetID_omitted ()
 
void test_OpDetIDsequence_normal ()
 
void test_OpDetIDsequence_empty ()
 
void test_OptionalOpDetIDsequence_normal ()
 
void test_OptionalOpDetIDsequence_empty ()
 
void test_OptionalOpDetIDsequence_omitted ()
 
void test_TPCID_normal ()
 
void test_TPCID_invalid ()
 
void test_OptionalTPCID_present ()
 
void test_OptionalTPCID_omitted ()
 
void test_TPCIDsequence_normal ()
 
void test_TPCIDsequence_empty ()
 
void test_OptionalTPCIDsequence_normal ()
 
void test_OptionalTPCIDsequence_empty ()
 
void test_OptionalTPCIDsequence_omitted ()
 
void test_PlaneID_normal ()
 
void test_PlaneID_invalid ()
 
void test_OptionalPlaneID_present ()
 
void test_OptionalPlaneID_omitted ()
 
void test_PlaneIDsequence_normal ()
 
void test_PlaneIDsequence_empty ()
 
void test_OptionalPlaneIDsequence_normal ()
 
void test_OptionalPlaneIDsequence_empty ()
 
void test_OptionalPlaneIDsequence_omitted ()
 
void test_WireID_normal ()
 
void test_WireID_invalid ()
 
void test_OptionalWireID_present ()
 
void test_OptionalWireID_omitted ()
 
void test_WireIDsequence_normal ()
 
void test_WireIDsequence_empty ()
 
void test_OptionalWireIDsequence_normal ()
 
void test_OptionalWireIDsequence_empty ()
 
void test_OptionalWireIDsequence_omitted ()
 
void test_WireUnifiedInterface ()
 
void test_groupDocumentation_example1 ()
 
void test_groupDocumentation_example2 ()
 
 BOOST_AUTO_TEST_CASE (CryostatID_testcase)
 
 BOOST_AUTO_TEST_CASE (OpDetID_testcase)
 
 BOOST_AUTO_TEST_CASE (TPCID_testcase)
 
 BOOST_AUTO_TEST_CASE (PlaneID_testcase)
 
 BOOST_AUTO_TEST_CASE (WireID_testcase)
 
 BOOST_AUTO_TEST_CASE (documentation_testcase)
 

Detailed Description

Test of larcoreobj/SimpleTypesAndConstants/geo_types_fhicl.h.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
Date
November 25, 2019

Definition in file geo_types_fhicl_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( geo_types_fhicl_test )

Definition at line 9 of file geo_types_fhicl_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( CryostatID_testcase  )

Definition at line 1588 of file geo_types_fhicl_test.cc.

1588  {
1589 
1592 
1595 
1598 
1602 
1603 } // BOOST_AUTO_TEST_CASE(CryostatID_testcase)
void test_OptionalCryostatIDsequence_omitted()
void test_CryostatID_invalid()
void test_CryostatID_normal()
void test_OptionalCryostatID_omitted()
void test_OptionalCryostatID_present()
void test_CryostatIDsequence_empty()
void test_OptionalCryostatIDsequence_empty()
void test_CryostatIDsequence_normal()
void test_OptionalCryostatIDsequence_normal()
BOOST_AUTO_TEST_CASE ( OpDetID_testcase  )

Definition at line 1610 of file geo_types_fhicl_test.cc.

1610  {
1611 
1614 
1617 
1620 
1624 
1625 } // BOOST_AUTO_TEST_CASE(OpDetID_testcase)
void test_OptionalOpDetIDsequence_omitted()
void test_OptionalOpDetIDsequence_empty()
void test_OpDetIDsequence_empty()
void test_OptionalOpDetID_omitted()
void test_OptionalOpDetIDsequence_normal()
void test_OpDetID_invalid()
void test_OpDetID_normal()
void test_OpDetIDsequence_normal()
void test_OptionalOpDetID_present()
BOOST_AUTO_TEST_CASE ( TPCID_testcase  )

Definition at line 1632 of file geo_types_fhicl_test.cc.

1632  {
1633 
1636 
1639 
1642 
1646 
1647 } // BOOST_AUTO_TEST_CASE(TPCID_testcase)
void test_OptionalTPCIDsequence_omitted()
void test_OptionalTPCIDsequence_empty()
void test_OptionalTPCIDsequence_normal()
void test_TPCID_normal()
void test_TPCIDsequence_normal()
void test_TPCID_invalid()
void test_OptionalTPCID_omitted()
void test_TPCIDsequence_empty()
void test_OptionalTPCID_present()
BOOST_AUTO_TEST_CASE ( PlaneID_testcase  )

Definition at line 1654 of file geo_types_fhicl_test.cc.

1654  {
1655 
1658 
1661 
1664 
1668 
1669 } // BOOST_AUTO_TEST_CASE(PlaneID_testcase)
void test_PlaneIDsequence_normal()
void test_PlaneID_invalid()
void test_OptionalPlaneID_present()
void test_OptionalPlaneIDsequence_normal()
void test_PlaneIDsequence_empty()
void test_OptionalPlaneIDsequence_omitted()
void test_OptionalPlaneID_omitted()
void test_OptionalPlaneIDsequence_empty()
void test_PlaneID_normal()
BOOST_AUTO_TEST_CASE ( WireID_testcase  )

Definition at line 1676 of file geo_types_fhicl_test.cc.

1676  {
1677 
1680 
1683 
1686 
1690 
1692 
1693 } // BOOST_AUTO_TEST_CASE(WireID_testcase)
void test_WireIDsequence_normal()
void test_WireID_normal()
void test_OptionalWireID_omitted()
void test_WireIDsequence_empty()
void test_WireID_invalid()
void test_OptionalWireID_present()
void test_OptionalWireIDsequence_omitted()
void test_OptionalWireIDsequence_normal()
void test_WireUnifiedInterface()
void test_OptionalWireIDsequence_empty()
BOOST_AUTO_TEST_CASE ( documentation_testcase  )

Definition at line 1700 of file geo_types_fhicl_test.cc.

1700  {
1701 
1704 
1705 } // BOOST_AUTO_TEST_CASE(documentation_testcase)
void test_groupDocumentation_example2()
void test_groupDocumentation_example1()
void test_CryostatID_invalid ( )

Definition at line 71 of file geo_types_fhicl_test.cc.

71  {
72 
73  using ID_t = geo::CryostatID;
74  struct Config { geo::fhicl::CryostatID Cryo { fhicl::Name("Cryo") }; };
75 
76  std::string const configStr { "Cryo: { isValid:false }" };
77  ID_t const expectedID {};
78 
79  auto validatedConfig = validateConfig<Config>(configStr)();
80 
81  auto const id = geo::fhicl::readID(validatedConfig.Cryo);
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);
87  }
88 } // test_CryostatID_invalid()
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
void test_CryostatID_normal ( )

Definition at line 51 of file geo_types_fhicl_test.cc.

51  {
52 
53  using ID_t = geo::CryostatID;
54  struct Config { geo::fhicl::CryostatID Cryo { fhicl::Name("Cryo") }; };
55 
56  std::string const configStr { "Cryo: { C:2 }" };
57  ID_t const expectedID { 2U };
58 
59  auto validatedConfig = validateConfig<Config>(configStr)();
60 
61  auto const id = geo::fhicl::readID(validatedConfig.Cryo);
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);
67  }
68 } // test_CryostatID_normal()
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
void test_CryostatIDsequence_empty ( )

Definition at line 164 of file geo_types_fhicl_test.cc.

164  {
165 
166  using ID_t = geo::CryostatID;
167  struct Config
168  { geo::fhicl::CryostatIDsequence Cryos { fhicl::Name("Cryos") }; };
169 
170  std::string const configStr { "Cryos: []" };
171 
172  auto validatedConfig = validateConfig<Config>(configStr)();
173 
174  auto ids = geo::fhicl::readIDsequence(validatedConfig.Cryos);
175  static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
176 
177  BOOST_TEST(ids.size() == 0U);
178 
179 } // test_CryostatIDsequence_empty()
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
void test_CryostatIDsequence_normal ( )

Definition at line 133 of file geo_types_fhicl_test.cc.

133  {
134 
135  using ID_t = geo::CryostatID;
136  struct Config
137  { geo::fhicl::CryostatIDsequence Cryos { fhicl::Name("Cryos") }; };
138 
139  std::string const configStr { "Cryos: [ { C:0 }, { C:2 } ]" };
140  // BUG the double brace syntax is required to work around clang bug 21629
141 // std::array<ID_t, 2U> const expectedIDs { ID_t{ 0U }, ID_t{ 2U } };
142  std::array<ID_t, 2U> const expectedIDs {{ ID_t{ 0U }, ID_t{ 2U } }};
143 
144  auto validatedConfig = validateConfig<Config>(configStr)();
145 
146  auto ids = geo::fhicl::readIDsequence(validatedConfig.Cryos);
147  static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
148 
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];
154 
155  BOOST_TEST_CONTEXT("Item [" << i << "]") {
156  BOOST_TEST(id.isValid == expectedID.isValid);
157  if (expectedID.isValid) BOOST_TEST(id == expectedID);
158  } // BOOST_TEST_CONTEXT
159  } // for
160 
161 } // test_CryostatIDsequence_normal()
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_groupDocumentation_example1 ( )

Definition at line 1411 of file geo_types_fhicl_test.cc.

1411  {
1412  /*
1413  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
1414  * struct Config {
1415  *
1416  * geo::fhicl::PlaneIDsequence Planes {
1417  * fhicl::Name("Planes"),
1418  * fhicl::Comment("anode planes to process")
1419  * };
1420  *
1421  * geo::fhicl::OptionalPlaneID ReferencePlane {
1422  * fhicl::Name("ReferencePlane"),
1423  * fhicl::Comment("reference anode plane (first one by default)")
1424  * };
1425  *
1426  * }; // struct Config
1427  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1428  * which can be configured as:
1429  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1430  * Planes: [
1431  * { C:0 T:1 P:0 },
1432  * { C:0 T:1 P:1 },
1433  * { C:0 T:1 P:2 }
1434  * ]
1435  * ReferencePlane: { C:0 T:1 P:2 }
1436  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1437  * and read as:
1438  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
1439  * void readParams(art::EDProducer::Table<Config> const& config) {
1440  *
1441  * std::vector<geo::PlaneID> planes
1442  * = geo::fhicl::readIDsequence(config().Planes);
1443  * if (planes.empty()) {
1444  * throw art::Exception(art::errors::Configuration)
1445  * << "At least one plane is needed.\n";
1446  * }
1447  *
1448  * geo::PlaneID refPlane; // invalid by default
1449  * if (!config().ReferencePlane(refPlane)) refPlane = planes.front();
1450  *
1451  * } // readParams()
1452  *
1453  */
1454 
1455  //
1456  // code (adapted to non-art context)
1457  //
1458  struct Config {
1459 
1461  fhicl::Name("Planes"),
1462  fhicl::Comment("anode planes to process")
1463  };
1464 
1465  geo::fhicl::OptionalPlaneID ReferencePlane {
1466  fhicl::Name("ReferencePlane"),
1467  fhicl::Comment("reference anode plane (first one by default)")
1468  };
1469 
1470  }; // struct Config
1471 
1472  std::string const configStr = {
1473  "Planes: ["
1474  "\n { C:0 T:1 P:0 },"
1475  "\n { C:0 T:1 P:1 },"
1476  "\n { C:0 T:1 P:2 }"
1477  "\n ]"
1478  "\nReferencePlane: { C:0 T:1 P:2 }"
1479  "\n"
1480  };
1481 
1482 
1483  fhicl::Table<Config> config = validateConfig<Config>(configStr);
1484 
1485  std::vector<geo::PlaneID> const planes
1486  = geo::fhicl::readIDsequence(config().Planes);
1487  if (planes.empty()) {
1488  throw std::runtime_error("At least one plane is needed.");
1489  }
1490 
1491  geo::PlaneID const refPlane
1492  = geo::fhicl::readOptionalID(config().ReferencePlane)
1493  .value_or(planes.front())
1494  ;
1495 
1496  //
1497  // test
1498  //
1499  BOOST_TEST(planes.size() == 3U);
1500  BOOST_TEST(planes[0U] == geo::PlaneID(0U, 1U, 0U));
1501  BOOST_TEST(planes[1U] == geo::PlaneID(0U, 1U, 1U));
1502  BOOST_TEST(planes[2U] == geo::PlaneID(0U, 1U, 2U));
1503 
1504  BOOST_TEST(refPlane == geo::PlaneID(0U, 1U, 2U));
1505 
1506 } // test_groupDocumentation_example1()
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
static Config * config
Definition: config.cpp:1054
#define Comment
void test_groupDocumentation_example2 ( )

Definition at line 1510 of file geo_types_fhicl_test.cc.

1510  {
1511  /*
1512  * struct Config {
1513  *
1514  * geo::fhicl::OptionalPlaneIDsequence Planes {
1515  * fhicl::Name("Planes"),
1516  * fhicl::Comment("anode planes to process (omit or empty processes all)")
1517  * };
1518  *
1519  * }; // struct Config
1520  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1521  * reading as:
1522  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
1523  * void readParams(art::EDProducer::Table<Config> const& config) {
1524  *
1525  * std::vector<geo::PlaneID> planes
1526  * = geo::fhicl::readOptionalIDsequence(config().Planes, {});
1527  *
1528  * } // readParams()
1529  *
1530  */
1531 
1532  //
1533  // code (adapted to non-art context)
1534  //
1535  struct Config {
1536 
1538  fhicl::Name("Planes"),
1539  fhicl::Comment("anode planes to process (omit or empty processes all)")
1540  };
1541 
1542  }; // struct Config
1543 
1544  //
1545  // test A
1546  //
1547  std::string const configStrA = {
1548  "Planes: ["
1549  "\n { C:0 T:1 P:0 },"
1550  "\n { C:0 T:1 P:1 },"
1551  "\n { C:0 T:1 P:2 }"
1552  "\n ]"
1553  "\n"
1554  };
1555 
1556  fhicl::Table<Config> configA = validateConfig<Config>(configStrA);
1557 
1558  std::vector<geo::PlaneID> planes
1559  = geo::fhicl::readOptionalIDsequence(configA().Planes, {});
1560 
1561  BOOST_TEST(planes.size() == 3U);
1562  BOOST_TEST(planes[0U] == geo::PlaneID(0U, 1U, 0U));
1563  BOOST_TEST(planes[1U] == geo::PlaneID(0U, 1U, 1U));
1564  BOOST_TEST(planes[2U] == geo::PlaneID(0U, 1U, 2U));
1565 
1566  //
1567  // test B
1568  //
1569  std::string const configStrB = { "" };
1570 
1571  fhicl::Table<Config> configB = validateConfig<Config>(configStrB);
1572 
1573  planes = geo::fhicl::readOptionalIDsequence(configB().Planes, {});
1574 
1575  BOOST_TEST(planes.empty());
1576 
1577 
1578 } // test_groupDocumentation_example2()
std::string string
Definition: nybbler.cc:12
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
#define Comment
void test_OpDetID_invalid ( )

Definition at line 307 of file geo_types_fhicl_test.cc.

307  {
308 
309  using ID_t = geo::OpDetID;
310  struct Config { geo::fhicl::OpDetID OpDet { fhicl::Name("OpDet") }; };
311 
312  std::string const configStr { "OpDet: { isValid:false }" };
313  ID_t const expectedID {};
314 
315  auto validatedConfig = validateConfig<Config>(configStr)();
316 
317  auto const id = geo::fhicl::readID(validatedConfig.OpDet);
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);
323  }
324 } // test_OpDetID_invalid()
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
void test_OpDetID_normal ( )

Definition at line 287 of file geo_types_fhicl_test.cc.

287  {
288 
289  using ID_t = geo::OpDetID;
290  struct Config { geo::fhicl::OpDetID OpDet { fhicl::Name("OpDet") }; };
291 
292  std::string const configStr { "OpDet: { C:2 O:3 }" };
293  ID_t const expectedID { 2U, 3U };
294 
295  auto validatedConfig = validateConfig<Config>(configStr)();
296 
297  auto const id = geo::fhicl::readID(validatedConfig.OpDet);
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);
303  }
304 } // test_OpDetID_normal()
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
void test_OpDetIDsequence_empty ( )

Definition at line 400 of file geo_types_fhicl_test.cc.

400  {
401 
402  using ID_t = geo::OpDetID;
403  struct Config
404  { geo::fhicl::OpDetIDsequence OpDets { fhicl::Name("OpDets") }; };
405 
406  std::string const configStr { "OpDets: []" };
407 
408  auto validatedConfig = validateConfig<Config>(configStr)();
409 
410  auto ids = geo::fhicl::readIDsequence(validatedConfig.OpDets);
411  static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
412 
413  BOOST_TEST(ids.size() == 0U);
414 
415 } // test_OpDetIDsequence_empty()
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
void test_OpDetIDsequence_normal ( )

Definition at line 369 of file geo_types_fhicl_test.cc.

369  {
370 
371  using ID_t = geo::OpDetID;
372  struct Config
373  { geo::fhicl::OpDetIDsequence OpDets { fhicl::Name("OpDets") }; };
374 
375  std::string const configStr { "OpDets: [ { C:0 O:1 }, { C:2 O:3 } ]" };
376  // BUG the double brace syntax is required to work around clang bug 21629
377 // std::array<ID_t, 2U> const expectedIDs { ID_t{ 0U, 1U }, ID_t{ 2U, 3U } };
378  std::array<ID_t, 2U> const expectedIDs {{ ID_t{ 0U, 1U }, ID_t{ 2U, 3U } }};
379 
380  auto validatedConfig = validateConfig<Config>(configStr)();
381 
382  auto ids = geo::fhicl::readIDsequence(validatedConfig.OpDets);
383  static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
384 
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];
390 
391  BOOST_TEST_CONTEXT("Item [" << i << "]") {
392  BOOST_TEST(id.isValid == expectedID.isValid);
393  if (expectedID.isValid) BOOST_TEST(id == expectedID);
394  } // BOOST_TEST_CONTEXT
395  } // for
396 
397 } // test_OpDetIDsequence_normal()
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_OptionalCryostatID_omitted ( )

Definition at line 111 of file geo_types_fhicl_test.cc.

111  {
112 
113  using ID_t = geo::CryostatID;
114  struct Config { geo::fhicl::OptionalCryostatID Cryo { fhicl::Name("Cryo") }; };
115 
116  std::string const configStr { "" };
117 
118  std::optional<ID_t> const expectedID;
119 
120  auto validatedConfig = validateConfig<Config>(configStr)();
121 
122  std::optional<ID_t> const id
123  = geo::fhicl::readOptionalID(validatedConfig.Cryo);
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());
128  }
129 
130 } // test_OptionalCryostatID_omitted()
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
void test_OptionalCryostatID_present ( )

Definition at line 91 of file geo_types_fhicl_test.cc.

91  {
92 
93  using ID_t = geo::CryostatID;
94  struct Config { geo::fhicl::OptionalCryostatID Cryo { fhicl::Name("Cryo") }; };
95 
96  std::string const configStr { "Cryo: { C:1 }" };
97  auto const expectedID = std::make_optional<ID_t>(1U);
98 
99  auto validatedConfig = validateConfig<Config>(configStr)();
100 
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());
106  }
107 
108 } // test_OptionalCryostatID_present()
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
void test_OptionalCryostatIDsequence_empty ( )

Definition at line 216 of file geo_types_fhicl_test.cc.

216  {
217 
218  using ID_t = geo::CryostatID;
219  struct Config
220  { geo::fhicl::OptionalCryostatIDsequence Cryos { fhicl::Name("Cryos") }; };
221 
222  std::string const configStr { "Cryos: []" };
223  std::optional<std::vector<ID_t>> const expectedIDs(std::in_place);
224 
225  auto validatedConfig = validateConfig<Config>(configStr)();
226 
227  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.Cryos);
228  static_assert
229  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
230 
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];
238 
239  BOOST_TEST_CONTEXT("Item [" << i << "]") {
240  BOOST_TEST(id.isValid == expectedID.isValid);
241  if (expectedID.isValid) BOOST_TEST(id == expectedID);
242  } // BOOST_TEST_CONTEXT
243  } // for
244  }
245 
246 } // test_OptionalCryostatIDsequence_empty()
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_OptionalCryostatIDsequence_normal ( )

Definition at line 182 of file geo_types_fhicl_test.cc.

182  {
183 
184  using ID_t = geo::CryostatID;
185  struct Config
186  { geo::fhicl::OptionalCryostatIDsequence Cryos { fhicl::Name("Cryos") }; };
187 
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 } });
191 
192  auto validatedConfig = validateConfig<Config>(configStr)();
193 
194  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.Cryos);
195  static_assert
196  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
197 
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];
205 
206  BOOST_TEST_CONTEXT("Item [" << i << "]") {
207  BOOST_TEST(id.isValid == expectedID.isValid);
208  if (expectedID.isValid) BOOST_TEST(id == expectedID);
209  } // BOOST_TEST_CONTEXT
210  } // for
211  }
212 
213 } // test_OptionalCryostatIDsequence_normal()
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_OptionalCryostatIDsequence_omitted ( )

Definition at line 249 of file geo_types_fhicl_test.cc.

249  {
250 
251  using ID_t = geo::CryostatID;
252  struct Config
253  { geo::fhicl::OptionalCryostatIDsequence Cryos { fhicl::Name("Cryos") }; };
254 
255  std::string const configStr { "" };
256  std::optional<std::vector<ID_t>> const expectedIDs(std::nullopt);
257 
258  auto validatedConfig = validateConfig<Config>(configStr)();
259 
260  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.Cryos);
261  static_assert
262  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
263 
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];
271 
272  BOOST_TEST_CONTEXT("Item [" << i << "]") {
273  BOOST_TEST(id.isValid == expectedID.isValid);
274  if (expectedID.isValid) BOOST_TEST(id == expectedID);
275  } // BOOST_TEST_CONTEXT
276  } // for
277  }
278 
279 } // test_OptionalCryostatIDsequence_omitted()
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_OptionalOpDetID_omitted ( )

Definition at line 347 of file geo_types_fhicl_test.cc.

347  {
348 
349  using ID_t = geo::OpDetID;
350  struct Config { geo::fhicl::OptionalOpDetID OpDet { fhicl::Name("OpDet") }; };
351 
352  std::string const configStr { "" };
353 
354  std::optional<ID_t> const expectedID { std::nullopt };
355 
356  auto validatedConfig = validateConfig<Config>(configStr)();
357 
358  std::optional<ID_t> const id
359  = geo::fhicl::readOptionalID(validatedConfig.OpDet);
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());
364  }
365 
366 } // test_OptionalOpDetID_omitted()
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
void test_OptionalOpDetID_present ( )

Definition at line 327 of file geo_types_fhicl_test.cc.

327  {
328 
329  using ID_t = geo::OpDetID;
330  struct Config { geo::fhicl::OptionalOpDetID OpDet { fhicl::Name("OpDet") }; };
331 
332  std::string const configStr { "OpDet: { C:1 O:2 }" };
333  std::optional<ID_t> const expectedID { std::in_place, 1U, 2U };
334 
335  auto validatedConfig = validateConfig<Config>(configStr)();
336 
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());
342  }
343 
344 } // test_OptionalOpDetID_present()
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
void test_OptionalOpDetIDsequence_empty ( )

Definition at line 452 of file geo_types_fhicl_test.cc.

452  {
453 
454  using ID_t = geo::OpDetID;
455  struct Config
456  { geo::fhicl::OptionalOpDetIDsequence OpDets { fhicl::Name("OpDets") }; };
457 
458  std::string const configStr { "OpDets: []" };
459  std::optional<std::vector<ID_t>> const expectedIDs(std::in_place);
460 
461  auto validatedConfig = validateConfig<Config>(configStr)();
462 
463  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.OpDets);
464  static_assert
465  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
466 
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];
474 
475  BOOST_TEST_CONTEXT("Item [" << i << "]") {
476  BOOST_TEST(id.isValid == expectedID.isValid);
477  if (expectedID.isValid) BOOST_TEST(id == expectedID);
478  } // BOOST_TEST_CONTEXT
479  } // for
480  }
481 
482 } // test_OptionalOpDetIDsequence_empty()
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_OptionalOpDetIDsequence_normal ( )

Definition at line 418 of file geo_types_fhicl_test.cc.

418  {
419 
420  using ID_t = geo::OpDetID;
421  struct Config
422  { geo::fhicl::OptionalOpDetIDsequence OpDets { fhicl::Name("OpDets") }; };
423 
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 } });
427 
428  auto validatedConfig = validateConfig<Config>(configStr)();
429 
430  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.OpDets);
431  static_assert
432  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
433 
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];
441 
442  BOOST_TEST_CONTEXT("Item [" << i << "]") {
443  BOOST_TEST(id.isValid == expectedID.isValid);
444  if (expectedID.isValid) BOOST_TEST(id == expectedID);
445  } // BOOST_TEST_CONTEXT
446  } // for
447  }
448 
449 } // test_OptionalOpDetIDsequence_normal()
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_OptionalOpDetIDsequence_omitted ( )

Definition at line 485 of file geo_types_fhicl_test.cc.

485  {
486 
487  using ID_t = geo::OpDetID;
488  struct Config
489  { geo::fhicl::OptionalOpDetIDsequence OpDets { fhicl::Name("OpDets") }; };
490 
491  std::string const configStr { "" };
492  std::optional<std::vector<ID_t>> const expectedIDs(std::nullopt);
493 
494  auto validatedConfig = validateConfig<Config>(configStr)();
495 
496  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.OpDets);
497  static_assert
498  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
499 
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];
507 
508  BOOST_TEST_CONTEXT("Item [" << i << "]") {
509  BOOST_TEST(id.isValid == expectedID.isValid);
510  if (expectedID.isValid) BOOST_TEST(id == expectedID);
511  } // BOOST_TEST_CONTEXT
512  } // for
513  }
514 
515 } // test_OptionalOpDetIDsequence_omitted()
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_OptionalPlaneID_omitted ( )

Definition at line 817 of file geo_types_fhicl_test.cc.

817  {
818 
819  using ID_t = geo::PlaneID;
820  struct Config { geo::fhicl::OptionalPlaneID Plane { fhicl::Name("Plane") }; };
821 
822  std::string const configStr { "" };
823 
824  std::optional<ID_t> const expectedID { std::nullopt };
825 
826  auto validatedConfig = validateConfig<Config>(configStr)();
827 
828  std::optional<ID_t> const id
829  = geo::fhicl::readOptionalID(validatedConfig.Plane);
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());
834  }
835 
836 } // test_OptionalPlaneID_omitted()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
recob::tracking::Plane Plane
Definition: TrackState.h:17
void test_OptionalPlaneID_present ( )

Definition at line 797 of file geo_types_fhicl_test.cc.

797  {
798 
799  using ID_t = geo::PlaneID;
800  struct Config { geo::fhicl::OptionalPlaneID Plane { fhicl::Name("Plane") }; };
801 
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 };
804 
805  auto validatedConfig = validateConfig<Config>(configStr)();
806 
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());
812  }
813 
814 } // test_OptionalPlaneID_present()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
recob::tracking::Plane Plane
Definition: TrackState.h:17
void test_OptionalPlaneIDsequence_empty ( )

Definition at line 925 of file geo_types_fhicl_test.cc.

925  {
926 
927  using ID_t = geo::PlaneID;
928  struct Config
929  { geo::fhicl::OptionalPlaneIDsequence Planes { fhicl::Name("Planes") }; };
930 
931  std::string const configStr { "Planes: []" };
932  std::optional<std::vector<ID_t>> const expectedIDs(std::in_place);
933 
934  auto validatedConfig = validateConfig<Config>(configStr)();
935 
936  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.Planes);
937  static_assert
938  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
939 
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];
947 
948  BOOST_TEST_CONTEXT("Item [" << i << "]") {
949  BOOST_TEST(id.isValid == expectedID.isValid);
950  if (expectedID.isValid) BOOST_TEST(id == expectedID);
951  } // BOOST_TEST_CONTEXT
952  } // for
953  }
954 
955 } // test_OptionalPlaneIDsequence_empty()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
void test_OptionalPlaneIDsequence_normal ( )

Definition at line 890 of file geo_types_fhicl_test.cc.

890  {
891 
892  using ID_t = geo::PlaneID;
893  struct Config
894  { geo::fhicl::OptionalPlaneIDsequence Planes { fhicl::Name("Planes") }; };
895 
896  std::string const configStr
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 } });
900 
901  auto validatedConfig = validateConfig<Config>(configStr)();
902 
903  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.Planes);
904  static_assert
905  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
906 
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];
914 
915  BOOST_TEST_CONTEXT("Item [" << i << "]") {
916  BOOST_TEST(id.isValid == expectedID.isValid);
917  if (expectedID.isValid) BOOST_TEST(id == expectedID);
918  } // BOOST_TEST_CONTEXT
919  } // for
920  }
921 
922 } // test_OptionalPlaneIDsequence_normal()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
void test_OptionalPlaneIDsequence_omitted ( )

Definition at line 958 of file geo_types_fhicl_test.cc.

958  {
959 
960  using ID_t = geo::PlaneID;
961  struct Config
962  { geo::fhicl::OptionalPlaneIDsequence Planes { fhicl::Name("Planes") }; };
963 
964  std::string const configStr { "" };
965  std::optional<std::vector<ID_t>> const expectedIDs(std::nullopt);
966 
967  auto validatedConfig = validateConfig<Config>(configStr)();
968 
969  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.Planes);
970  static_assert
971  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
972 
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];
980 
981  BOOST_TEST_CONTEXT("Item [" << i << "]") {
982  BOOST_TEST(id.isValid == expectedID.isValid);
983  if (expectedID.isValid) BOOST_TEST(id == expectedID);
984  } // BOOST_TEST_CONTEXT
985  } // for
986  }
987 
988 } // test_OptionalPlaneIDsequence_omitted()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
void test_OptionalTPCID_omitted ( )

Definition at line 582 of file geo_types_fhicl_test.cc.

582  {
583 
584  using ID_t = geo::TPCID;
585  struct Config { geo::fhicl::OptionalTPCID TPC { fhicl::Name("TPC") }; };
586 
587  std::string const configStr { "" };
588 
589  std::optional<ID_t> const expectedID { std::nullopt };
590 
591  auto validatedConfig = validateConfig<Config>(configStr)();
592 
593  std::optional<ID_t> const id
594  = geo::fhicl::readOptionalID(validatedConfig.TPC);
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());
599  }
600 
601 } // test_OptionalTPCID_omitted()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void test_OptionalTPCID_present ( )

Definition at line 562 of file geo_types_fhicl_test.cc.

562  {
563 
564  using ID_t = geo::TPCID;
565  struct Config { geo::fhicl::OptionalTPCID TPC { fhicl::Name("TPC") }; };
566 
567  std::string const configStr { "TPC: { C:1 T:2 }" };
568  std::optional<ID_t> const expectedID { std::in_place, 1U, 2U };
569 
570  auto validatedConfig = validateConfig<Config>(configStr)();
571 
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());
577  }
578 
579 } // test_OptionalTPCID_present()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void test_OptionalTPCIDsequence_empty ( )

Definition at line 687 of file geo_types_fhicl_test.cc.

687  {
688 
689  using ID_t = geo::TPCID;
690  struct Config
691  { geo::fhicl::OptionalTPCIDsequence TPCs { fhicl::Name("TPCs") }; };
692 
693  std::string const configStr { "TPCs: []" };
694  std::optional<std::vector<ID_t>> const expectedIDs(std::in_place);
695 
696  auto validatedConfig = validateConfig<Config>(configStr)();
697 
698  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.TPCs);
699  static_assert
700  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
701 
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];
709 
710  BOOST_TEST_CONTEXT("Item [" << i << "]") {
711  BOOST_TEST(id.isValid == expectedID.isValid);
712  if (expectedID.isValid) BOOST_TEST(id == expectedID);
713  } // BOOST_TEST_CONTEXT
714  } // for
715  }
716 
717 } // test_OptionalTPCIDsequence_empty()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void test_OptionalTPCIDsequence_normal ( )

Definition at line 653 of file geo_types_fhicl_test.cc.

653  {
654 
655  using ID_t = geo::TPCID;
656  struct Config
657  { geo::fhicl::OptionalTPCIDsequence TPCs { fhicl::Name("TPCs") }; };
658 
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 } });
662 
663  auto validatedConfig = validateConfig<Config>(configStr)();
664 
665  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.TPCs);
666  static_assert
667  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
668 
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];
676 
677  BOOST_TEST_CONTEXT("Item [" << i << "]") {
678  BOOST_TEST(id.isValid == expectedID.isValid);
679  if (expectedID.isValid) BOOST_TEST(id == expectedID);
680  } // BOOST_TEST_CONTEXT
681  } // for
682  }
683 
684 } // test_OptionalTPCIDsequence_normal()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void test_OptionalTPCIDsequence_omitted ( )

Definition at line 720 of file geo_types_fhicl_test.cc.

720  {
721 
722  using ID_t = geo::TPCID;
723  struct Config
724  { geo::fhicl::OptionalTPCIDsequence TPCs { fhicl::Name("TPCs") }; };
725 
726  std::string const configStr { "" };
727  std::optional<std::vector<ID_t>> const expectedIDs(std::nullopt);
728 
729  auto validatedConfig = validateConfig<Config>(configStr)();
730 
731  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.TPCs);
732  static_assert
733  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
734 
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];
742 
743  BOOST_TEST_CONTEXT("Item [" << i << "]") {
744  BOOST_TEST(id.isValid == expectedID.isValid);
745  if (expectedID.isValid) BOOST_TEST(id == expectedID);
746  } // BOOST_TEST_CONTEXT
747  } // for
748  }
749 
750 } // test_OptionalTPCIDsequence_omitted()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void test_OptionalWireID_omitted ( )

Definition at line 1055 of file geo_types_fhicl_test.cc.

1055  {
1056 
1057  using ID_t = geo::WireID;
1058  struct Config { geo::fhicl::OptionalWireID Wire { fhicl::Name("Wire") }; };
1059 
1060  std::string const configStr { "" };
1061 
1062  std::optional<ID_t> const expectedID { std::nullopt };
1063 
1064  auto validatedConfig = validateConfig<Config>(configStr)();
1065 
1066  std::optional<ID_t> const id
1067  = geo::fhicl::readOptionalID(validatedConfig.Wire);
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());
1072  }
1073 
1074 } // test_OptionalWireID_omitted()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
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_OptionalWireID_present ( )

Definition at line 1035 of file geo_types_fhicl_test.cc.

1035  {
1036 
1037  using ID_t = geo::WireID;
1038  struct Config { geo::fhicl::OptionalWireID Wire { fhicl::Name("Wire") }; };
1039 
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 };
1042 
1043  auto validatedConfig = validateConfig<Config>(configStr)();
1044 
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());
1050  }
1051 
1052 } // test_OptionalWireID_present()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
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_OptionalWireIDsequence_empty ( )

Definition at line 1163 of file geo_types_fhicl_test.cc.

1163  {
1164 
1165  using ID_t = geo::WireID;
1166  struct Config
1167  { geo::fhicl::OptionalWireIDsequence Wires { fhicl::Name("Wires") }; };
1168 
1169  std::string const configStr { "Wires: []" };
1170  std::optional<std::vector<ID_t>> const expectedIDs(std::in_place);
1171 
1172  auto validatedConfig = validateConfig<Config>(configStr)();
1173 
1174  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.Wires);
1175  static_assert
1176  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
1177 
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];
1185 
1186  BOOST_TEST_CONTEXT("Item [" << i << "]") {
1187  BOOST_TEST(id.isValid == expectedID.isValid);
1188  if (expectedID.isValid) BOOST_TEST(id == expectedID);
1189  } // BOOST_TEST_CONTEXT
1190  } // for
1191  }
1192 
1193 } // test_OptionalWireIDsequence_empty()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_OptionalWireIDsequence_normal ( )

Definition at line 1128 of file geo_types_fhicl_test.cc.

1128  {
1129 
1130  using ID_t = geo::WireID;
1131  struct Config
1132  { geo::fhicl::OptionalWireIDsequence Wires { fhicl::Name("Wires") }; };
1133 
1134  std::string const configStr
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 } });
1138 
1139  auto validatedConfig = validateConfig<Config>(configStr)();
1140 
1141  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.Wires);
1142  static_assert
1143  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
1144 
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];
1152 
1153  BOOST_TEST_CONTEXT("Item [" << i << "]") {
1154  BOOST_TEST(id.isValid == expectedID.isValid);
1155  if (expectedID.isValid) BOOST_TEST(id == expectedID);
1156  } // BOOST_TEST_CONTEXT
1157  } // for
1158  }
1159 
1160 } // test_OptionalWireIDsequence_normal()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_OptionalWireIDsequence_omitted ( )

Definition at line 1196 of file geo_types_fhicl_test.cc.

1196  {
1197 
1198  using ID_t = geo::WireID;
1199  struct Config
1200  { geo::fhicl::OptionalWireIDsequence Wires { fhicl::Name("Wires") }; };
1201 
1202  std::string const configStr { "" };
1203  std::optional<std::vector<ID_t>> const expectedIDs(std::nullopt);
1204 
1205  auto validatedConfig = validateConfig<Config>(configStr)();
1206 
1207  auto ids = geo::fhicl::readOptionalIDsequence(validatedConfig.Wires);
1208  static_assert
1209  (std::is_same_v<decltype(ids), std::optional<std::vector<ID_t>>>);
1210 
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];
1218 
1219  BOOST_TEST_CONTEXT("Item [" << i << "]") {
1220  BOOST_TEST(id.isValid == expectedID.isValid);
1221  if (expectedID.isValid) BOOST_TEST(id == expectedID);
1222  } // BOOST_TEST_CONTEXT
1223  } // for
1224  }
1225 
1226 } // test_OptionalWireIDsequence_omitted()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::void_t< T > n
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_PlaneID_invalid ( )

Definition at line 777 of file geo_types_fhicl_test.cc.

777  {
778 
779  using ID_t = geo::PlaneID;
780  struct Config { geo::fhicl::PlaneID Plane { fhicl::Name("Plane") }; };
781 
782  std::string const configStr { "Plane: { isValid:false }" };
783  ID_t const expectedID {};
784 
785  auto validatedConfig = validateConfig<Config>(configStr)();
786 
787  auto const id = geo::fhicl::readID(validatedConfig.Plane);
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);
793  }
794 } // test_PlaneID_invalid()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
recob::tracking::Plane Plane
Definition: TrackState.h:17
void test_PlaneID_normal ( )

Definition at line 757 of file geo_types_fhicl_test.cc.

757  {
758 
759  using ID_t = geo::PlaneID;
760  struct Config { geo::fhicl::PlaneID Plane { fhicl::Name("Plane") }; };
761 
762  std::string const configStr { "Plane: { C:2 T:3 P:1 }" };
763  ID_t const expectedID { 2U, 3U, 1U };
764 
765  auto validatedConfig = validateConfig<Config>(configStr)();
766 
767  auto const id = geo::fhicl::readID(validatedConfig.Plane);
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);
773  }
774 } // test_PlaneID_normal()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
recob::tracking::Plane Plane
Definition: TrackState.h:17
void test_PlaneIDsequence_empty ( )

Definition at line 872 of file geo_types_fhicl_test.cc.

872  {
873 
874  using ID_t = geo::PlaneID;
875  struct Config
876  { geo::fhicl::PlaneIDsequence Planes { fhicl::Name("Planes") }; };
877 
878  std::string const configStr { "Planes: []" };
879 
880  auto validatedConfig = validateConfig<Config>(configStr)();
881 
882  auto ids = geo::fhicl::readIDsequence(validatedConfig.Planes);
883  static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
884 
885  BOOST_TEST(ids.size() == 0U);
886 
887 } // test_PlaneIDsequence_empty()
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
void test_PlaneIDsequence_normal ( )

Definition at line 839 of file geo_types_fhicl_test.cc.

839  {
840 
841  using ID_t = geo::PlaneID;
842  struct Config
843  { geo::fhicl::PlaneIDsequence Planes { fhicl::Name("Planes") }; };
844 
845  std::string const configStr
846  { "Planes: [ { C:0 T:1 P:1 }, { C:2 T:3 P:0 } ]" };
847  std::array<ID_t, 2U> const expectedIDs
848  // BUG the double brace syntax is required to work around clang bug 21629
849 // { ID_t{ 0U, 1U, 1U }, ID_t{ 2U, 3U, 0U } };
850  {{ ID_t{ 0U, 1U, 1U }, ID_t{ 2U, 3U, 0U } }};
851 
852  auto validatedConfig = validateConfig<Config>(configStr)();
853 
854  auto ids = geo::fhicl::readIDsequence(validatedConfig.Planes);
855  static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
856 
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];
862 
863  BOOST_TEST_CONTEXT("Item [" << i << "]") {
864  BOOST_TEST(id.isValid == expectedID.isValid);
865  if (expectedID.isValid) BOOST_TEST(id == expectedID);
866  } // BOOST_TEST_CONTEXT
867  } // for
868 
869 } // test_PlaneIDsequence_normal()
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
void test_TPCID_invalid ( )

Definition at line 542 of file geo_types_fhicl_test.cc.

542  {
543 
544  using ID_t = geo::TPCID;
545  struct Config { geo::fhicl::TPCID TPC { fhicl::Name("TPC") }; };
546 
547  std::string const configStr { "TPC: { isValid:false }" };
548  ID_t const expectedID {};
549 
550  auto validatedConfig = validateConfig<Config>(configStr)();
551 
552  auto const id = geo::fhicl::readID(validatedConfig.TPC);
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);
558  }
559 } // test_TPCID_invalid()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void test_TPCID_normal ( )

Definition at line 522 of file geo_types_fhicl_test.cc.

522  {
523 
524  using ID_t = geo::TPCID;
525  struct Config { geo::fhicl::TPCID TPC { fhicl::Name("TPC") }; };
526 
527  std::string const configStr { "TPC: { C:2 T:3 }" };
528  ID_t const expectedID { 2U, 3U };
529 
530  auto validatedConfig = validateConfig<Config>(configStr)();
531 
532  auto const id = geo::fhicl::readID(validatedConfig.TPC);
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);
538  }
539 } // test_TPCID_normal()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void test_TPCIDsequence_empty ( )

Definition at line 635 of file geo_types_fhicl_test.cc.

635  {
636 
637  using ID_t = geo::TPCID;
638  struct Config
639  { geo::fhicl::TPCIDsequence TPCs { fhicl::Name("TPCs") }; };
640 
641  std::string const configStr { "TPCs: []" };
642 
643  auto validatedConfig = validateConfig<Config>(configStr)();
644 
645  auto ids = geo::fhicl::readIDsequence(validatedConfig.TPCs);
646  static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
647 
648  BOOST_TEST(ids.size() == 0U);
649 
650 } // test_TPCIDsequence_empty()
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void test_TPCIDsequence_normal ( )

Definition at line 604 of file geo_types_fhicl_test.cc.

604  {
605 
606  using ID_t = geo::TPCID;
607  struct Config
608  { geo::fhicl::TPCIDsequence TPCs { fhicl::Name("TPCs") }; };
609 
610  std::string const configStr { "TPCs: [ { C:0 T:1 }, { C:2 T:3 } ]" };
611  // BUG the double brace syntax is required to work around clang bug 21629
612 // std::array<ID_t, 2U> const expectedIDs { ID_t{ 0U, 1U }, ID_t{ 2U, 3U } };
613  std::array<ID_t, 2U> const expectedIDs {{ ID_t{ 0U, 1U }, ID_t{ 2U, 3U } }};
614 
615  auto validatedConfig = validateConfig<Config>(configStr)();
616 
617  auto ids = geo::fhicl::readIDsequence(validatedConfig.TPCs);
618  static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
619 
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];
625 
626  BOOST_TEST_CONTEXT("Item [" << i << "]") {
627  BOOST_TEST(id.isValid == expectedID.isValid);
628  if (expectedID.isValid) BOOST_TEST(id == expectedID);
629  } // BOOST_TEST_CONTEXT
630  } // for
631 
632 } // test_TPCIDsequence_normal()
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
std::void_t< T > n
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void test_WireID_invalid ( )

Definition at line 1015 of file geo_types_fhicl_test.cc.

1015  {
1016 
1017  using ID_t = geo::WireID;
1018  struct Config { geo::fhicl::WireID Wire { fhicl::Name("Wire") }; };
1019 
1020  std::string const configStr { "Wire: { isValid:false }" };
1021  ID_t const expectedID {};
1022 
1023  auto validatedConfig = validateConfig<Config>(configStr)();
1024 
1025  auto const id = geo::fhicl::readID(validatedConfig.Wire);
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);
1031  }
1032 } // test_WireID_invalid()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void test_WireID_normal ( )

Definition at line 995 of file geo_types_fhicl_test.cc.

995  {
996 
997  using ID_t = geo::WireID;
998  struct Config { geo::fhicl::WireID Wire { fhicl::Name("Wire") }; };
999 
1000  std::string const configStr { "Wire: { C:2 T:3 P:1 W:9 }" };
1001  ID_t const expectedID { 2U, 3U, 1U, 9U };
1002 
1003  auto validatedConfig = validateConfig<Config>(configStr)();
1004 
1005  auto const id = geo::fhicl::readID(validatedConfig.Wire);
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);
1011  }
1012 } // test_WireID_normal()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void test_WireIDsequence_empty ( )

Definition at line 1110 of file geo_types_fhicl_test.cc.

1110  {
1111 
1112  using ID_t = geo::WireID;
1113  struct Config
1114  { geo::fhicl::WireIDsequence Wires { fhicl::Name("Wires") }; };
1115 
1116  std::string const configStr { "Wires: []" };
1117 
1118  auto validatedConfig = validateConfig<Config>(configStr)();
1119 
1120  auto ids = geo::fhicl::readIDsequence(validatedConfig.Wires);
1121  static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
1122 
1123  BOOST_TEST(ids.size() == 0U);
1124 
1125 } // test_WireIDsequence_empty()
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void test_WireIDsequence_normal ( )

Definition at line 1077 of file geo_types_fhicl_test.cc.

1077  {
1078 
1079  using ID_t = geo::WireID;
1080  struct Config
1081  { geo::fhicl::WireIDsequence Wires { fhicl::Name("Wires") }; };
1082 
1083  std::string const configStr
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
1086  // BUG the double brace syntax is required to work around clang bug 21629
1087 // { ID_t{ 0U, 1U, 1U, 9U }, ID_t{ 2U, 3U, 0U, 7U } };
1088  {{ ID_t{ 0U, 1U, 1U, 9U }, ID_t{ 2U, 3U, 0U, 7U } }};
1089 
1090  auto validatedConfig = validateConfig<Config>(configStr)();
1091 
1092  auto ids = geo::fhicl::readIDsequence(validatedConfig.Wires);
1093  static_assert(std::is_same_v<decltype(ids), std::vector<ID_t>>);
1094 
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];
1100 
1101  BOOST_TEST_CONTEXT("Item [" << i << "]") {
1102  BOOST_TEST(id.isValid == expectedID.isValid);
1103  if (expectedID.isValid) BOOST_TEST(id == expectedID);
1104  } // BOOST_TEST_CONTEXT
1105  } // for
1106 
1107 } // test_WireIDsequence_normal()
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::void_t< T > n
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void test_WireUnifiedInterface ( )

Definition at line 1229 of file geo_types_fhicl_test.cc.

1229  {
1230 
1231  using ID_t = geo::WireID;
1232  struct Config {
1233 
1234  geo::fhicl::WireID Wire { fhicl::Name("Wire") };
1235 
1236  geo::fhicl::OptionalWireID MaybeWire { fhicl::Name("MaybeWire") };
1237 
1238  geo::fhicl::OptionalWireID NoWire { fhicl::Name("NoWire") };
1239 
1240  geo::fhicl::WireIDsequence Wires { fhicl::Name("Wires") };
1241 
1242  geo::fhicl::OptionalWireIDsequence MaybeWires { fhicl::Name("MaybeWires") };
1243 
1244  geo::fhicl::OptionalWireIDsequence NoWires { fhicl::Name("NoWires") };
1245 
1246  }; // struct Config
1247 
1248  std::string const configStr {
1249  "Wire: { C:1 T:5 P:2 W:9 }"
1250  "\nMaybeWire: { C:1 T:5 P:2 W:8 }"
1251  "\n# NoWire: @nil"
1252  "\n"
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 } ] "
1255  "\n# NoWires: @nil"
1256  "\n"
1257  };
1258 
1259  auto const& config = validateConfig<Config>(configStr);
1260 
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
1264  // BUG the double brace syntax is required to work around clang bug 21629
1265 // { ID_t{ 1U, 5U, 2U, 7U }, ID_t{ 1U, 5U, 2U, 6U } };
1266  {{ ID_t{ 1U, 5U, 2U, 7U }, ID_t{ 1U, 5U, 2U, 6U } }};
1267  std::array<ID_t, 1U> const expected5
1268  // BUG the double brace syntax is required to work around clang bug 21629
1269 // { ID_t{ 1U, 5U, 2U, 5U } };
1270  {{ ID_t{ 1U, 5U, 2U, 5U } }};
1271 
1272  ID_t const default3 { 1U, 5U, 0U, 9U };
1273  auto default3value = default3;
1274 
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 }
1277  });
1278  auto default6value = default6;
1279 
1280  //
1281  // read simple atom
1282  //
1283  auto id11 = geo::fhicl::readParameter(config().Wire);
1284  static_assert(std::is_same_v<decltype(id11), ID_t>);
1285  BOOST_TEST(id11 == expected1);
1286 
1287  //
1288  // read optional atom
1289  //
1290 
1291  // this one is present (default values should be ignored):
1292  auto id21 = geo::fhicl::readParameter(config().MaybeWire);
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);
1296 
1297  default3value = default3;
1298  auto id22 = geo::fhicl::readParameter(config().MaybeWire, default3);
1299  static_assert(std::is_same_v<decltype(id22), ID_t>);
1300  BOOST_TEST(id22 == expected2);
1301  BOOST_TEST(default3value == default3);
1302 
1303  default3value = default3;
1304  auto id23
1305  = geo::fhicl::readParameter(config().MaybeWire, std::move(default3));
1306  static_assert(std::is_same_v<decltype(id23), ID_t>);
1307  BOOST_TEST(id23 == expected2);
1308  BOOST_TEST(default3value == default3);
1309 
1310  // this one is omitted:
1311  auto id31 = geo::fhicl::readParameter(config().NoWire);
1312  static_assert(std::is_same_v<decltype(id31), std::optional<ID_t>>);
1313  BOOST_TEST(!id31.has_value());
1314 
1315  default3value = default3;
1316  auto id32 = geo::fhicl::readParameter(config().NoWire, default3);
1317  static_assert(std::is_same_v<decltype(id32), ID_t>);
1318  BOOST_TEST(id32 == default3);
1319  BOOST_TEST(default3value == default3);
1320 
1321  default3value = default3;
1322  auto id33 = geo::fhicl::readParameter(config().NoWire, std::move(default3));
1323  static_assert(std::is_same_v<decltype(id33), ID_t>);
1324  BOOST_TEST(id33 == default3);
1325 
1326  // test for compilation
1327  auto id34 = geo::fhicl::readParameter(config().NoWire, { 1U, 3U, 6U, 9U });
1328  BOOST_TEST(id34 == (geo::WireID{ 1U, 3U, 6U, 9U }));
1329 
1330 
1331  //
1332  // read sequence
1333  //
1334  auto id41 = geo::fhicl::readParameter(config().Wires);
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]);
1340  }
1341 
1342  //
1343  // read optional sequence
1344  //
1345  // this one is present (default values should be ignored):
1346  auto id51 = geo::fhicl::readParameter(config().MaybeWires);
1347  static_assert
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());
1353  }
1354 
1355  default6value = default6;
1356  auto id52 = geo::fhicl::readParameter(config().MaybeWires, default6value);
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()
1363  );
1364 
1365  default6value = default6;
1366  auto id53
1367  = geo::fhicl::readParameter(config().MaybeWires, std::move(default6value));
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()
1374  );
1375 
1376  // this one is omitted:
1377  auto id61 = geo::fhicl::readParameter(config().NoWires);
1378  static_assert
1379  (std::is_same_v<decltype(id61), std::optional<std::vector<ID_t>>>);
1380  BOOST_TEST(!id61.has_value());
1381 
1382  default6value = default6;
1383  auto id62 = geo::fhicl::readParameter(config().NoWires, default6value);
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()
1390  );
1391 
1392  default6value = default6;
1393  auto id63
1394  = geo::fhicl::readParameter(config().NoWires, std::move(default6value));
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());
1398  // this is a bit out of standard, since after moving an object is guaranteed
1399  // only to be good for destruction; yet usually implementations of std::vector
1400  // leave it as a fully valid empty vector:
1401  BOOST_TEST(default6value.empty());
1402 
1403 } // test_WireUnifiedInterface()
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
static Config * config
Definition: config.cpp:1054
def move(depos, offset)
Definition: depos.py:107
static int max(int a, int b)
ID readParameter(IDparameter< SrcID > const &atom)
template<typename Config >
fhicl::Table<Config> validateConfig ( std::string const &  configStr)

Definition at line 30 of file geo_types_fhicl_test.cc.

30  {
32  pset = fhicl::ParameterSet::make(configStr);
33  fhicl::Table<Config> validatedConfig { fhicl::Name("validatedConfig") };
34 
35  std::cout << std::string(80, '-') << std::endl;
36  std::cout << "===> FHiCL configuration:";
37  if (configStr.empty()) std::cout << " <empty>";
38  else std::cout << "\n" << configStr;
39  std::cout << std::endl;
40  validatedConfig.print_allowed_configuration
41  (std::cout << "===> Expected configuration: ");
42  std::cout << std::endl;
43 
44  validatedConfig.validate_ParameterSet(pset);
45  return validatedConfig;
46 } // validateConfig()
std::string string
Definition: nybbler.cc:12
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
ChannelGroupService::Name Name
QTextStream & endl(QTextStream &s)