ProductRegistryHelper_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (ProductRegistryHelper_t)
2 #include "boost/test/unit_test.hpp"
3 
9 
10 using namespace art;
11 
12 namespace {
13  class matches {
14  std::string msg_;
15 
16  public:
17  explicit matches(std::string msg) : msg_{move(msg)} {}
18 
19  bool
20  operator()(art::Exception const& e) const
21  {
22  return e.explain_self().find(msg_) != std::string::npos;
23  }
24  };
25 
26  auto const dummy_pset_id = fhicl::ParameterSet{}.id();
27  ModuleDescription const md{dummy_pset_id,
28  "_NAMEERROR_",
29  "_LABELERROR_",
31  ProcessConfiguration{"Process", dummy_pset_id, {}},
32  true /*isEmulated*/};
33 }
34 
35 BOOST_AUTO_TEST_SUITE(ProductRegistryHelper_t)
36 
38 {
40  prh.produces<int>();
41  BOOST_CHECK_EXCEPTION((prh.reconstitutes<int, InEvent>("label", "instance")),
42  Exception,
43  matches{"'produces' should have been called instead"});
44 }
45 
47 {
49  prh.reconstitutes<int, InEvent>("label", "instance");
50  BOOST_CHECK_EXCEPTION(
51  prh.produces<int>(),
53  matches{"'reconstitutes' should have been called instead"});
54 }
55 
56 BOOST_AUTO_TEST_CASE(reconstitutes_different_module_labels)
57 {
59  prh.reconstitutes<int, InEvent>("label1");
60  prh.reconstitutes<int, InEvent>("label2");
61  BOOST_CHECK_NO_THROW(prh.fillDescriptions(md));
62 }
63 
64 BOOST_AUTO_TEST_CASE(reconstitutes_assns_reversed_types)
65 {
67  prh.reconstitutes<Assns<int, double>, InEvent>("label");
68  prh.reconstitutes<Assns<double, int>, InEvent>("label");
69  BOOST_CHECK_EXCEPTION(
70  prh.fillDescriptions(md),
71  Exception,
72  matches{"That friendly name has already been registered for this module."});
73 }
74 
75 BOOST_AUTO_TEST_SUITE_END()
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
BOOST_AUTO_TEST_CASE(produces)
const double e
def move(depos, offset)
Definition: depos.py:107
ParameterSetID id() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66