os/ossrv/stdcpp/tsrc/Boost_test/multi_array/src/idxgen1.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/stdcpp/tsrc/Boost_test/multi_array/src/idxgen1.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,93 @@
     1.4 +// Copyright 2002 The Trustees of Indiana University.
     1.5 +
     1.6 +// Use, modification and distribution is subject to the Boost Software 
     1.7 +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
     1.8 +// http://www.boost.org/LICENSE_1_0.txt)
     1.9 +
    1.10 +//  Boost.MultiArray Library
    1.11 +//  Authors: Ronald Garcia
    1.12 +//           Jeremy Siek
    1.13 +//           Andrew Lumsdaine
    1.14 +//  See http://www.boost.org/libs/multi_array for documentation.
    1.15 +
    1.16 +//
    1.17 +// idxset1.cpp - testing the code for index_gen
    1.18 +//
    1.19 +/*
    1.20 + * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
    1.21 +*/
    1.22 +
    1.23 +#include "boost/multi_array/index_gen.hpp"
    1.24 +#include "boost/multi_array/index_range.hpp"
    1.25 +#include "boost/multi_array/types.hpp"
    1.26 +#include "boost/test/minimal.hpp"
    1.27 +
    1.28 +#include "boost/array.hpp"
    1.29 +
    1.30 +#ifdef __SYMBIAN32__
    1.31 +#include "std_log_result.h"
    1.32 +#define LOG_FILENAME_LINE __FILE__, __LINE__
    1.33 +#endif
    1.34 +typedef boost::detail::multi_array::index index_type;
    1.35 +typedef boost::detail::multi_array::size_type size_type;
    1.36 +typedef boost::detail::multi_array::index_range<index_type,size_type> range;
    1.37 +
    1.38 +template <int NumRanges, int NumDims>
    1.39 +void check(const boost::detail::multi_array::
    1.40 +           index_gen<NumRanges,NumDims>&) { }
    1.41 +
    1.42 +bool operator==(const range& lhs,const range& rhs) {  
    1.43 +  return lhs.start_ == rhs.start_ &&
    1.44 +    lhs.finish_ == rhs.finish_ &&
    1.45 +    lhs.stride_ == rhs.stride_ &&
    1.46 +    lhs.degenerate_ == rhs.degenerate_;
    1.47 +}
    1.48 +
    1.49 +int
    1.50 +test_main(int,char*[])
    1.51 +{
    1.52 +
    1.53 +  boost::detail::multi_array::index_gen<0,0> indices;
    1.54 +
    1.55 +
    1.56 +  check<1,1>(indices[range()]);
    1.57 +  check<2,2>(indices[range()][range()]);
    1.58 +  check<3,3>(indices[range()][range()][range()]);
    1.59 +
    1.60 +  check<1,0>(indices[0]);
    1.61 +  check<2,0>(indices[0][0]);
    1.62 +  check<2,1>(indices[range()][0]);
    1.63 +  check<2,1>(indices[0][range()]);
    1.64 +  check<3,0>(indices[0][0][0]);
    1.65 +  check<3,1>(indices[range()][0][0]);
    1.66 +  check<3,1>(indices[0][range()][0]);
    1.67 +  check<3,1>(indices[0][0][range()]);
    1.68 +  check<3,2>(indices[range()][range()][0]);
    1.69 +  check<3,2>(indices[range()][0][range()]);
    1.70 +  check<3,2>(indices[0][range()][range()]);
    1.71 +
    1.72 +  {
    1.73 +    boost::detail::multi_array::index_gen<3,3> is1 =
    1.74 +      indices[range(0,1,2)][range(1,2,3)][range(2,3,4)];
    1.75 +    BOOST_CHECK(is1.ranges_[0] == range(0,1,2));
    1.76 +    BOOST_CHECK(is1.ranges_[1] == range(1,2,3));
    1.77 +    BOOST_CHECK(is1.ranges_[2] == range(2,3,4));
    1.78 +  }
    1.79 +
    1.80 +  {
    1.81 +    boost::detail::multi_array::index_gen<3,2> is2 = 
    1.82 +      indices[range(0,1,2)][2][range(2,3,4)];
    1.83 +    BOOST_CHECK(is2.ranges_[0] == range(0,1,2));
    1.84 +    BOOST_CHECK(is2.ranges_[1] == range(2));
    1.85 +    BOOST_CHECK(is2.ranges_[1].is_degenerate());
    1.86 +    BOOST_CHECK(is2.ranges_[2] == range(2,3,4));
    1.87 +  }
    1.88 +#ifdef __SYMBIAN32__
    1.89 +if(boost::minimal_test::errors_counter() != 0)
    1.90 +   assert_failed = true;
    1.91 +   	testResultXml("idxgen1");
    1.92 +	close_log_file();
    1.93 +#endif
    1.94 +  return boost::exit_success;
    1.95 +}
    1.96 +