summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/multi_array/test/access.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/multi_array/test/access.cpp
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/multi_array/test/access.cpp')
-rw-r--r--src/boost/libs/multi_array/test/access.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/boost/libs/multi_array/test/access.cpp b/src/boost/libs/multi_array/test/access.cpp
new file mode 100644
index 000000000..0b9f803d0
--- /dev/null
+++ b/src/boost/libs/multi_array/test/access.cpp
@@ -0,0 +1,63 @@
+// Copyright 2002 The Trustees of Indiana University.
+
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// Boost.MultiArray Library
+// Authors: Ronald Garcia
+// Jeremy Siek
+// Andrew Lumsdaine
+// See http://www.boost.org/libs/multi_array for documentation.
+
+//
+// access.cpp - operator[] and operator() tests with various arrays
+// The tests assume that they are working on an Array of shape 2x3x4
+//
+
+#include "generative_tests.hpp"
+#include <boost/static_assert.hpp>
+
+template <typename Array>
+void access(Array& A, const mutable_array_tag&) {
+ assign(A);
+ access(A,const_array_tag());
+
+ const Array& CA = A;
+ access(CA,const_array_tag());
+}
+
+template <typename Array>
+void access(Array& A, const const_array_tag&) {
+ const unsigned int ndims = 3;
+ BOOST_STATIC_ASSERT((Array::dimensionality == ndims));
+ typedef typename Array::index index;
+ const index idx0 = A.index_bases()[0];
+ const index idx1 = A.index_bases()[1];
+ const index idx2 = A.index_bases()[2];
+
+ // operator[]
+ int cnum = 0;
+ const Array& CA = A;
+ for (index i = idx0; i != idx0+2; ++i)
+ for (index j = idx1; j != idx1+3; ++j)
+ for (index k = idx2; k != idx2+4; ++k) {
+ BOOST_TEST(A[i][j][k] == cnum++);
+ BOOST_TEST(CA[i][j][k] == A[i][j][k]);
+ }
+
+ // operator()
+ for (index i2 = idx0; i2 != idx0+2; ++i2)
+ for (index j2 = idx1; j2 != idx1+3; ++j2)
+ for (index k2 = idx2; k2 != idx2+4; ++k2) {
+ boost::array<index,ndims> indices;
+ indices[0] = i2; indices[1] = j2; indices[2] = k2;
+ BOOST_TEST(A(indices) == A[i2][j2][k2]);
+ BOOST_TEST(CA(indices) == A(indices));
+ }
+ ++tests_run;
+}
+
+int main() {
+ return run_generative_tests();
+}