49 using LERR_(ITER_EXHAUST);
56 const uint NUM_ELEMENTS = 500;
57 int exception_trigger = -1;
59 inline void __triggerErrorAt(
int i) { exception_trigger = i; }
60 inline void __triggerError_reset() { exception_trigger =-1; }
82 if (i == exception_trigger)
83 throw error::Fatal(
"simulated error", LUMIERA_ERROR_PROVOKED_FAILURE);
97 Num (
int i=0,
int j=0,
int k=0)
126 uint current = num->getVal();
127 if (maxNum_ <= current)
130 num =
new Nummy(current+1);
141 :
public NummyGenerator::iterator
146 : NummyGenerator::iterator (
192 verify_nonOwnership();
193 verify_ExceptionSafety();
194 populate_by_iterator();
195 verify_RAII_safety();
196 verify_customAllocator();
203 CHECK (0 == Dummy::checksum());
206 CHECK (isnil (elements));
207 CHECK (0 == elements.
size());
208 CHECK (0 == Dummy::checksum());
215 CHECK (!isnil (elements));
216 CHECK (5 == elements.
size());
217 CHECK (0 != Dummy::checksum());
219 CHECK (Dummy::checksum() == elements[0].getVal()
220 + elements[1].getVal()
221 + elements[2].getVal()
222 + elements[3].getVal()
223 + elements[4].getVal());
226 CHECK (isnil (elements));
227 CHECK (0 == elements.
size());
228 CHECK (0 == Dummy::checksum());
234 CHECK (3 == elements.
size());
235 CHECK (0 != Dummy::checksum());
237 CHECK (0 == Dummy::checksum());
244 CHECK (0 == Dummy::checksum());
247 for (uint i=1; i<=NUM_ELEMENTS; ++i)
252 int check=NUM_ELEMENTS;
256 CHECK (check == ii->getVal());
257 CHECK (check == ii->acc(+5) - 5);
265 List const& const_elm (elements);
266 check = NUM_ELEMENTS;
270 CHECK (check == cii->getVal());
278 CHECK (! (elements.end()));
279 CHECK (isnil (elements.end()));
284 CHECK (ii == elements.end());
286 CHECK (cii == elements.end());
292 CHECK (0 == Dummy::checksum());
299 CHECK (0 == Dummy::checksum());
302 CHECK (isnil (list));
304 CHECK (isnil (list));
305 CHECK (0 == Dummy::checksum());
308 CHECK (not isnil (list));
309 CHECK (1 == list[0].getVal());
310 CHECK (1 == Dummy::checksum());
312 CHECK (1 == Dummy::checksum());
313 CHECK (1 == list[0].getVal());
314 CHECK (not isnil (list));
317 CHECK (not isnil (list));
318 CHECK (2 == list.
size());
319 CHECK (2 == list[0].getVal());
320 CHECK (2+1 == Dummy::checksum());
322 CHECK (1+2 == Dummy::checksum());
323 CHECK (1 == list[0].getVal());
324 CHECK (2 == list.
size());
327 CHECK (3 == list.
size());
328 CHECK (3 == list.
top().getVal());
329 CHECK (3+1+2 == Dummy::checksum());
331 CHECK (2 == list[0].getVal());
332 CHECK (1 == list[1].getVal());
333 CHECK (3 == list[2].getVal());
335 CHECK (2 == ii->getVal());
337 CHECK (1 == ii->getVal());
339 CHECK (3 == ii->getVal());
342 CHECK (2+1+3 == Dummy::checksum());
345 CHECK (4 == list.
top().getVal());
346 CHECK (3 == list[3].getVal());
348 CHECK (3 == list[0].getVal());
349 CHECK (1 == list[1].getVal());
350 CHECK (2 == list[2].getVal());
351 CHECK (4 == list[3].getVal());
352 CHECK (3+1+2+4 == Dummy::checksum());
354 CHECK (0 == Dummy::checksum());
369 CHECK (0 == Dummy::checksum());
372 CHECK (isnil (elements));
377 CHECK (22+44+66 == Dummy::checksum());
382 CHECK (!isnil (elements));
383 CHECK (3 == elements.
size());
384 CHECK (22+44+66 == Dummy::checksum());
386 CHECK (66 == elements[0].getVal());
387 CHECK (44 == elements[1].getVal());
388 CHECK (22 == elements[2].getVal());
389 CHECK (isSameObject(n2, elements[2]));
390 CHECK (isSameObject(n4, elements[1]));
391 CHECK (isSameObject(n6, elements[0]));
394 CHECK (isnil (elements));
395 CHECK (22+44+66 == Dummy::checksum());
397 CHECK (0 == Dummy::checksum());
402 verify_ExceptionSafety()
404 CHECK (0 == Dummy::checksum());
407 CHECK (isnil (elements));
413 CHECK (1+2 == Dummy::checksum());
416 CHECK (1+2 == Dummy::checksum());
417 CHECK (2 == elements.
size());
419 CHECK (2 == elements[0].getVal());
420 CHECK (1 == elements[1].getVal());
423 CHECK (0 == Dummy::checksum());
424 __triggerError_reset();
426 CHECK (0 == Dummy::checksum());
431 populate_by_iterator()
433 CHECK (0 == Dummy::checksum());
435 Populator yieldSomeElements(NUM_ELEMENTS);
438 CHECK (!isnil (elements));
439 CHECK (NUM_ELEMENTS == elements.
size());
440 CHECK (sum(NUM_ELEMENTS) == Dummy::checksum());
442 int check=NUM_ELEMENTS;
446 CHECK (check == ii->getVal());
452 CHECK (0 == Dummy::checksum());
465 CHECK (0 == Dummy::checksum());
468 Populator yieldSomeElements(NUM_ELEMENTS);
471 CHECK (0 == Dummy::checksum());
472 __triggerError_reset();
477 verify_customAllocator()
479 CHECK (0 == Dummy::checksum());
486 elements.
emplace<Num<3>> (4,5);
487 elements.
emplace<Num<6>> (7,8,9);
489 CHECK (sum(9) == Dummy::checksum());
490 CHECK (3 == allocator.
size());
491 CHECK (1 == allocator.
count<Num<1>>());
492 CHECK (1 == allocator.
count<Num<3>>());
493 CHECK (1 == allocator.
count<Num<6>>());
495 CHECK (3 == elements.
size());
496 CHECK (1+2 == elements[2].getVal());
497 CHECK (3+4+5 == elements[1].getVal());
498 CHECK (6+7+8+9 == elements[0].getVal());
501 CHECK (3 == allocator.
size());
502 CHECK (sum(9) == Dummy::checksum());
506 CHECK (0 == Dummy::checksum());
LinkedElements & reverse()
Mutate the complete list to change the order of elements.
IterQueue< T > elements(T const &elm)
convenience free function to build an iterable sequence
TY & emplace(ARGS &&...args)
prepend object of type TY, forwarding ctor args
size_t count() const
helper for diagnostics
Memory management for the low-level model (render nodes network).
Intrusive single linked list, possibly taking ownership of node elements.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Iterator-Frontend to generate this series of objects.
Implementation namespace for support and library code.
unittest helper code: test dummy objects to track instances.
Derived specific exceptions within Lumiera's exception hierarchy.
Iteration source interface to abstract a data source, which then can be accessed through IterAdapter ...
Simple test class runner.
Another Lumiera Forward Iterator building block, based on incorporating a state type right into the i...
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Helper to produce a pre-determined series of objects to populate a LinkedElements list...
A collection of frequently used helper functions to support unit testing.
Intrusive single linked list with optional ownership.
A Dummy object for tests.
TY & push(TY &elm)
accept the given element and prepend it to the list of elements; depending on the allocation policy...
A pile of objects sharing common allocation and lifecycle.
void verify_RAII_safety()
to demonstrate holding subclasses
virtual Pos firstResult()
iteration start: prepare the first element.
virtual void nextResult(Pos &num)
iteration step: switch on to the next element.
void verify_nonOwnership()
Extension module to build an opaque data source, accessible as Lumiera Forward Iterator.
Test-Element, supporting intrusive linked list storage.
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.
bool isSameObject(A const &a, B const &b)
compare plain object identity, bypassing any custom comparison operators.