29#include <boost/lexical_cast.hpp>
38 using LERR_(ITER_EXHAUST);
39 using boost::lexical_cast;
57 data_.push_back(num--);
83 typedef vector<int *>
_Vec;
87 static void killIt (
int *it) {
delete it; }
94 for (
uint i=0; i<count; ++i)
95 numberz_[i] =
new int(i);
100 for_each (numberz_, killIt);
121 size_t size()
const {
return numberz_.size(); }
155 if ((pos != ITER()) and (pos != src->
numberz_.end()))
217 CHECK (sum == (N-1)*N / 2);
247 typedef vector<int>::iterator I;
250 Range range (iVec.begin(), iVec.end());
251 CHECK (not isnil(range) or not
NUM_ELMS);
256 cout <<
"::" << *range;
261 CHECK (isnil (range));
262 CHECK (range == Range());
276 static void showIntP (
int* elm) { cout <<
"::" << *elm; }
277 static void showInt (
int elm) { cout <<
"::" << elm; }
288 WrappedVector
const& ref (testVec);
299 TestContainer
const& const_elms (elms);
302 for (TestContainer::iterator
iter = elms.begin();
307 CHECK (
iter != elms.end());
310 CHECK (**
iter == i-1);
314 for (TestContainer::const_iterator
iter = const_elms.begin();
319 CHECK (
iter != elms.end());
320 CHECK (**
iter == i-1);
329 for (TestContainer::ref_iterator
iter = elms.begin_ref();
334 CHECK ((*
iter) == i-1);
336 CHECK ((*
iter) == i);
340 for (TestContainer::const_ref_iter
iter = const_elms.begin_ref();
345 CHECK ((*
iter) == i);
353 for (
auto& elm : elms)
360 CHECK (
size_t(i) == elms.size());
363 for (
auto const& elm : elms)
369 CHECK (
size_t(i) == elms.size());
372 for (
auto const& elm : const_elms)
378 CHECK (
size_t(i) == elms.size());
391 typedef vector<int>::iterator RawIter;
395 AddrIter ii(Range(numbz.begin(), numbz.end()));
396 for (
uint i=0; i < numbz.size(); ++i)
400 CHECK (p == & numbz[i]);
408 typedef vector<int>::const_iterator ConstRawIter;
412 ConstAddrIter iic(ConstRange(Range(numbz.begin(), numbz.end())));
413 for (
uint i=0; i < numbz.size(); ++i)
417 CHECK (p == & numbz[i]);
430 TestContainer::ref_iterator rI (elms.begin_ref());
437 TestContainer
const& const_elms (elms);
438 TestContainer::const_ref_iter rI2 (const_elms.begin_ref());
441 CHECK (rI2 == elms.begin_ref());
442 CHECK (rI2 == const_elms.begin_ref());
448 CHECK (!isnil (rI2));
450 CHECK (TestContainer::iterator() == elms.end());
451 CHECK (!(TestContainer::iterator()));
452 CHECK (!(elms.end()));
453 CHECK (isnil (elms.end()));
455 CHECK (elms.begin());
456 CHECK (!isnil (elms.begin()));
wrapper for an existing Iterator type to expose the address of each value yielded.
Adapter for building an implementation of the »Lumiera Forward Iterator« concept.
wrapper for an existing Iterator type, automatically dereferencing the output of the former.
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
static void showInt(int elm)
void simpleUsage(CON &elms)
void useSimpleWrappedContainer()
virtual void run(Arg arg)
void iterTypeVariations(TestContainer &elms)
void exposeDataAddresses()
void verifyComparisons(TestContainer &elms)
static void showIntP(int *elm)
Example of a more elaborate custom container exposing an iteration API.
const_ref_iter begin_ref() const
const_iterator begin() const
PtrDerefIter< const_iterator > const_ref_iter
IterAdapter< _Vec::iterator, const TestContainer * > iterator
static void killIt(int *it)
friend bool checkPoint(const TestContainer *src, ITER &pos)
Implementation of Iteration-logic: detect iteration end.
TestContainer(uint count)
friend void iterNext(const TestContainer *, ITER &pos)
Implementation of Iteration-logic: pull next element.
PtrDerefIter< iterator > ref_iterator
IterAdapter< _Vec::const_iterator, const TestContainer * > const_iterator
const_iterator end() const
Extension adapter for Lumiera Forward Iterators to dereference any pointer values automatically.
Helper template(s) for creating Lumiera Forward Iterators.
Implementation namespace for support and library code.
NumIter< INT > eachNum(INT start=std::numeric_limits< INT >::min(), INT end=std::numeric_limits< INT >::max())
convenience function to iterate "each number"
Test runner and basic definitions for tests.
disable_if< can_IterForEach< Container >, FUN > for_each(Container const &coll, FUN doIt)
operate on all elements of a STL container.
bool isnil(lib::time::Duration const &dur)
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
example of simply wrapping an STL container and exposing a range as Lumiera Forward Iterator
const_iterator begin() const
vector< int >::const_iterator const_sourceIter
RangeIter< const_sourceIter > const_iterator
const_iterator end() const
vector< int >::iterator sourceIter
RangeIter< sourceIter > iterator
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.
Perform operations "for each element" of a collection.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...