Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/multi_array/test/assign.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.6 KB
Line 
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
24bool equal(const int& a, const int& b)
25{
26  return a == b;
27}
28
29template <typename ArrayA, typename ArrayB>
30bool 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
41template <typename Array>
42void 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_CHECK(equal(A,filler));
63  ++tests_run;
64}
65
66template <typename Array>
67void access(Array&, const const_array_tag&) {
68}
69
70
71int test_main(int,char*[]) {
72  return run_generative_tests();
73}
Note: See TracBrowser for help on using the repository browser.