Quickbook: Copy trunk libs into quickbook-dev branch.

[SVN r75213]
This commit is contained in:
Daniel James
2011-11-01 13:04:29 +00:00
17 changed files with 325 additions and 32 deletions

View File

@ -11,7 +11,7 @@
#include <boost/range/algorithm/copy.hpp>
#include <boost/assign.hpp>
#include <algorithm>
#include <functinoal>
#include <functional>
#include <iostream>
#include <vector>

View File

@ -41,5 +41,5 @@ int main(int argc, const char* argv[])
display_element_and_index( input | indexed(0) );
return 0;
]
}

View File

@ -9,7 +9,7 @@
//
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <boost/range/assign.hpp>
#include <boost/assign.hpp>
#include <algorithm>
#include <iostream>
#include <vector>

View File

@ -31,6 +31,22 @@ rule range-test ( name : includes * )
}
test-suite range :
[ compile ../doc/reference/adaptors/examples/adjacent_filtered.cpp : : example_adjacent_filtered ]
[ compile ../doc/reference/adaptors/examples/copied.cpp : : example_copied ]
[ compile ../doc/reference/adaptors/examples/filtered.cpp : : example_filtered ]
[ compile ../doc/reference/adaptors/examples/indexed.cpp : : example_indexed ]
[ compile ../doc/reference/adaptors/examples/indirected.cpp : : example_indirected ]
[ compile ../doc/reference/adaptors/examples/map_keys.cpp : : example_map_keys ]
[ compile ../doc/reference/adaptors/examples/map_values.cpp : : example_map_values ]
[ compile ../doc/reference/adaptors/examples/replaced.cpp : : example_replaced ]
[ compile ../doc/reference/adaptors/examples/replaced_if.cpp : : example_replaced_if ]
[ compile ../doc/reference/adaptors/examples/reversed.cpp : : example_reversed ]
[ compile ../doc/reference/adaptors/examples/sliced.cpp : : example_sliced ]
[ compile ../doc/reference/adaptors/examples/strided.cpp : : example_strided ]
[ compile ../doc/reference/adaptors/examples/tokenized.cpp : : example_tokenized ]
[ compile ../doc/reference/adaptors/examples/transformed.cpp : : example_transformed ]
[ compile ../doc/reference/adaptors/examples/uniqued.cpp : : example_uniqued ]
[ compile-fail compile_fail/iterator_range1.cpp ]
[ range-test adaptor_test/adjacent_filtered ]
[ range-test adaptor_test/copied ]
[ range-test adaptor_test/filtered ]
@ -155,5 +171,9 @@ test-suite range :
[ range-test std_container ]
[ range-test string ]
[ range-test sub_range ]
[ range-test ticket_5486 ]
[ range-test ticket_5544_terminate_irange ]
[ range-test ticket_5547 ]
[ range-test ticket_5556_is_sorted_namespace ]
;

View File

@ -250,6 +250,38 @@ namespace boost
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
output.begin(), output.end() );
}
template<typename Range>
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<typename Range>
void strided_test_ticket_5236_check(const Range& rng)
{
strided_test_ticket_5236_check_bidirectional(rng);
typename boost::range_iterator<const Range>::type it = boost::end(rng);
it = it - 1;
BOOST_CHECK_EQUAL( std::distance(boost::begin(rng), it), 0 );
}
void strided_test_ticket_5236()
{
std::vector<int> 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<int> l;
l.push_back(1);
strided_test_ticket_5236_check_bidirectional( l | boost::adaptors::strided(2) );
}
}
}
@ -262,6 +294,7 @@ init_unit_test_suite(int argc, char* argv[])
test->add( BOOST_TEST_CASE( &boost::strided_test ) );
test->add( BOOST_TEST_CASE( &boost::strided_defect_Trac5014 ) );
test->add( BOOST_TEST_CASE( &boost::strided_test_traversal ) );
test->add( BOOST_TEST_CASE( &boost::strided_test_ticket_5236 ) );
return test;
}

View File

