]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/multi_array/test/assign.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / multi_array / test / assign.cpp
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 // assign.cpp - Test out operator=() on the different types
15 //
16 //
17 #include "generative_tests.hpp"
18 #include <boost/array.hpp>
19 #include <boost/multi_array.hpp>
20 #include <boost/cstdlib.hpp>
21 #include <algorithm>
22 #include <iostream>
23
24 bool equal(const int& a, const int& b)
25 {
26 return a == b;
27 }
28
29 template <typename ArrayA, typename ArrayB>
30 bool equal(const ArrayA& A, const ArrayB& B)
31 {
32 typename ArrayA::const_iterator ia;
33 typename ArrayB::const_iterator ib = B.begin();
34 for (ia = A.begin(); ia != A.end(); ++ia, ++ib)
35 if (!::equal(*ia, *ib))
36 return false;
37 return true;
38 }
39
40
41 template <typename Array>
42 void access(Array& A, const mutable_array_tag&) {
43 assign(A);
44 typedef boost::multi_array<int,3> array3;
45
46 int insert[] = {
47 99,98,97,96,
48 95,94,93,92,
49 91,90,89,88,
50
51 87,86,85,84,
52 83,82,81,80,
53 79,78,77,76
54 };
55 const int insert_size = 2*3*4;
56 array3 filler(boost::extents[2][3][4]);
57 filler.assign(insert,insert+insert_size);
58
59
60 A = filler;
61
62 BOOST_TEST(::equal(A,filler));
63 ++tests_run;
64 }
65
66 template <typename Array>
67 void access(Array&, const const_array_tag&) {
68 }
69
70
71 int main() {
72 return run_generative_tests();
73 }