Пример #1
0
bool rangeTest(const DSL& dsl)
{
  ASSERT( dsl.mu() == 0 ); 
  typedef typename DSL::Point Point; 

  unsigned int nbok = 0;
  unsigned int nb = 0;
  
  trace.beginBlock ( "Range/Iterator services..." );
  trace.info() << dsl << std::endl; 

  Point first(0,0); 
  Point last(dsl.b(), dsl.a()); 
  trace.info() << "from " << first << " to " << last << std::endl; 

  if (dsl.isValid())
    nbok++; 
  nb++; 

  trace.info() << "(" << nbok << "/" << nb << ") "
  	       << std::endl;

  {//forward pass  
    typedef typename DSL::ConstIterator I; 
    BOOST_CONCEPT_ASSERT(( boost_concepts::ReadableIteratorConcept<I> )); 
    BOOST_CONCEPT_ASSERT(( boost_concepts::BidirectionalTraversalConcept<I> ));
    bool res = true; 
    int c = 0; 
    for (I it = dsl.begin(first), itEnd = dsl.end(last); 
	 ( (it != itEnd)&&(res)&&(c<100) ); 
	 ++it, ++c)
      {
	trace.info() << "(" << it->operator[](0) << "," << it->operator[](1) << ") ";  
	if ( !dsl(*it) )
	  res = false; 
      }
    trace.info() << " : " << c << " points " << std::endl; 
    trace.info() << std::endl; 

    if ( (res)&&(c == (dsl.omega()+1)) ) 
      nbok++; 
    nb++;

    trace.info() << "(" << nbok << "/" << nb << ") "
		 << std::endl;
  }

  {//backward pass
    typedef typename DSL::ConstReverseIterator I; 
    BOOST_CONCEPT_ASSERT(( boost_concepts::ReadableIteratorConcept<I> )); 
    BOOST_CONCEPT_ASSERT(( boost_concepts::BidirectionalTraversalConcept<I> ));
    bool res = true; 
    int c = 0; 
    for (I it = dsl.rbegin(last), itEnd = dsl.rend(first); 
	 ( (it != itEnd)&&(res)&&(c<100) ); 
	 ++it, ++c)
      {
	trace.info() << "(" << it->operator[](0) << "," << it->operator[](1) << ") ";  
	if ( !dsl(*it) )
	  res = false; 
      }
    trace.info() << " : " << c << " points " << std::endl; 
    trace.info() << std::endl; 

    if ( (res)&&(c == (dsl.omega()+1)) ) 
      nbok++; 
    nb++;

    trace.info() << "(" << nbok << "/" << nb << ") "
		 << std::endl;
  }

  trace.endBlock();
  
  return nbok == nb;
}
Пример #2
0
bool rangeTest(const DSL& dsl)
{
  typedef typename DSL::Point Point; 

  unsigned int nbok = 0;
  unsigned int nb = 0;
  
  trace.beginBlock ( "Range/Iterator services..." );
  trace.info() << dsl << std::endl; 

  Point origin = dsl.getPoint();
  Point first = Point(origin[0]-dsl.b(), origin[1]-dsl.a());
  Point last = Point(first[0]+dsl.b(), first[1]+dsl.a()); 
  trace.info() << "from " << first << " to " << last << std::endl; 

  if (dsl.isValid())
    nbok++; 
  nb++; 

  trace.info() << "(" << nbok << "/" << nb << ") "
  	       << std::endl;

  {//forward pass  
    typedef typename DSL::ConstIterator I; 
    BOOST_CONCEPT_ASSERT(( boost_concepts::ReadableIteratorConcept<I> )); 
    BOOST_CONCEPT_ASSERT(( boost_concepts::RandomAccessTraversalConcept<I> ));
    bool res = true; 
    int c = 0; 
    for (I it = dsl.begin(first), itEnd = dsl.end(last); 
	 ( (it != itEnd)&&(res)&&(c<100) ); 
	 ++it, ++c)
      {
	trace.info() << "(" << it->operator[](0) << "," << it->operator[](1) << ") ";  
	if ( !dsl(*it) )
	  res = false; 
      }
    trace.info() << " : " << c << " points " << std::endl; 
    trace.info() << std::endl; 

    if ( (res)&&(c == (dsl.omega()+1)) ) 
      nbok++; 
    nb++;

    trace.info() << "(" << nbok << "/" << nb << ") "
		 << std::endl;
  }

  {//backward pass
    typedef typename DSL::ConstReverseIterator I; 
    BOOST_CONCEPT_ASSERT(( boost_concepts::ReadableIteratorConcept<I> )); 
    BOOST_CONCEPT_ASSERT(( boost_concepts::RandomAccessTraversalConcept<I> ));
    bool res = true; 
    int c = 0; 
    for (I it = dsl.rbegin(last), itEnd = dsl.rend(first); 
	 ( (it != itEnd)&&(res)&&(c<100) ); 
	 ++it, ++c)
      {
	trace.info() << "(" << it->operator[](0) << "," << it->operator[](1) << ") ";  
	if ( !dsl(*it) )
	  res = false; 
      }
    trace.info() << " : " << c << " points " << std::endl; 
    trace.info() << std::endl; 

    if ( (res)&&(c == (dsl.omega()+1)) ) 
      nbok++; 
    nb++;

    trace.info() << "(" << nbok << "/" << nb << ") "
		 << std::endl;
  }

  {//random access services  
    typedef typename DSL::ConstIterator I; 
    BOOST_CONCEPT_ASSERT(( boost_concepts::ReadableIteratorConcept<I> )); 
    BOOST_CONCEPT_ASSERT(( boost_concepts::RandomAccessTraversalConcept<I> ));
    bool res = true; 
    int c = 0; 
    I itBegin = dsl.begin(first); 
    for (I it = itBegin, itEnd = dsl.end(last); 
	 ( (it != itEnd)&&(res)&&(c<100) ); 
	 ++it, ++c)
      {
	trace.info() << "(" << it->operator[](0) << "," << it->operator[](1) << ") " << it.remainder() << ", ";  
	I it2 = ( itBegin + c ); 
	if ( (it != it2) || ((it2 - itBegin) != c) )
	  res = false; 
      }
    int n = c; 
    trace.info() << " : " << c << " points " << std::endl; 
    trace.info() << std::endl; 

    if (res) 
      nbok++; 
    nb++;

    trace.info() << "(" << nbok << "/" << nb << ") "
		 << std::endl;

    --n; 
    c = 0; 
    for (I it = (itBegin+n), itEnd = itBegin; 
	 ( (it!=itEnd)&&(res)&&(c < 100) );
	 --it, ++c )
      {
	trace.info() << "(" << it->operator[](0) << "," << it->operator[](1) << ") " << it.remainder() << ", ";  
	I it2 = ( (itBegin+n) - c ); 
	if ( (it != it2) || (((itBegin+n) - it2) != c) )
	  res = false; 
      }

    if (res) 
      nbok++; 
    nb++;

    trace.info() << "(" << nbok << "/" << nb << ") "
		 << std::endl;
  }


  trace.endBlock();
  
  return nbok == nb;
}