37 #include <boost/lexical_cast.hpp> 38 #include <unordered_map> 50 using boost::lexical_cast;
60 using LERR_(ITER_EXHAUST);
62 using iter_source::eachEntry;
63 using iter_source::transform;
64 using iter_source::singleVal;
65 using iter_source::eachMapKey;
66 using iter_source::eachMapVal;
67 using iter_source::eachValForKey;
68 using iter_source::eachDistinctKey;
77 typedef const char* CStr;
94 current_ = buffer_.c_str();
102 if (pos && *pos && **pos)
105 if (!(pos && *pos && **pos))
116 INFO (
test,
"created TestSource(\"%s\")",
cStr(buffer_));
132 data_.push_back(num--);
135 typedef list<int>::iterator sourceIter;
138 iterator begin() {
return iterator(data_.begin(),data_.end()); }
139 iterator end() {
return iterator(); }
149 for ( ; iter; ++iter )
150 cout <<
"::" << *iter;
179 typedef std::map<string,TimeVar> TreeMap;
180 typedef std::unordered_map<string,TimeVar> HashMap;
182 typedef std::multimap<int,int> TreeMultimap;
183 typedef std::unordered_multimap<int,int>HashMultimap;
189 if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
191 verify_simpleIters();
192 verify_transformIter();
194 verify_MapWrappers<TreeMap>();
195 verify_MapWrappers<HashMap>();
197 verify_MultimapIters<TreeMultimap>();
198 verify_MultimapIters<HashMultimap>();
206 WrappedList customList(NUM_ELMS);
207 TestSource dedicatedSource(NUM_ELMS);
208 list<int>& rawList(customList.data_);
210 IntIter iii (eachEntry (customList));
211 IntIter isi (eachEntry (rawList.begin(), rawList.end()));
214 CHECK (!isnil (iii));
215 CHECK (!isnil (isi));
216 CHECK (!isnil (cii));
239 WrappedList customList(NUM_ELMS);
240 WrappedList::iterator sourceValues = customList.begin();
243 auto makeTime = [](
int input_sec) ->
TimeVar 248 TimeIter tIt (transform (sourceValues, makeTime));
249 CHECK (!isnil (tIt));
261 IntIter ii = singleVal(12);
262 CHECK (not isnil(ii));
274 CHECK (not isnil(ii));
292 for (uint i=0; i<NUM_ELMS; ++i)
295 StringIter sIter = eachMapKey (testMap);
296 TimeIter tIter = eachMapVal (testMap);
298 CHECK (sIter && tIter);
302 CHECK (!sIter && !tIter);
308 StringIter justSomeKey = eachMapKey (testMap);
309 TimeIter correspondingVal = eachMapVal (testMap);
314 TimeIter value4key = eachValForKey (testMap,
"nonexistent key");
317 value4key = eachValForKey (testMap, *justSomeKey);
319 CHECK (*value4key == *correspondingVal);
327 verify_MultimapIters()
330 for (uint i=0; i<NUM_ELMS; ++i)
332 uint n = 1 + rand() % 100;
333 do testMap.insert (make_pair (i,n));
336 CHECK (NUM_ELMS < testMap.size(),
"no repetition in test data??");
338 IntIter keys = eachDistinctKey (testMap);
340 cout <<
"distinct_keys";
345 cout <<
"values_4_key";
346 IntIter vals = eachValForKey (testMap, NUM_ELMS);
349 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.
#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.
Simple 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.