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)
106 static unsigned int nNewCalls;
108 float value1, value2;
117 template <
typename T,
typename LIST>
120 BOOST_TEST_MESSAGE(
"Testing class '" <<
typeid(
T).
name() <<
"' label \"" 121 <<
label <<
"\" (" << (
present?
"present":
"not present") <<
")" );
125 auto const& item = l.template get<T>(
label);
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
Exception thrown on a request about an unregistered type.
static std::unique_ptr< PinnedDatumClass > New(float x, float y)
virtual ~PinnedDatumClass()
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 >()
std::set< void * > TrackedMemory
NormalDatumClass(unsigned int v)
static unsigned int nNewCalls
void TestElement(LIST &l, std::string label="", bool present=true)
void NonConstTest(testing::ProviderList &l)
void ConstTest(testing::ProviderList const &l)
BOOST_AUTO_TEST_CASE(ProviderListTest)
PinnedDatumClass(float x, float y)
constexpr ProductStatus present() noexcept