From 41b76f8f5c99237c53e5631e8a4d5154ebd169d7 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sun, 22 May 2011 22:15:14 +0000 Subject: [PATCH] [boost][range] - Ticket 5236 - Improved test coverage to ensure that the result for a random access strided range is consistent with that of a bidirectional strided range. [SVN r72108] --- test/adaptor_test/strided.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/adaptor_test/strided.cpp b/test/adaptor_test/strided.cpp index 6389a30..1198a10 100644 --- a/test/adaptor_test/strided.cpp +++ b/test/adaptor_test/strided.cpp @@ -252,14 +252,19 @@ namespace boost } template - void strided_test_ticket_5236_check(const Range& rng) + void strided_test_ticket_5236_check_bidirectional(const Range& rng) { BOOST_CHECK_EQUAL( boost::distance(rng), 1 ); BOOST_CHECK_EQUAL( std::distance(boost::begin(rng), boost::prior(boost::end(rng))), 0 ); - + } + + template + void strided_test_ticket_5236_check(const Range& rng) + { + strided_test_ticket_5236_check_bidirectional(rng); + typename boost::range_iterator::type it = boost::end(rng); it = it - 1; - BOOST_CHECK_EQUAL( std::distance(boost::begin(rng), it), 0 ); } @@ -268,7 +273,15 @@ namespace boost std::vector v; v.push_back(1); strided_test_ticket_5236_check( v | boost::adaptors::strided(2) ); + + // Ensure that there is consistency between the random-access implementation + // and the bidirectional. + + std::list l; + l.push_back(1); + strided_test_ticket_5236_check_bidirectional( l | boost::adaptors::strided(2) ); } + } }