28#include <boost/lexical_cast.hpp>
29#include <unordered_map>
41 using boost::lexical_cast;
49 using LERR_(ITER_EXHAUST);
78 current_ = buffer_.c_str();
86 if (pos and *pos and **pos)
89 if (!(pos and *pos and **pos))
100 INFO (
test,
"created TestSource(\"%s\")",
cStr(buffer_));
116 data_.push_back(num--);
134 cout <<
"::" << *
iter;
164 typedef std::unordered_map<string,TimeVar>
HashMap;
181 verify_MapWrappers<TreeMap>();
182 verify_MapWrappers<HashMap>();
184 verify_MultimapIters<TreeMultimap>();
185 verify_MultimapIters<HashMultimap>();
194 TestSource dedicatedSource(
NUM_ELMS);
195 list<int>& rawList(customList.data_);
197 IntIter iii (eachEntry (customList));
198 IntIter isi (eachEntry (rawList.begin(), rawList.end()));
201 CHECK (!isnil (iii));
202 CHECK (!isnil (isi));
203 CHECK (!isnil (cii));
227 WrappedList::iterator sourceValues = customList.begin();
230 auto makeTime = [](
int input_sec) ->
TimeVar
235 TimeIter tIt (transform (sourceValues, makeTime));
236 CHECK (!isnil (tIt));
249 CHECK (not isnil(ii));
261 CHECK (not isnil(ii));
283 TimeIter tIter = eachMapVal (testMap);
285 CHECK (sIter and tIter);
289 CHECK (not sIter and not tIter);
295 StringIter justSomeKey = eachMapKey (testMap);
296 TimeIter correspondingVal = eachMapVal (testMap);
301 TimeIter value4key = eachValForKey (testMap,
"nonexistent key");
304 value4key = eachValForKey (testMap, *justSomeKey);
306 CHECK (*value4key == *correspondingVal);
320 do testMap.insert (make_pair (i,n));
323 CHECK (
NUM_ELMS < testMap.size(),
"no repetition in test data??");
325 IntIter keys = eachDistinctKey (testMap);
327 cout <<
"distinct_keys";
332 cout <<
"values_4_key";
336 vals = eachValForKey (testMap, 0);
Iteration source interface to abstract a data source, which then can be accessed through IterAdapter ...
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
void verify_MapWrappers()
IterSource< CStr >::iterator StrIter
IterSource< string >::iterator StringIter
virtual void run(Arg arg)
std::map< string, TimeVar > TreeMap
std::multimap< int, int > TreeMultimap
IterSource< int >::iterator IntIter
void verify_MultimapIters()
void verify_transformIter()
IterSource< TimeVar >::iterator TimeIter
void verify_simpleIters()
std::unordered_multimap< int, int > HashMultimap
void verify_singleValIter()
std::unordered_map< string, TimeVar > HashMap
Explicit implementation of the IterSource interface (test dummy) Creates a random string and chops of...
virtual Pos firstResult() override
iteration start: prepare the first element.
virtual void nextResult(Pos &pos) override
iteration step: switch on to the next element.
a mutable time value, behaving like a plain number, allowing copy and re-accessing
Lumiera's internal time value datatype.
Any copy and copy construction prohibited.
Extension module to build an opaque data source, accessible as Lumiera Forward Iterator.
_MapT< MAP >::KeyIter eachDistinctKey(MAP &map)
_TransformIterT< IT, FUN >::Iter transform(IT &&source, FUN processingFunc)
pipes a given Lumiera Forward Iterator through a transformation function and wraps the resulting tran...
_MapT< MAP >::ValIter eachValForKey(MAP &map, typename _MapT< MAP >::Key key)
auto singleVal(VAL &&something)
an IterSource frontend to return just a single value once.
_MapT< MAP >::KeyIter eachMapKey(MAP &map)
_MapT< MAP >::ValIter eachMapVal(MAP &map)
_SeqT< CON >::Iter eachEntry(CON &container)
lib::time::Time randTime()
create a random but not insane Time value between 1s ... 10min + 500ms
void pullOut(ITER const &i)
string randStr(size_t len)
create garbage string of given length
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Implementation namespace for support and library code.
int rani(uint bound=_iBOUND())
Test runner and basic definitions for tests.
bool isnil(lib::time::Duration const &dur)
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
test dummy: simply wrapping an STL container and exposing a range as Lumiera Forward Iterator
RangeIter< sourceIter > iterator
list< int >::iterator sourceIter
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
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.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...