os/ossrv/stdcpp/tsrc/Boost_test/multi_array/src/idxgen1.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright 2002 The Trustees of Indiana University.
     2 
     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)
     6 
     7 //  Boost.MultiArray Library
     8 //  Authors: Ronald Garcia
     9 //           Jeremy Siek
    10 //           Andrew Lumsdaine
    11 //  See http://www.boost.org/libs/multi_array for documentation.
    12 
    13 //
    14 // idxset1.cpp - testing the code for index_gen
    15 //
    16 /*
    17  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
    18 */
    19 
    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"
    24 
    25 #include "boost/array.hpp"
    26 
    27 #ifdef __SYMBIAN32__
    28 #include "std_log_result.h"
    29 #define LOG_FILENAME_LINE __FILE__, __LINE__
    30 #endif
    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;
    34 
    35 template <int NumRanges, int NumDims>
    36 void check(const boost::detail::multi_array::
    37            index_gen<NumRanges,NumDims>&) { }
    38 
    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_;
    44 }
    45 
    46 int
    47 test_main(int,char*[])
    48 {
    49 
    50   boost::detail::multi_array::index_gen<0,0> indices;
    51 
    52 
    53   check<1,1>(indices[range()]);
    54   check<2,2>(indices[range()][range()]);
    55   check<3,3>(indices[range()][range()][range()]);
    56 
    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()]);
    68 
    69   {
    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));
    75   }
    76 
    77   {
    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));
    84   }
    85 #ifdef __SYMBIAN32__
    86 if(boost::minimal_test::errors_counter() != 0)
    87    assert_failed = true;
    88    	testResultXml("idxgen1");
    89 	close_log_file();
    90 #endif
    91   return boost::exit_success;
    92 }
    93