[range] - corrected defected test for the partition algorithm.

[SVN r64001]
This commit is contained in:
Neil Groves
2010-07-13 22:28:37 +00:00
parent 183e449a31
commit 109bf20484

View File

@ -42,19 +42,19 @@ namespace boost
test_iter(Container& cont) test_iter(Container& cont)
{ {
typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t; typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
const Container old_cont(cont); const Container old_cont(cont);
Container cont2(old_cont); Container cont2(old_cont);
iter_t result = boost::partition(cont, UnaryPredicate()); iter_t result = boost::partition(cont, UnaryPredicate());
iter_t temp_result = boost::partition(cont2, UnaryPredicate()); iter_t temp_result = boost::partition(cont2, UnaryPredicate());
cont2 = old_cont; cont2 = old_cont;
BOOST_CHECK( temp_result == boost::partition( BOOST_CHECK( temp_result == boost::partition(
boost::make_iterator_range(cont2), UnaryPredicate()) ); boost::make_iterator_range(cont2), UnaryPredicate()) );
BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(), BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
cont2.begin(), cont2.end() ); cont2.begin(), cont2.end() );
return result; return result;
} }
@ -68,20 +68,19 @@ namespace boost
operator()(Policy& policy, Container& cont) operator()(Policy& policy, Container& cont)
{ {
typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t; typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
const Container old_cont(cont); const Container old_cont(cont);
Container cont2(old_cont); Container cont2(old_cont);
result_t result = boost::partition<return_type>(cont, policy.pred()); result_t result = boost::partition<return_type>(cont, policy.pred());
result_t temp_result = boost::partition<return_type>( // Test that operation a temporary created by using
cont2, policy.pred()); // make_iterator_range.
cont2 = old_cont; boost::partition<return_type>(
BOOST_CHECK( temp_result == boost::partition<return_type>( boost::make_iterator_range(cont2), policy.pred());
boost::make_iterator_range(cont2), policy.pred()) );
BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(), BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
cont2.begin(), cont2.end() ); cont2.begin(), cont2.end() );
return result; return result;
} }
}; };