Update contrib.
1 // Copyright 2002 The Trustees of Indiana University.
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // Boost.MultiArray Library
8 // Authors: Ronald Garcia
11 // See http://www.boost.org/libs/multi_array for documentation.
14 // idxset1.cpp - testing the code for index_gen
17 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
20 #include "boost/multi_array/index_gen.hpp"
21 #include "boost/multi_array/index_range.hpp"
22 #include "boost/multi_array/types.hpp"
23 #include "boost/test/minimal.hpp"
25 #include "boost/array.hpp"
28 #include "std_log_result.h"
29 #define LOG_FILENAME_LINE __FILE__, __LINE__
31 typedef boost::detail::multi_array::index index_type;
32 typedef boost::detail::multi_array::size_type size_type;
33 typedef boost::detail::multi_array::index_range<index_type,size_type> range;
35 template <int NumRanges, int NumDims>
36 void check(const boost::detail::multi_array::
37 index_gen<NumRanges,NumDims>&) { }
39 bool operator==(const range& lhs,const range& rhs) {
40 return lhs.start_ == rhs.start_ &&
41 lhs.finish_ == rhs.finish_ &&
42 lhs.stride_ == rhs.stride_ &&
43 lhs.degenerate_ == rhs.degenerate_;
47 test_main(int,char*[])
50 boost::detail::multi_array::index_gen<0,0> indices;
53 check<1,1>(indices[range()]);
54 check<2,2>(indices[range()][range()]);
55 check<3,3>(indices[range()][range()][range()]);
57 check<1,0>(indices[0]);
58 check<2,0>(indices[0][0]);
59 check<2,1>(indices[range()][0]);
60 check<2,1>(indices[0][range()]);
61 check<3,0>(indices[0][0][0]);
62 check<3,1>(indices[range()][0][0]);
63 check<3,1>(indices[0][range()][0]);
64 check<3,1>(indices[0][0][range()]);
65 check<3,2>(indices[range()][range()][0]);
66 check<3,2>(indices[range()][0][range()]);
67 check<3,2>(indices[0][range()][range()]);
70 boost::detail::multi_array::index_gen<3,3> is1 =
71 indices[range(0,1,2)][range(1,2,3)][range(2,3,4)];
72 BOOST_CHECK(is1.ranges_[0] == range(0,1,2));
73 BOOST_CHECK(is1.ranges_[1] == range(1,2,3));
74 BOOST_CHECK(is1.ranges_[2] == range(2,3,4));
78 boost::detail::multi_array::index_gen<3,2> is2 =
79 indices[range(0,1,2)][2][range(2,3,4)];
80 BOOST_CHECK(is2.ranges_[0] == range(0,1,2));
81 BOOST_CHECK(is2.ranges_[1] == range(2));
82 BOOST_CHECK(is2.ranges_[1].is_degenerate());
83 BOOST_CHECK(is2.ranges_[2] == range(2,3,4));
86 if(boost::minimal_test::errors_counter() != 0)
88 testResultXml("idxgen1");
91 return boost::exit_success;