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/multi_array/test/idxgen1.cpp | 81 +++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/boost/libs/multi_array/test/idxgen1.cpp (limited to 'src/boost/libs/multi_array/test/idxgen1.cpp') diff --git a/src/boost/libs/multi_array/test/idxgen1.cpp b/src/boost/libs/multi_array/test/idxgen1.cpp new file mode 100644 index 00000000..ca9dcc72 --- /dev/null +++ b/src/boost/libs/multi_array/test/idxgen1.cpp @@ -0,0 +1,81 @@ +// Copyright 2002 The Trustees of Indiana University. + +// 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) + +// Boost.MultiArray Library +// Authors: Ronald Garcia +// Jeremy Siek +// Andrew Lumsdaine +// See http://www.boost.org/libs/multi_array for documentation. + +// +// idxset1.cpp - testing the code for index_gen +// + +#include +#include +#include +#include + +#include + +typedef boost::detail::multi_array::index index_type; +typedef boost::detail::multi_array::size_type size_type; +typedef boost::detail::multi_array::index_range range; + +template +void check(const boost::detail::multi_array:: + index_gen&) { } + +bool operator==(const range& lhs,const range& rhs) { + return lhs.start_ == rhs.start_ && + lhs.finish_ == rhs.finish_ && + lhs.stride_ == rhs.stride_ && + lhs.degenerate_ == rhs.degenerate_; +} + +int +main() +{ + + boost::detail::multi_array::index_gen<0,0> indices; + + + check<1,1>(indices[range()]); + check<2,2>(indices[range()][range()]); + check<3,3>(indices[range()][range()][range()]); + + check<1,0>(indices[0]); + check<2,0>(indices[0][0]); + check<2,1>(indices[range()][0]); + check<2,1>(indices[0][range()]); + check<3,0>(indices[0][0][0]); + check<3,1>(indices[range()][0][0]); + check<3,1>(indices[0][range()][0]); + check<3,1>(indices[0][0][range()]); + check<3,2>(indices[range()][range()][0]); + check<3,2>(indices[range()][0][range()]); + check<3,2>(indices[0][range()][range()]); + + { + boost::detail::multi_array::index_gen<3,3> is1 = + indices[range(0,1,2)][range(1,2,3)][range(2,3,4)]; + BOOST_TEST(is1.ranges_[0] == range(0,1,2)); + BOOST_TEST(is1.ranges_[1] == range(1,2,3)); + BOOST_TEST(is1.ranges_[2] == range(2,3,4)); + } + + { + boost::detail::multi_array::index_gen<3,2> is2 = + indices[range(0,1,2)][2][range(2,3,4)]; + BOOST_TEST(is2.ranges_[0] == range(0,1,2)); + BOOST_TEST(is2.ranges_[1] == range(2)); + BOOST_TEST(is2.ranges_[1].is_degenerate()); + BOOST_TEST(is2.ranges_[2] == range(2,3,4)); + } + + return boost::report_errors(); +} + -- cgit v1.2.3