17 #define BOOST_TEST_MODULE ProviderList_test
18 #include <boost/test/unit_test.hpp>
35 { TrackedMemory.insert(
this); }
49 { TrackedMemory.insert(
this); }
63 { TrackedMemory.insert(
this); }
76 (
" *** special setup for UnmovableDatumClass *** ");
77 return std::make_unique<UnmovableDatumClass>();
86 virtual bool abstract()
const = 0;
91 { TrackedMemory.insert(
this); }
97 virtual bool abstract()
const override {
return false; }
99 static std::unique_ptr<PinnedDatumClass>
New(
float x,
float y)
117 template <
typename T,
typename LIST>
118 void TestElement(LIST& l, std::string label =
"",
bool present =
true) {
120 BOOST_TEST_MESSAGE(
"Testing class '" <<
typeid(T).
name() <<
"' label \""
121 << label <<
"\" (" << (present?
"present":
"not present") <<
")" );
122 BOOST_TEST(l.template known<T>(label) == present);
123 BOOST_TEST(l.template valid<T>(label) == present);
125 auto const& item = l.template get<T>(label);
130 BOOST_TEST(!present);
136 template <
typename LIST>
139 TestElement<NormalDatumClass>(l);
140 TestElement<UncopiableDatumClass>(l,
"",
false);
141 TestElement<UncopiableDatumClass>(l,
"One");
142 TestElement<UncopiableDatumClass>(l,
"Two",
false);
143 TestElement<UnmovableDatumClass>(l);
144 TestElement<PinnedDatumClass>(l);
145 TestElement<PinnedDatumClassBase>(l);
146 TestElement<int>(l,
"",
false);
149 BOOST_TEST(!l.template get<PinnedDatumClassBase>().abstract());
159 TestElement<UncopiableDatumClass>(l,
"Acquired",
false);
163 l.acquire(std::make_unique<UncopiableDatumClass>
164 (
"another uncopiable"),
"Acquired")
166 TestElement<UncopiableDatumClass>(l,
"Acquired",
true);
170 TestElement<UncopiableDatumClass>(l,
"Acquired",
false);
174 TestElement<UncopiableDatumClass>(l,
"Acquired",
false);
178 TestElement<UncopiableDatumClass>(l,
"Never",
false);
188 BOOST_TEST_MESSAGE(
"Construction and instantiation of ProviderList");
189 auto l = std::make_unique<testing::ProviderList>();
201 BOOST_TEST_MESSAGE(
"Constant list test");
203 BOOST_TEST_MESSAGE(
"Mutable list test");
206 BOOST_TEST_MESSAGE(
"ProviderListTest completed");
210 BOOST_TEST(TrackedMemory.empty());
Container of service providers accessed by type and optional label.
NormalDatumClass & operator=(NormalDatumClass const &)=default
process_name opflash particleana ie x
Exception thrown on a request about an unregistered type.
static std::unique_ptr< PinnedDatumClass > New(float x, float y)
Container for service providers used in a test.
virtual ~PinnedDatumClass()
void ConstTest(testing::ProviderList const &l)
static std::unique_ptr< Prov > setup(Args &&...args)
Instantiates a new provider with specified arguments for constructor.
UncopiableDatumClass(const char *v)
std::unique_ptr< UnmovableDatumClass > setupProvider< UnmovableDatumClass >()
UnmovableDatumClass & operator=(UnmovableDatumClass const &)=default
NormalDatumClass(unsigned int v)
process_name opflash particleana ie ie y
PinnedDatumClass & operator=(PinnedDatumClass const &)=delete
static unsigned int nNewCalls
std::set< void * > TrackedMemory
UncopiableDatumClass & operator=(UncopiableDatumClass const &)=delete
void TestElement(LIST &l, std::string label="", bool present=true)
PinnedDatumClass(float x, float y)
void NonConstTest(testing::ProviderList &l)
virtual ~PinnedDatumClassBase()=default