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/combine.cpp | 160 ++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 src/boost/libs/range/test/combine.cpp (limited to 'src/boost/libs/range/test/combine.cpp') diff --git a/src/boost/libs/range/test/combine.cpp b/src/boost/libs/range/test/combine.cpp new file mode 100644 index 00000000..11f674b5 --- /dev/null +++ b/src/boost/libs/range/test/combine.cpp @@ -0,0 +1,160 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014 +// +// Copyright Thorsten Ottosen 2006. 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 + +#include + +#include +#include +#include +#include + +namespace boost_range_test +{ + namespace + { + +template +void test_combine2() +{ + std::vector v; + std::list l; + + for (int i = 0; i < 10; ++i) + { + v.push_back(i); + l.push_back(i * 2); + } + + ContRef1& in1 = v; + ContRef2& in2 = l; + + std::vector > output; + boost::push_back(output, boost::combine(in1, in2)); + + int index = 0; + int i1, i2; + BOOST_FOREACH(boost::tie(i1,i2), output) + { + BOOST_CHECK_EQUAL(i1, index); + BOOST_CHECK_EQUAL(i2, index * 2); + ++index; + } +} + +template +void test_combine3() +{ + std::vector v1; + std::vector v2; + std::vector v3; + + for (int i = 0; i < 10; ++i) + { + v1.push_back(i); + v2.push_back(i * 2); + v3.push_back(i * 3); + } + + ContRef1& in1 = v1; + ContRef2& in2 = v2; + ContRef3& in3 = v3; + + std::vector > output; + boost::push_back(output, boost::combine(in1, in2, in3)); + + int index = 0; + int i1, i2, i3; + + BOOST_FOREACH(boost::tie(i1,i2,i3), output) + { + BOOST_CHECK_EQUAL(i1, index); + BOOST_CHECK_EQUAL(i2, index * 2); + BOOST_CHECK_EQUAL(i3, index * 3); + ++index; + } +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite(int, char*[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE( "Boost.Range combine() test suite" ); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine2< + const std::vector, const std::list >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine2< + const std::vector, std::list >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine2< + std::vector, const std::list >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine2< + std::vector, std::list >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine3< + std::vector, + std::vector, + std::vector >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine3< + std::vector, + std::vector, + const std::vector >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine3< + std::vector, + const std::vector, + std::vector >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine3< + std::vector, + const std::vector, + const std::vector >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine3< + const std::vector, + std::vector, + std::vector >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine3< + const std::vector, + std::vector, + const std::vector >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine3< + const std::vector, + const std::vector, + std::vector >))); + + test->add(BOOST_TEST_CASE(( + &boost_range_test::test_combine3< + const std::vector, + const std::vector, + const std::vector >))); + + return test; +} -- cgit v1.2.3