34#include <forward_list>
36#include "DGtal/base/Common.h"
37#include "DGtal/base/Circulator.h"
52template<
typename Iterator>
53bool testOffset(
const Iterator& itb,
const Iterator& ite,
const vector<int>& groundTruth)
60 copy(itb,ite,ostream_iterator<int>(
trace.
info(),
" "));
73 copy(v.begin(),v.end(),ostream_iterator<int>(
trace.
info(),
" "));
77 copy(groundTruth.begin(),groundTruth.end(),ostream_iterator<int>(
trace.
info(),
" "));
80 return equal( v.begin(),v.end(),groundTruth.begin() );
88template<
typename Container>
91 unsigned int nbok = 0;
95 typedef typename Container::const_iterator I;
102 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
108 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
117 if ( (circ0 != circ1) && (circ0 != circ2) && (circ1 == circ2) )
120 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
127 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
129 && (circ0.
end() == circ1.
end())
133 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
135 if ( (*circ1 == *circ2) && (circ1.operator->() == &(*circ1)) )
138 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
150template<
typename Container>
153 ASSERT( cont.size() >= 1 );
154 unsigned int nbok = 0;
158 typedef typename Container::const_iterator I;
170 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
174 if ( (circ1 == circ2) && (circ1 == res) && (circ2 == res) )
177 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
189template<
typename Container>
192 ASSERT( cont.size() == 5 );
194 unsigned int nbok = 0;
198 typedef typename Container::const_iterator I;
204 trace.
info() <<
"arithmetic operators" << std::endl;
206 if ( (circ2) == (circ1+4) )
209 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
213 if ( circ1 == circ2 )
216 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
218 if ( (circ1+3) == (3+circ1) )
221 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
224 if ( (circ1+2) == circ2 )
227 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
229 if ( ((circ1-circ2) + (circ2-circ1)) == (cont.end()-cont.begin()) )
232 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
234 trace.
info() <<
"comparison operators" << std::endl;
235 if ( (circ1 < circ2) && (circ1 <= circ2)
236 && (circ2 < circ1) && (circ2 <= circ1) )
239 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
241 if ( !( (circ1 > circ2) && (circ1 >= circ2)
242 && (circ2 > circ1) && (circ2 >= circ1) ) )
245 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
255int main(
int argc,
char** argv )
259 for (
int i = 0; i < argc; ++i )
294 trace.
info() <<
"(const / not const)" << endl;
298 res = res && (c1 == c2) && (c1 == c3);
300 trace.
info() <<
"(reverse_iterator<Circulator> / Circulator<reverse_iterator>)" << endl;
301 std::reverse_iterator<Circulator<vector<int>::iterator> > rc1( c1 );
302 Circulator <vector<int>::reverse_iterator> c4( v.rend(), v.rbegin(), v.rend() );
303 res = res && (rc1.base().base() == c4.
base().base());
304 trace.
info() <<
"first element: (" << *--rc1 <<
" == " << *--c4 <<
")" << endl;
305 res = res && ((*rc1) == (*c4));
308 std::forward_list<int> fl;
330 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
Go to http://www.sgi.com/tech/stl/BidirectionalIterator.html.
bool testOffset(const Iterator &itb, const Iterator &ite, const vector< int > &groundTruth)
bool basicBidirectionalTest(const Container &cont)
bool basicRandomAccessTest(const Container &cont)
bool basicForwardTest(const Container &cont)