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 // access.cpp - operator[] and operator() tests with various arrays
15 // The tests assume that they are working on an Array of shape 2x3x4
18 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
21 #include "generative_tests.hpp"
22 #include "boost/static_assert.hpp"
24 template <typename Array>
25 void access(Array& A, const mutable_array_tag&) {
27 access(A,const_array_tag());
30 access(CA,const_array_tag());
33 template <typename Array>
34 void access(Array& A, const const_array_tag&) {
35 const unsigned int ndims = 3;
36 BOOST_STATIC_ASSERT((Array::dimensionality == ndims));
37 typedef typename Array::index index;
38 const index idx0 = A.index_bases()[0];
39 const index idx1 = A.index_bases()[1];
40 const index idx2 = A.index_bases()[2];
45 for (index i = idx0; i != idx0+2; ++i)
46 for (index j = idx1; j != idx1+3; ++j)
47 for (index k = idx2; k != idx2+4; ++k) {
48 BOOST_CHECK(A[i][j][k] == cnum++);
49 BOOST_CHECK(CA[i][j][k] == A[i][j][k]);
53 for (index i2 = idx0; i2 != idx0+2; ++i2)
54 for (index j2 = idx1; j2 != idx1+3; ++j2)
55 for (index k2 = idx2; k2 != idx2+4; ++k2) {
56 boost::array<index,ndims> indices;
57 indices[0] = i2; indices[1] = j2; indices[2] = k2;
58 BOOST_CHECK(A(indices) == A[i2][j2][k2]);
59 BOOST_CHECK(CA(indices) == A(indices));
64 int test_main(int,char*[]) {
66 if(boost::minimal_test::errors_counter() != 0)
68 testResultXml("access");
71 return run_generative_tests();