@ -172,9 +172,9 @@ void check_adl_conformance()
BOOST_CHECK_EQUAL( boost_test::begin( r6 ), global_namespace );
}
#include <boost/test/included/unit_test_framework.hpp>
#include <boost/test/included/unit_test.hpp>
using boost::unit_test_framework::test_suite;
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{

View File

@ -18,7 +18,7 @@
#include <boost/range/begin.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/included/unit_test_framework.hpp>
#include <boost/test/included/unit_test.hpp>
namespace mock_std
{
@ -104,12 +104,12 @@ namespace
}
}
using boost::unit_test_framework::test_suite;
using boost::unit_test::test_suite;
boost::unit_test_framework::test_suite*
boost::unit_test::test_suite*
init_unit_test_suite( int argc, char* argv[] )
{
boost::unit_test_framework::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite - begin() ADL namespace barrier" );
boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite - begin() ADL namespace barrier" );
test->add( BOOST_TEST_CASE( &test_range_begin ) );

View File

@ -53,9 +53,9 @@ void compat1()
iterator_of< std::vector<int> >::type i = v.begin();
}
#include <boost/test/included/unit_test_framework.hpp>
#include <boost/test/included/unit_test.hpp>
using boost::unit_test_framework::test_suite;
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{

View File

@ -53,9 +53,9 @@ void compat1()
iterator_of< std::vector<int> >::type i = v.begin();
}
#include <boost/test/included/unit_test_framework.hpp>
#include <boost/test/included/unit_test.hpp>
using boost::unit_test_framework::test_suite;
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
{

View File

@ -0,0 +1,21 @@
// Boost.Range library
//
// Copyright Neil Groves 2011. Use, modification and distribution is subject
// to the Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range
//
#include <boost/range/iterator_range_core.hpp>
namespace iterator_range_test_detail
{
void check_iterator_range_doesnt_convert_pointers()
{
double source[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
boost::iterator_range<float*> rng = boost::make_iterator_range(source);
}
}

View File

@ -18,7 +18,7 @@
#include <boost/range/end.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/included/unit_test_framework.hpp>
#include <boost/test/included/unit_test.hpp>
namespace mock_std
{
@ -104,12 +104,12 @@ namespace
}
}
using boost::unit_test_framework::test_suite;
using boost::unit_test::test_suite;
boost::unit_test_framework::test_suite*
boost::unit_test::test_suite*
init_unit_test_suite( int argc, char* argv[] )
{
boost::unit_test_framework::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite - end() ADL namespace barrier" );
boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite - end() ADL namespace barrier" );
test->add( BOOST_TEST_CASE( &test_range_end_adl_avoidance ) );

View File

@ -14,7 +14,6 @@
#include <boost/range/end.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <vector>
namespace boost
@ -35,27 +34,38 @@ namespace boost
BOOST_CHECK_EQUAL_COLLECTIONS( test.begin(), test.end(),
reference.begin(), reference.end() );
}
template<typename Integer>
std::ptrdiff_t test_irange_calculate_num_steps(Integer first, Integer last, int step)
{
const std::ptrdiff_t sz = static_cast<std::ptrdiff_t>(step >= 0 ? step : -step);
const std::ptrdiff_t l = static_cast<std::ptrdiff_t>(step >= 0 ? last : first);
const std::ptrdiff_t f = static_cast<std::ptrdiff_t>(step >= 0 ? first : last);
return (l + ((l-f) % sz) - f) / sz;
}
// Test an integer range with a runtime specified step size.
template<typename Integer>
void test_irange_impl(Integer first, Integer last, int step)
template<typename Integer, typename IntegerInput>
void test_irange_impl(IntegerInput first, IntegerInput last, int step)
{
BOOST_ASSERT( step != 0 );
// Skip tests that have negative values if the type is
// unsigned
if ((static_cast<IntegerInput>(static_cast<Integer>(first)) != first)
|| (static_cast<IntegerInput>(static_cast<Integer>(last)) != last))
return;
std::vector<Integer> reference;
if (step > 0)
{
for (Integer i = first; i < last; i += step)
reference.push_back(i);
}
else
{
for (Integer i = first; i > last; i += step)
reference.push_back(i);
}
const std::ptrdiff_t num_steps = test_irange_calculate_num_steps(first, last, step);
Integer current_value = first;
for (std::ptrdiff_t i = 0; i < num_steps; ++i, current_value += step)
reference.push_back(current_value);
std::vector<Integer> test;
boost::push_back(test, boost::irange(first, last, step));
BOOST_CHECK_EQUAL_COLLECTIONS( test.begin(), test.end(),
reference.begin(), reference.end() );
}
@ -81,7 +91,6 @@ namespace boost
void test_irange(int first, int last, int step_size)
{
BOOST_ASSERT( step_size != 0 );
BOOST_ASSERT( (last - first) % step_size == 0 );
test_irange_impl<signed char>(first, last, step_size);
test_irange_impl<unsigned char>(first, last, step_size);
test_irange_impl<signed short>(first, last, step_size);
@ -114,8 +123,27 @@ namespace boost
test_irange(10, 0, -1);
test_irange(0, 2, 2);
test_irange(2, 0, -2);
test_irange(0, 9, 2);
test_irange(9, 0, -2);
test_irange(-9, 0, 2);
test_irange(-9, 9, 2);
test_irange(9, -9, -2);
test_irange(10, 20, 5);
test_irange(20, 10, -5);
test_irange(0, 0, 3);
test_irange(0, 1, 3);
test_irange(0, 2, 3);
test_irange(0, 3, 3);
test_irange(0, 4, 3);
test_irange(0, 10, 3);
test_irange(0, 0, -3);
test_irange(0, -1, -3);
test_irange(0, -2, -3);
test_irange(0, -3, -3);
test_irange(0, -4, -3);
test_irange(0, -10, -3);
}
} // namespace boost

