mirror of
https://github.com/boostorg/multi_array.git
synced 2025-05-11 21:33:52 +00:00
Added a new test case that constructs a multi_array from any other
array type (multi_array_ref,array_view,subarray, etc.) [SVN r21976]
This commit is contained in:
parent
afb151d824
commit
154942c4a8
@ -39,6 +39,7 @@ test-suite multi_array
|
||||
[ run iterators.cpp <lib>../../test/build/boost_test_exec_monitor ]
|
||||
[ run slice.cpp <lib>../../test/build/boost_test_exec_monitor ]
|
||||
[ run assign.cpp <lib>../../test/build/boost_test_exec_monitor ]
|
||||
[ run assign_to_array.cpp <lib>../../test/build/boost_test_exec_monitor ]
|
||||
[ run index_bases.cpp <lib>../../test/build/boost_test_exec_monitor ]
|
||||
[ run storage_order.cpp <lib>../../test/build/boost_test_exec_monitor ]
|
||||
[ run reshape.cpp <lib>../../test/build/boost_test_exec_monitor ]
|
||||
|
60
test/assign_to_array.cpp
Normal file
60
test/assign_to_array.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
// 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.
|
||||
|
||||
//
|
||||
// assign_to_array.cpp - multi_array should be constructible from any other
|
||||
// array type in the library.
|
||||
//
|
||||
//
|
||||
#include "generative_tests.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/multi_array.hpp"
|
||||
#include "boost/cstdlib.hpp"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
bool equal(const int& a, const int& b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
template <typename ArrayA, typename ArrayB>
|
||||
bool equal(const ArrayA& A, const ArrayB& B)
|
||||
{
|
||||
typename ArrayA::const_iterator ia;
|
||||
typename ArrayB::const_iterator ib = B.begin();
|
||||
for (ia = A.begin(); ia != A.end(); ++ia, ++ib)
|
||||
if (!equal(*ia, *ib))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <typename Array>
|
||||
void access(Array& A, const mutable_array_tag&) {
|
||||
|
||||
assign(A);
|
||||
access(A,const_array_tag());
|
||||
}
|
||||
|
||||
template <typename Array>
|
||||
void access(Array& A, const const_array_tag&) {
|
||||
typedef boost::multi_array<int,3> array3;
|
||||
array3 acopy(A);
|
||||
BOOST_TEST(equal(acopy,A));
|
||||
++tests_run;
|
||||
}
|
||||
|
||||
|
||||
int test_main(int,char*[]) {
|
||||
return run_generative_tests();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user