fix name, add test for postfix increment
This commit is contained in:
parent
1a69026acb
commit
e2cd4aba8a
5 changed files with 23 additions and 16 deletions
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
*/
|
||||
|
||||
/** @file iter-adaptor.hpp
|
||||
/** @file iter-adapter.hpp
|
||||
** Helper template(s) for creating <b>lumiera forward iterators</b>.
|
||||
** This denotes a concept similar to STL's "forward iterator", with
|
||||
** the addition of an bool check to detect iteration end. The latter
|
||||
|
|
@ -61,13 +61,15 @@ namespace lib {
|
|||
|
||||
|
||||
/**
|
||||
* simple ptr-to-object based implementation of the lumiera forward iterator concept.
|
||||
* Basically such an PtrIter behaves like the similar concept from STL, but
|
||||
* - it is not just a disguised pointer (meaning, its more expensive)
|
||||
* Adapter for building an implementation of the lumiera forward iterator concept.
|
||||
* The "current position" is represented as an opaque element (usually an nested iterator),
|
||||
* with callbacks to the controlling container instance for managing this position.
|
||||
* Basically such an IterAdapter behaves like the similar concept from STL, but
|
||||
* - it is not just a disguised pointer (meaning, it's more expensive)
|
||||
* - it checks validity on every operation and may throw
|
||||
* - it has a distinct back-link to the source container
|
||||
* - the source container needs to implement iterStart() and iterInc()
|
||||
* - we need friendship to and from the container class
|
||||
* - we need friendship to access the callbacks on the container
|
||||
* - the end-of-iteration can be detected by bool check
|
||||
*
|
||||
* @see scoped-ptrvect.hpp usage example
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
|
||||
#include "include/logging.h"
|
||||
#include "lib/iter-adaptor.hpp"
|
||||
#include "lib/iter-adapter.hpp"
|
||||
#include "lib/error.hpp"
|
||||
#include "lib/util.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -281,7 +281,8 @@ return: 0
|
|||
END
|
||||
|
||||
|
||||
PLANNED "Lumiera Iterator Concept" IterAdaptor_test <<END
|
||||
TEST "Lumiera Iterator Concept" IterAdapter_test 20 <<END
|
||||
out: ::0::1::2::3::4::5::6::7::8::9::10::11::12::13::14::15::16::17::18::19
|
||||
END
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ test_lib_SOURCES = \
|
|||
$(testlib_srcdir)/hash-indexed-test.cpp \
|
||||
$(testlib_srcdir)/helloworldtest.cpp \
|
||||
$(testlib_srcdir)/lifecycletest.cpp \
|
||||
$(testlib_srcdir)/iter-adaptor-test.cpp \
|
||||
$(testlib_srcdir)/iter-adapter-test.cpp \
|
||||
$(testlib_srcdir)/mainsuite.cpp \
|
||||
$(testlib_srcdir)/meta/typelist-test.cpp \
|
||||
$(testlib_srcdir)/meta/typelist-manip-test.cpp \
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
IterAdaptor(Test) - building simple iterators for a given container
|
||||
IterAdapter(Test) - building various custom iterators for a given container
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2009, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
#include "lib/util.hpp"
|
||||
|
||||
//#include "lib/scoped-ptrvect.hpp"
|
||||
#include "lib/iter-adaptor.hpp"
|
||||
#include "lib/iter-adapter.hpp"
|
||||
//#include "testdummy.hpp"
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
|
@ -72,10 +72,7 @@ namespace test{
|
|||
for_each (numberz_, killIt);
|
||||
}
|
||||
|
||||
typedef int * value_type;
|
||||
typedef int ** pointer;
|
||||
typedef int *& reference;
|
||||
|
||||
|
||||
typedef IterAdapter<_Vec::iterator, TestContainer> iterator;
|
||||
typedef IterAdapter<_Vec::const_iterator, TestContainer> const_iterator;
|
||||
typedef PtrDerefIter<iterator > ref_iterator;
|
||||
|
|
@ -122,7 +119,7 @@ namespace test{
|
|||
* "lumiera forward iterator"
|
||||
* @todo see Ticket #182
|
||||
*/
|
||||
class IterAdaptor_test : public Test
|
||||
class IterAdapter_test : public Test
|
||||
{
|
||||
|
||||
virtual void
|
||||
|
|
@ -199,6 +196,13 @@ namespace test{
|
|||
ASSERT ((*iter) == i);
|
||||
}
|
||||
|
||||
TestContainer::ref_iterator rI (elms.begin_ref());
|
||||
|
||||
ASSERT (0 == *rI );
|
||||
ASSERT (0 == *rI++);
|
||||
ASSERT (1 == *rI );
|
||||
ASSERT (2 == *++rI);
|
||||
|
||||
ASSERT (TestContainer::iterator() == elms.end());
|
||||
ASSERT (!(TestContainer::iterator()));
|
||||
ASSERT (!(elms.end()));
|
||||
|
|
@ -211,7 +215,7 @@ namespace test{
|
|||
|
||||
};
|
||||
|
||||
LAUNCHER (IterAdaptor_test, "unit common");
|
||||
LAUNCHER (IterAdapter_test, "unit common");
|
||||
|
||||
|
||||
}} // namespace lib::test
|
||||
Loading…
Reference in a new issue