bugfix and test coverage
This commit is contained in:
parent
2a5b080dd7
commit
2ad85dbb07
4 changed files with 54 additions and 7 deletions
|
|
@ -294,7 +294,7 @@ namespace lib {
|
|||
}
|
||||
|
||||
template<class IT>
|
||||
typename _PairIterT<IT>::KeyIter
|
||||
typename _PairIterT<IT>::ValIter
|
||||
takePairSecond (IT const& source)
|
||||
{
|
||||
return transformIterator(source, _PairIterT<IT>::takeSecond );
|
||||
|
|
@ -336,7 +336,7 @@ namespace lib {
|
|||
*/
|
||||
template<class MAP>
|
||||
typename _MapT<MAP>::ValIter
|
||||
eachMapValue (MAP& map)
|
||||
eachMapVal (MAP& map)
|
||||
{
|
||||
typedef RangeIter<typename MAP::iterator> Range;
|
||||
|
||||
|
|
@ -377,6 +377,7 @@ namespace lib {
|
|||
using iter_impl::wrapIter;
|
||||
using iter_impl::eachMapKey;
|
||||
using iter_impl::eachDistinctKey;
|
||||
using iter_impl::eachMapVal;
|
||||
using iter_impl::eachEntry;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -359,6 +359,10 @@ END
|
|||
TEST "Iterable data source" IterSource_test 13 <<END
|
||||
out: ::13::12::11::10::9::8::7::6::5::4::3::2::1
|
||||
out: ::.............::............::...........::..........::.........::........::.......::......::.....::....::...::..::.$
|
||||
out: (::X...........){13}$
|
||||
out: (::00:0.:....00){13}$
|
||||
out: (::X...........){13}$
|
||||
out: (::00:0.:....00){13}$
|
||||
END
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -168,11 +168,14 @@ namespace test{
|
|||
|
||||
|
||||
/*********************************************************************
|
||||
* @test set up example implementations based on the iterator-adapter
|
||||
* templates and verify the behaviour in accordance to the
|
||||
* concept "lumiera forward iterator"
|
||||
*
|
||||
* @todo see Ticket #182
|
||||
* @test set up example implementations based on the iterator-adapter
|
||||
* templates and verify the behaviour in accordance to the
|
||||
* concept "lumiera forward iterator"
|
||||
*
|
||||
* @note see Ticket #182
|
||||
* @see IterAdapter
|
||||
* @see itertools.hpp
|
||||
* @see IterSource
|
||||
*/
|
||||
class IterAdapter_test : public Test
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,15 +24,18 @@
|
|||
|
||||
#include "lib/test/run.hpp"
|
||||
#include "lib/test/test-helper.hpp"
|
||||
#include "lib/lumitime-fmt.hpp"
|
||||
#include "lib/util.hpp"
|
||||
|
||||
#include "lib/iter-source.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <tr1/unordered_map>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
|
||||
|
||||
|
|
@ -40,9 +43,11 @@ namespace lib {
|
|||
namespace test{
|
||||
|
||||
using ::Test;
|
||||
using lumiera::Time;
|
||||
using boost::lexical_cast;
|
||||
using boost::noncopyable;
|
||||
using lib::test::randStr;
|
||||
using lib::test::randTime;
|
||||
using util::isnil;
|
||||
using util::cStr;
|
||||
using std::string;
|
||||
|
|
@ -144,12 +149,27 @@ namespace test{
|
|||
|
||||
typedef IterSource<int>::iterator IntIter;
|
||||
typedef IterSource<CStr>::iterator StrIter;
|
||||
typedef IterSource<const string>::iterator StringIter;
|
||||
typedef IterSource<Time>::iterator TimeIter;
|
||||
|
||||
typedef std::map<string,Time> TreeMap;
|
||||
typedef std::tr1::unordered_map<string,Time> HashMap;
|
||||
|
||||
virtual void
|
||||
run (Arg arg)
|
||||
{
|
||||
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[0]);
|
||||
|
||||
verify_simpleIters();
|
||||
|
||||
verify_MapWrappers<TreeMap>();
|
||||
verify_MapWrappers<HashMap>();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
verify_simpleIters()
|
||||
{
|
||||
// build the test data sources
|
||||
WrappedList customList(NUM_ELMS);
|
||||
TestSource dedicatedSource(NUM_ELMS);
|
||||
|
|
@ -178,6 +198,25 @@ namespace test{
|
|||
cout << endl;
|
||||
}
|
||||
|
||||
|
||||
template<class MAP>
|
||||
void
|
||||
verify_MapWrappers()
|
||||
{
|
||||
MAP testMap;
|
||||
for (uint i=0; i<NUM_ELMS; ++i)
|
||||
testMap['X'+randStr(11)] = randTime();
|
||||
|
||||
StringIter sIter = eachMapKey (testMap);
|
||||
TimeIter tIter = eachMapVal (testMap);
|
||||
|
||||
ASSERT (sIter && tIter);
|
||||
pullOut (sIter);
|
||||
pullOut (tIter);
|
||||
|
||||
ASSERT (!sIter && !tIter);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
LAUNCHER (IterSource_test, "unit common");
|
||||
|
|
|
|||
Loading…
Reference in a new issue