sl@0: // Copyright 2002 The Trustees of Indiana University. sl@0: sl@0: // Use, modification and distribution is subject to the Boost Software sl@0: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: // Boost.MultiArray Library sl@0: // Authors: Ronald Garcia sl@0: // Jeremy Siek sl@0: // Andrew Lumsdaine sl@0: // See http://www.boost.org/libs/multi_array for documentation. sl@0: sl@0: // sl@0: // idxset1.cpp - testing the code for index_gen sl@0: // sl@0: /* sl@0: * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved. sl@0: */ sl@0: sl@0: #include "boost/multi_array/index_gen.hpp" sl@0: #include "boost/multi_array/index_range.hpp" sl@0: #include "boost/multi_array/types.hpp" sl@0: #include "boost/test/minimal.hpp" sl@0: sl@0: #include "boost/array.hpp" sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: #include "std_log_result.h" sl@0: #define LOG_FILENAME_LINE __FILE__, __LINE__ sl@0: #endif sl@0: typedef boost::detail::multi_array::index index_type; sl@0: typedef boost::detail::multi_array::size_type size_type; sl@0: typedef boost::detail::multi_array::index_range range; sl@0: sl@0: template sl@0: void check(const boost::detail::multi_array:: sl@0: index_gen&) { } sl@0: sl@0: bool operator==(const range& lhs,const range& rhs) { sl@0: return lhs.start_ == rhs.start_ && sl@0: lhs.finish_ == rhs.finish_ && sl@0: lhs.stride_ == rhs.stride_ && sl@0: lhs.degenerate_ == rhs.degenerate_; sl@0: } sl@0: sl@0: int sl@0: test_main(int,char*[]) sl@0: { sl@0: sl@0: boost::detail::multi_array::index_gen<0,0> indices; sl@0: sl@0: sl@0: check<1,1>(indices[range()]); sl@0: check<2,2>(indices[range()][range()]); sl@0: check<3,3>(indices[range()][range()][range()]); sl@0: sl@0: check<1,0>(indices[0]); sl@0: check<2,0>(indices[0][0]); sl@0: check<2,1>(indices[range()][0]); sl@0: check<2,1>(indices[0][range()]); sl@0: check<3,0>(indices[0][0][0]); sl@0: check<3,1>(indices[range()][0][0]); sl@0: check<3,1>(indices[0][range()][0]); sl@0: check<3,1>(indices[0][0][range()]); sl@0: check<3,2>(indices[range()][range()][0]); sl@0: check<3,2>(indices[range()][0][range()]); sl@0: check<3,2>(indices[0][range()][range()]); sl@0: sl@0: { sl@0: boost::detail::multi_array::index_gen<3,3> is1 = sl@0: indices[range(0,1,2)][range(1,2,3)][range(2,3,4)]; sl@0: BOOST_CHECK(is1.ranges_[0] == range(0,1,2)); sl@0: BOOST_CHECK(is1.ranges_[1] == range(1,2,3)); sl@0: BOOST_CHECK(is1.ranges_[2] == range(2,3,4)); sl@0: } sl@0: sl@0: { sl@0: boost::detail::multi_array::index_gen<3,2> is2 = sl@0: indices[range(0,1,2)][2][range(2,3,4)]; sl@0: BOOST_CHECK(is2.ranges_[0] == range(0,1,2)); sl@0: BOOST_CHECK(is2.ranges_[1] == range(2)); sl@0: BOOST_CHECK(is2.ranges_[1].is_degenerate()); sl@0: BOOST_CHECK(is2.ranges_[2] == range(2,3,4)); sl@0: } sl@0: #ifdef __SYMBIAN32__ sl@0: if(boost::minimal_test::errors_counter() != 0) sl@0: assert_failed = true; sl@0: testResultXml("idxgen1"); sl@0: close_log_file(); sl@0: #endif sl@0: return boost::exit_success; sl@0: } sl@0: