50 return getVal() + trigger_;
52 return Dummy::calc(i);
60 if (trigger == getVal())
61 throw error::Fatal (
"Subversive Bomb", LUMIERA_ERROR_SUBVERSIVE);
83 using LERR_(ITER_EXHAUST);
118 CHECK (isnil (container));
119 CHECK (0 == container.size());
122 container.populate();
123 CHECK (!isnil (container));
124 CHECK (5 == container.size());
128 CHECK (isnil (container));
129 CHECK (0 == container.size());
132 container.populate();
134 + container[1].getVal()
135 + container[2].getVal()
136 + container[3].getVal()
137 + container[4].getVal());
149 for (
uint i=0; i<coll.capacity(); ++i)
150 coll.emplace<
Dummy>(i);
153 CollD::iterator ii = coll.begin();
156 CHECK (check == ii->getVal());
157 CHECK (check == ii->calc(+5) - 5);
164 CollD const& const_coll (coll);
166 CollD::const_iterator cii = const_coll.begin();
169 CHECK (check == cii->getVal());
177 for (
auto& entry : coll)
179 CHECK (check == entry.getVal());
183 for (
auto const& entry : const_coll)
185 CHECK (check == entry.getVal());
191 CHECK (! (coll.end()));
192 CHECK (isnil (coll.end()));
197 CHECK (ii == coll.end());
198 CHECK (cii == coll.end());
225 CHECK (0 == coll.size());
228 Dummy& d0 = coll.emplaceElement();
229 CHECK (1 == coll.size());
232 CHECK (2 == coll.size());
237 VERIFY_ERROR (SUBVERSIVE, coll.emplace<SubDummy>(rr,rr) );
239 CHECK ( 2 == coll.size());
242 Dummy& d2 = coll.emplace<SubDummy> (rr, rr+1);
243 CHECK (3 == coll.size());
251 CHECK (3 == coll.size());
255 CHECK (d0.
calc(11) == coll[0].getVal() + 11 );
256 CHECK (d1.
calc(22) == rr + 22);
257 CHECK (d2.
calc(33) == rr + 33);
258 CHECK (d2.
calc(0) == rr + (rr+1) );
262 coll.emplace<SubDummy> (11,22);
264 CHECK ( 1 == coll.size());
270 CHECK (d0.
calc(0) == 11 + 22);
302 int trigger = 100 + 5 + 1;
306 CHECK (!isnil (coll));
307 CHECK (6 == coll.size());
310 CHECK (coll[0].calc(0) == 0 + rr);
311 CHECK (coll[1].calc(0) == 1 + rr + trigger);
312 CHECK (coll[2].calc(0) == 2 + rr);
313 CHECK (coll[3].calc(0) == 3 + rr + trigger);
314 CHECK (coll[4].calc(0) == 4 + rr);
315 CHECK (coll[5].calc(0) == 5 + rr + trigger);
382 CollD coll (25, CollD::FillAll() );
384 CHECK (!isnil (coll));
385 CHECK (25 == coll.size());
388 for (CollD::iterator ii = coll.begin(); ii; ++ii)
401 CollD coll (25, CollD::FillWith<SubDummy>() );
403 CHECK (!isnil (coll));
404 CHECK (25 == coll.size());
407 for (CollD::iterator ii = coll.begin(); ii; ++ii)
418 for (
uint i=0; i < source.capacity(); ++i)
419 source.emplace<
uint>(i);
421 CollI coll (20, CollI::pull(source.begin()));
423 CHECK (!isnil (coll));
424 CHECK (20 == coll.size());
425 CHECK (25 == source.size());
427 for (
uint i=0; i < coll.size(); ++i)
429 CHECK (coll[i] == i );
430 CHECK (coll[i] == source[i]);
434 VERIFY_ERROR (ITER_EXHAUST, CollI (50, CollI::pull (source.begin())));
449 CHECK (sum(50) == object_with_embedded_Collection.
useMyNumbers());
A fixed collection of non-copyable polymorphic objects.
A Dummy object for tests.
virtual long calc(int i)
a dummy API operation
static constexpr int DEAD
ScopedCollection< uint > CollI
void buildNumbers(CollI::ElementHolder &storage)
const CollI my_own_Numbers_
Functor to populate the Collection.
void operator()(CollD::ElementHolder &storage)
Populator(int baseOffset, int triggerCode)
void verify_iteratorPopulator()
void verify_defaultPopulator()
void verify_embeddedCollection()
void building_StackStyle()
void verify_subclassPopulator()
void building_RAII_Style()
virtual long calc(int i)
special variant of the dummy API operation:
SubDummy(int id, int trigger)
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.
ScopedCollection< Dummy, sizeof(SubDummy)> CollD
Implementation namespace for support and library code.
int rani(uint bound=_iBOUND())
LumieraError< LERR_(FATAL), Logic > Fatal
Test runner and basic definitions for tests.
bool isnil(lib::time::Duration const &dur)
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Managing a collection of non-copyable polymorphic objects in compact storage.
A collection of frequently used helper functions to support unit testing.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
unittest helper code: test dummy objects to track instances.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.