From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/range/test/iterator_pair.cpp | 104 ++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/boost/libs/range/test/iterator_pair.cpp (limited to 'src/boost/libs/range/test/iterator_pair.cpp') diff --git a/src/boost/libs/range/test/iterator_pair.cpp b/src/boost/libs/range/test/iterator_pair.cpp new file mode 100644 index 00000000..7b615a9f --- /dev/null +++ b/src/boost/libs/range/test/iterator_pair.cpp @@ -0,0 +1,104 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2004. 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 + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +# pragma warn -8091 // suppress warning in Boost.Test +# pragma warn -8057 // unused argument argc/argv in Boost.Test +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void check_iterator_pair() +{ + typedef std::vector vec_t; + vec_t vec; + vec.push_back( 4 ); + typedef std::pair + pair_t; + typedef std::pair + const_pair_t; + typedef const pair_t const_pair_tt; + pair_t pair = std::make_pair( boost::begin( vec ), boost::end( vec ) ); + const_pair_t const_pair = std::make_pair( boost::begin( vec ), boost::end( vec ) ); + const_pair_tt constness_pair( pair ); + + + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value::type, + std::iterator_traits::value_type>::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, pair_t::first_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_const_iterator::type, pair_t::first_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference::type, + std::iterator_traits::difference_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size::type, std::size_t >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, pair_t::first_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_t::first_type >::value )); + + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value::type, + std::iterator_traits::value_type>::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_tt::first_type >::value )); + // + // This behavior is not supported with v2. + //BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, const_pair_tt::first_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference::type, + std::iterator_traits::difference_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size::type, std::size_t >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_tt::first_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_tt::first_type >::value )); + + BOOST_CHECK( boost::begin( pair ) == pair.first ); + BOOST_CHECK( boost::end( pair ) == pair.second ); + BOOST_CHECK( boost::empty( pair ) == (pair.first == pair.second) ); + BOOST_CHECK( boost::size( pair ) == + static_cast( + std::distance(pair.first, pair.second)) ); + + BOOST_CHECK( boost::begin( const_pair ) == const_pair.first ); + BOOST_CHECK( boost::end( const_pair ) == const_pair.second ); + BOOST_CHECK( boost::empty( const_pair ) == (const_pair.first == const_pair.second) ); + BOOST_CHECK( boost::size( const_pair ) == + static_cast( + std::distance(const_pair.first, const_pair.second)) ); + + BOOST_CHECK( boost::begin( constness_pair ) == constness_pair.first ); + BOOST_CHECK( boost::end( constness_pair ) == constness_pair.second ); + BOOST_CHECK( boost::empty( constness_pair ) == (constness_pair.first == const_pair.second) ); + BOOST_CHECK( boost::size( constness_pair ) == + static_cast( + std::distance(constness_pair.first, + constness_pair.second)) ); +} + + +#include + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); + + test->add( BOOST_TEST_CASE( &check_iterator_pair ) ); + + return test; +} + + + + + + -- cgit v1.2.3