61 return getVal() + trigger_;
71 if (trigger == getVal())
72 throw error::Fatal (
"Subversive Bomb", LUMIERA_ERROR_SUBVERSIVE);
94 using LERR_(ITER_EXHAUST);
113 building_RAII_Style();
114 building_StackStyle();
116 verify_defaultPopulator();
117 verify_iteratorPopulator();
118 verify_embeddedCollection();
125 CHECK (0 == Dummy::checksum());
128 CHECK (isnil (container));
129 CHECK (0 == container.size());
130 CHECK (0 == Dummy::checksum());
133 CHECK (!isnil (container));
134 CHECK (5 == container.size());
135 CHECK (0 != Dummy::checksum());
138 CHECK (isnil (container));
139 CHECK (0 == container.size());
140 CHECK (0 == Dummy::checksum());
143 CHECK (Dummy::checksum() == container[0].getVal()
144 + container[1].getVal()
145 + container[2].getVal()
146 + container[3].getVal()
147 + container[4].getVal());
149 CHECK (0 == Dummy::checksum());
156 CHECK (0 == Dummy::checksum());
159 for (uint i=0; i<coll.capacity(); ++i)
166 CHECK (check == ii->getVal());
167 CHECK (check == ii->acc(+5) - 5);
174 CollD
const& const_coll (coll);
179 CHECK (check == cii->getVal());
187 for (
auto&
entry : coll)
189 CHECK (check ==
entry.getVal());
193 for (
auto const&
entry : const_coll)
195 CHECK (check ==
entry.getVal());
201 CHECK (! (coll.end()));
202 CHECK (isnil (coll.end()));
207 CHECK (ii == coll.end());
208 CHECK (cii == coll.end());
213 CHECK (0 == Dummy::checksum());
229 CHECK (0 == Dummy::checksum());
232 int rr = rand() % 100;
235 CHECK (0 == coll.size());
236 CHECK (0 == Dummy::checksum());
239 CHECK (1 == coll.size());
242 CHECK (2 == coll.size());
244 int sum = Dummy::checksum();
249 CHECK ( 2 == coll.size());
250 CHECK (sum == Dummy::checksum());
253 CHECK (3 == coll.size());
255 CHECK (sum + rr == Dummy::checksum());
261 CHECK (3 == coll.size());
262 CHECK (sum + rr == Dummy::checksum());
265 CHECK (d0.
acc(11) == coll[0].getVal() + 11 );
266 CHECK (d1.acc(22) == rr + 22);
267 CHECK (d2.
acc(33) == rr + 33);
268 CHECK (d2.
acc(0) == rr + (rr+1) );
272 coll.
emplace<SubDummy> (11,22);
274 CHECK ( 1 == coll.size());
275 CHECK (11 == Dummy::checksum());
280 CHECK (d0.
acc(0) == 11 + 22);
283 CHECK (d1.acc(44) == rr + 44);
286 CHECK (0 == Dummy::checksum());
309 CHECK (0 == Dummy::checksum());
311 int rr = rand() % 100;
312 int trigger = 100 + 5 + 1;
316 CHECK (!isnil (coll));
317 CHECK (6 == coll.size());
318 CHECK (0 != Dummy::checksum());
320 CHECK (coll[0].acc(0) == 0 + rr);
321 CHECK (coll[1].acc(0) == 1 + rr + trigger);
322 CHECK (coll[2].acc(0) == 2 + rr);
323 CHECK (coll[3].acc(0) == 3 + rr + trigger);
324 CHECK (coll[4].acc(0) == 4 + rr);
325 CHECK (coll[5].acc(0) == 5 + rr + trigger);
335 CHECK (0 == Dummy::checksum());
343 CHECK (0 == Dummy::checksum());
346 CHECK (0 == Dummy::checksum());
357 Populator (
int baseOffset,
int triggerCode)
360 , trigg_(triggerCode)
373 storage.
create<SubDummy> (i_+off_, trigg_);
390 CHECK (0 == Dummy::checksum());
394 CHECK (!isnil (coll));
395 CHECK (25 == coll.size());
396 CHECK (0 != Dummy::checksum());
407 verify_subclassPopulator()
409 CHECK (0 == Dummy::checksum());
413 CHECK (!isnil (coll));
414 CHECK (25 == coll.size());
415 CHECK (0 != Dummy::checksum());
423 verify_iteratorPopulator()
428 for (uint i=0; i < source.capacity(); ++i)
429 source.emplace<uint>(i);
431 CollI coll (20, CollI::pull(source.begin()));
433 CHECK (!isnil (coll));
434 CHECK (20 == coll.size());
435 CHECK (25 == source.size());
437 for (uint i=0; i < coll.size(); ++i)
439 CHECK (coll[i] == i );
440 CHECK (coll[i] == source[i]);
444 VERIFY_ERROR (ITER_EXHAUST, CollI (50, CollI::pull (source.begin())));
459 CHECK (sum(50) == object_with_embedded_Collection.useMyNumbers());
467 const CollI my_own_Numbers_;
472 storage.
create<uint>(memberVar_);
479 , my_own_Numbers_(cnt, &ManagerDemo::buildNumbers,
this)
481 CHECK (0 == memberVar_);
482 CHECK (cnt == my_own_Numbers_.size());
void verify_embeddedCollection()
A fixed collection of non-copyable polymorphic objects.
TY & create(ARGS &&...args)
place object of type TY, forwarding ctor arguments
AnyPair entry(Query< TY > const &query, typename WrapReturn< TY >::Wrapper &obj)
helper to simplify creating mock table entries, wrapped correctly
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.
virtual long acc(int i)
a dummy API operation
void building_RAII_Style()
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
TY & emplace(ARGS &&...args)
push new entry at the end of this container and build object of type TY in place there ...
Implementation namespace for support and library code.
unittest helper code: test dummy objects to track instances.
Managing a collection of non-copyable polymorphic objects in compact storage.
void building_StackStyle()
Storage Frame to hold one Child object.
virtual long acc(int i)
special variant of the dummy API operation:
Derived specific exceptions within Lumiera's exception hierarchy.
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A collection of frequently used helper functions to support unit testing.
A Dummy object for tests.
void populate()
init all elements default constructed
fills the ScopedCollection with default constructed I-instances
void verify_defaultPopulator()
I & emplaceElement()
push a new element of default type to the end of this container
Adapter for building an implementation of the »Lumiera Forward Iterator« concept. ...
Functor to populate the Collection.
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.