os/ossrv/stdcpp/tsrc/Boost_test/multi_array/src/access.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/access.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,72 @@
     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 +// access.cpp - operator[] and operator() tests with various arrays
    1.18 +//    The tests assume that they are working on an Array of shape 2x3x4
    1.19 +//
    1.20 +/*
    1.21 + * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
    1.22 +*/
    1.23 +
    1.24 +#include "generative_tests.hpp"
    1.25 +#include "boost/static_assert.hpp"
    1.26 +
    1.27 +template <typename Array>
    1.28 +void access(Array& A, const mutable_array_tag&) {
    1.29 +  assign(A);
    1.30 +  access(A,const_array_tag());
    1.31 +
    1.32 +  const Array& CA = A;
    1.33 +  access(CA,const_array_tag());
    1.34 +}
    1.35 +
    1.36 +template <typename Array>
    1.37 +void access(Array& A, const const_array_tag&) {
    1.38 +  const unsigned int ndims = 3;
    1.39 +  BOOST_STATIC_ASSERT((Array::dimensionality == ndims));
    1.40 +  typedef typename Array::index index;
    1.41 +  const index idx0 = A.index_bases()[0];
    1.42 +  const index idx1 = A.index_bases()[1];
    1.43 +  const index idx2 = A.index_bases()[2];
    1.44 +
    1.45 +  // operator[]
    1.46 +  int cnum = 0;
    1.47 +  const Array& CA = A;
    1.48 +  for (index i = idx0; i != idx0+2; ++i)
    1.49 +    for (index j = idx1; j != idx1+3; ++j)
    1.50 +      for (index k = idx2; k != idx2+4; ++k) {
    1.51 +        BOOST_CHECK(A[i][j][k] == cnum++);
    1.52 +        BOOST_CHECK(CA[i][j][k] == A[i][j][k]);
    1.53 +      }
    1.54 +
    1.55 +  // operator()
    1.56 +  for (index i2 = idx0; i2 != idx0+2; ++i2)
    1.57 +    for (index j2 = idx1; j2 != idx1+3; ++j2)
    1.58 +      for (index k2 = idx2; k2 != idx2+4; ++k2) {
    1.59 +        boost::array<index,ndims> indices;
    1.60 +        indices[0] = i2; indices[1] = j2; indices[2] = k2;
    1.61 +        BOOST_CHECK(A(indices) == A[i2][j2][k2]);
    1.62 +         BOOST_CHECK(CA(indices) == A(indices));
    1.63 +      }
    1.64 +  ++tests_run;
    1.65 +}
    1.66 +
    1.67 +int test_main(int,char*[]) {
    1.68 +#ifdef __SYMBIAN32__
    1.69 +if(boost::minimal_test::errors_counter() != 0)
    1.70 +   assert_failed = true;
    1.71 +   	testResultXml("access");
    1.72 +	close_log_file();
    1.73 +#endif
    1.74 +  return run_generative_tests();
    1.75 +}