sl@0: // Copyright 2002 The Trustees of Indiana University. sl@0: sl@0: // Use, modification and distribution is subject to the Boost Software sl@0: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: // Boost.MultiArray Library sl@0: // Authors: Ronald Garcia sl@0: // Jeremy Siek sl@0: // Andrew Lumsdaine sl@0: // See http://www.boost.org/libs/multi_array for documentation. sl@0: sl@0: // sl@0: // assign.cpp - Test out operator=() on the different types sl@0: // sl@0: // sl@0: #include "generative_tests.hpp" sl@0: #include "boost/array.hpp" sl@0: #include "boost/multi_array.hpp" sl@0: #include "boost/cstdlib.hpp" sl@0: #include sl@0: #include sl@0: sl@0: bool equal(const int& a, const int& b) sl@0: { sl@0: return a == b; sl@0: } sl@0: sl@0: template sl@0: bool equal(const ArrayA& A, const ArrayB& B) sl@0: { sl@0: typename ArrayA::const_iterator ia; sl@0: typename ArrayB::const_iterator ib = B.begin(); sl@0: for (ia = A.begin(); ia != A.end(); ++ia, ++ib) sl@0: if (!equal(*ia, *ib)) sl@0: return false; sl@0: return true; sl@0: } sl@0: sl@0: sl@0: template sl@0: void access(Array& A, const mutable_array_tag&) { sl@0: assign(A); sl@0: typedef boost::multi_array array3; sl@0: sl@0: int insert[] = { sl@0: 99,98,97,96, sl@0: 95,94,93,92, sl@0: 91,90,89,88, sl@0: sl@0: 87,86,85,84, sl@0: 83,82,81,80, sl@0: 79,78,77,76 sl@0: }; sl@0: const int insert_size = 2*3*4; sl@0: array3 filler(boost::extents[2][3][4]); sl@0: filler.assign(insert,insert+insert_size); sl@0: sl@0: sl@0: A = filler; sl@0: sl@0: BOOST_CHECK(equal(A,filler)); sl@0: ++tests_run; sl@0: } sl@0: sl@0: template sl@0: void access(Array&, const const_array_tag&) { sl@0: } sl@0: sl@0: sl@0: int test_main(int,char*[]) { sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: if(boost::minimal_test::errors_counter() != 0) sl@0: assert_failed = true; sl@0: testResultXml("assign"); sl@0: close_log_file(); sl@0: #endif sl@0: sl@0: return run_generative_tests(); sl@0: sl@0: }