28 #include <boost/lexical_cast.hpp> 29 #include <unordered_map> 41 using boost::lexical_cast;
49 using LERR_(ITER_EXHAUST);
51 using iter_source::eachEntry;
52 using iter_source::transform;
53 using iter_source::singleVal;
54 using iter_source::eachMapKey;
55 using iter_source::eachMapVal;
56 using iter_source::eachValForKey;
57 using iter_source::eachDistinctKey;
78 current_ = buffer_.c_str();
86 if (pos && *pos && **pos)
89 if (!(pos && *pos && **pos))
100 INFO (
test,
"created TestSource(\"%s\")",
cStr(buffer_));
116 data_.push_back(num--);
119 typedef list<int>::iterator sourceIter;
122 iterator begin() {
return iterator(data_.begin(),data_.end()); }
123 iterator end() {
return iterator(); }
133 for ( ; iter; ++iter )
134 cout <<
"::" << *iter;
163 typedef std::map<string,TimeVar> TreeMap;
164 typedef std::unordered_map<string,TimeVar> HashMap;
166 typedef std::multimap<int,int> TreeMultimap;
167 typedef std::unordered_multimap<int,int>HashMultimap;
176 NUM_ELMS = firstVal (arg, 10);
178 verify_simpleIters();
179 verify_transformIter();
181 verify_MapWrappers<TreeMap>();
182 verify_MapWrappers<HashMap>();
184 verify_MultimapIters<TreeMultimap>();
185 verify_MultimapIters<HashMultimap>();
193 WrappedList customList(NUM_ELMS);
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));
226 WrappedList customList(NUM_ELMS);
227 WrappedList::iterator sourceValues = customList.begin();
230 auto makeTime = [](
int input_sec) ->
TimeVar 235 TimeIter tIt (transform (sourceValues, makeTime));
236 CHECK (!isnil (tIt));
248 IntIter ii = singleVal(12);
249 CHECK (not isnil(ii));
261 CHECK (not isnil(ii));
279 for (uint i=0; i<NUM_ELMS; ++i)
282 StringIter sIter = eachMapKey (testMap);
283 TimeIter tIter = eachMapVal (testMap);
285 CHECK (sIter && tIter);
289 CHECK (!sIter && !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);
314 verify_MultimapIters()
317 for (uint i=0; i<NUM_ELMS; ++i)
319 uint n = 1 +
rani(100);
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";
333 IntIter vals = eachValForKey (testMap, NUM_ELMS);
336 vals = eachValForKey (testMap, 0);
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
virtual void nextResult(Pos &pos) override
iteration step: switch on to the next element.
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
Any copy and copy construction prohibited.
int rani(uint bound=_iBOUND())
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
void verify_transformIter()
Implementation namespace for support and library code.
string randStr(size_t len)
create garbage string of given length
Lumiera's internal time value datatype.
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.
Iteration source interface to abstract a data source, which then can be accessed through IterAdapter ...
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
void pullOut(IT &iter)
diagnostics helper
boost::rational< int64_t > FSecs
rational representation of fractional seconds
A collection of frequently used helper functions to support unit testing.
void verify_singleValIter()
lib::time::Time randTime()
create a random but not insane Time value between 1s ...
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
test dummy: simply wrapping an STL container and exposing a range as Lumiera Forward Iterator ...
Extension module to build an opaque data source, accessible as Lumiera Forward Iterator.