View File

@ -200,6 +200,15 @@ namespace iterator_range_test_detail
}
}
}
void check_iterator_range_from_array()
{
double source[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
boost::iterator_range<double*> rng = boost::make_iterator_range(source);
BOOST_CHECK_EQUAL_COLLECTIONS( rng.begin(), rng.end(),
source, source + 6 );
}
} // namespace iterator_range_test_detail
template<typename Pred>

56
test/ticket_5486.cpp Normal file
View File

@ -0,0 +1,56 @@
// Boost.Range library
//
// Copyright Neil Groves 2011. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/range/adaptor/adjacent_filtered.hpp>
#include <boost/range/algorithm_ext/push_back.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <functional>
#include <vector>
namespace boost
{
namespace
{
class TestTicket5486Pred
: public std::binary_function<int,int,bool>
{
public:
explicit TestTicket5486Pred(int x) {}
bool operator()(int,int) const { return true; }
private:
TestTicket5486Pred();
};
// Ticket 5486 - pertained to predicates erroneous
// requiring default construction
void test_ticket_5486()
{
std::vector<int> v;
boost::push_back(v, v | boost::adaptors::adjacent_filtered(TestTicket5486Pred(1)));
BOOST_CHECK_EQUAL_COLLECTIONS( v.begin(), v.end(),
v.begin(), v.end() );
}
}
}
boost::unit_test::test_suite*
init_unit_test_suite(int argc, char* argv[])
{
boost::unit_test::test_suite* test
= BOOST_TEST_SUITE( "RangeTestSuite.ticket_5486" );
test->add( BOOST_TEST_CASE( &boost::test_ticket_5486 ) );
return test;
}

View File

@ -0,0 +1,47 @@
// Boost.Range library
//
// Copyright Neil Groves 2011. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/range/irange.hpp>
#include <boost/range/algorithm_ext/push_back.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <vector>
namespace boost
{
namespace
{
void test_irange_termination()
{
std::vector<int> reference;
for (int i = 0; i < 9; i += 2)
reference.push_back(i);
std::vector<int> actual;
boost::push_back(actual, boost::irange(0,9,2));
BOOST_CHECK_EQUAL_COLLECTIONS(actual.begin(), actual.end(),
reference.begin(), reference.end());
}
}
}
boost::unit_test::test_suite*
init_unit_test_suite(int argc, char* argv[])
{
boost::unit_test::test_suite* test
= BOOST_TEST_SUITE( "RangeTestSuite.ticket_5544" );
test->add( BOOST_TEST_CASE( &boost::test_irange_termination ) );
return test;
}

42
test/ticket_5547.cpp Normal file
View File

@ -0,0 +1,42 @@
// Boost.Range library
//
// Copyright Neil Groves 2011. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/algorithm/string/join.hpp>
#include <boost/range/join.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <vector>
namespace boost
{
namespace
{
// Ticket 5547 - boost::join ambiguous with algorithm::join
void test_ticket_5547()
{
std::vector<int> x;
boost::range::join(x,x);
}
}
}
boost::unit_test::test_suite*
init_unit_test_suite(int argc, char* argv[])
{
boost::unit_test::test_suite* test
= BOOST_TEST_SUITE( "RangeTestSuite.ticket_5547" );
test->add( BOOST_TEST_CASE( &boost::test_ticket_5547 ) );
return test;
}

View File

@ -0,0 +1,37 @@
// Boost.Range library
//
// Copyright Neil Groves 2011. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// For more information, see http://www.boost.org/libs/range/
//
// Embarrasingly, the mere inclusion of these headers in this order was
// enough to trigger the defect.
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
namespace boost
{
namespace
{
void test_ticket_5556() {}
}
}
boost::unit_test::test_suite*
init_unit_test_suite(int argc, char* argv[])
{
boost::unit_test::test_suite* test
= BOOST_TEST_SUITE( "RangeTestSuite.ticket_5556" );
test->add( BOOST_TEST_CASE( &boost::test_ticket_5556 ) );
return test;
}