From c30eee78db4cc40a666b0a6ea8e21c48358717c2 Mon Sep 17 00:00:00 2001 From: Daniela Engert Date: Wed, 27 Dec 2017 15:21:06 +0100 Subject: [PATCH 1/6] Get rid of iterator.hpp It does nothing more than pulling std::iterator into namespace boost and including headers. This library only takes advantage of the included headers. OTOH, pulling std::iterator into boost generates deprecation warnings in MSVC 14.1 when compiling in C++17 mode. Even more, Boost's iterator.hpp is deprecated, too. Signed-off-by: Daniela Engert --- include/boost/multi_array/algorithm.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/multi_array/algorithm.hpp b/include/boost/multi_array/algorithm.hpp index c749c3f..81f4b38 100644 --- a/include/boost/multi_array/algorithm.hpp +++ b/include/boost/multi_array/algorithm.hpp @@ -40,7 +40,7 @@ // See http://www.boost.org/libs/multi_array for documentation. -#include "boost/iterator.hpp" +#include namespace boost { namespace detail { From 17f9326ecc7b5b94e8b50d480c51971abc08b5a7 Mon Sep 17 00:00:00 2001 From: CromwellEnage <32967088+CromwellEnage@users.noreply.github.com> Date: Wed, 19 Sep 2018 12:06:36 -0400 Subject: [PATCH 2/6] index_range.size() was missing Added missing size() member function to index_range in accordance with reference documentation. --- include/boost/multi_array/index_range.hpp | 9 +++++++++ test/range1.cpp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/include/boost/multi_array/index_range.hpp b/include/boost/multi_array/index_range.hpp index 3d6035e..b0896a0 100644 --- a/include/boost/multi_array/index_range.hpp +++ b/include/boost/multi_array/index_range.hpp @@ -107,6 +107,15 @@ namespace multi_array { index stride() const { return stride_; } + size_type size(index idx) const + { + return ( + (this->start_ == this_type::from_start()) || ( + this->finish_ == this_type::to_end() + ) + ) ? idx : ((this->finish_ - this->start_) / this->stride_); + } + void set_index_range(index start, index finish, index stride=1) { start_ = start; diff --git a/test/range1.cpp b/test/range1.cpp index a673a9b..db9fef8 100644 --- a/test/range1.cpp +++ b/test/range1.cpp @@ -33,6 +33,7 @@ test_main(int,char*[]) BOOST_CHECK(r1.start() == -3); BOOST_CHECK(r1.finish() == 5); BOOST_CHECK(r1.stride() == 1); + BOOST_CHECK(r1.size(0) == 8); BOOST_CHECK(!r1.is_degenerate()); BOOST_CHECK(r1.get_start(0) == -3); BOOST_CHECK(r1.get_finish(100) == 5); @@ -43,6 +44,7 @@ test_main(int,char*[]) BOOST_CHECK(r2.start() == -3); BOOST_CHECK(r2.finish() == 5); BOOST_CHECK(r2.stride() == 2); + BOOST_CHECK(r2.size(0) == 4); BOOST_CHECK(!r2.is_degenerate()); } @@ -52,6 +54,7 @@ test_main(int,char*[]) BOOST_CHECK(r3.start() == 5); BOOST_CHECK(r3.finish() == 6); BOOST_CHECK(r3.stride() == 1); + BOOST_CHECK(r3.size(0) == 1); BOOST_CHECK(r3.is_degenerate()); } @@ -61,6 +64,7 @@ test_main(int,char*[]) BOOST_CHECK(r4.get_start(0) == 0); BOOST_CHECK(r4.get_finish(100) == 100); BOOST_CHECK(r4.stride() == 1); + BOOST_CHECK(r4.size(0) == 0); } { @@ -69,6 +73,7 @@ test_main(int,char*[]) BOOST_CHECK(r5.start() == -3); BOOST_CHECK(r5.stride() == 2); BOOST_CHECK(r5.finish() == 7); + BOOST_CHECK(r5.size(0) == 5); } // try out all the comparison operators @@ -77,6 +82,7 @@ test_main(int,char*[]) BOOST_CHECK(r6.start() == -3); BOOST_CHECK(r6.stride() == 2); BOOST_CHECK(r6.finish() == 7); + BOOST_CHECK(r6.size(0) == 5); } { @@ -84,6 +90,7 @@ test_main(int,char*[]) BOOST_CHECK(r7.start() == -2); BOOST_CHECK(r7.stride() == 1); BOOST_CHECK(r7.finish() == 8); + BOOST_CHECK(r7.size(0) == 10); } // arithmetic operators @@ -92,6 +99,7 @@ test_main(int,char*[]) BOOST_CHECK(r8.start() == 2); BOOST_CHECK(r8.stride() == 1); BOOST_CHECK(r8.finish() == 7); + BOOST_CHECK(r8.size(0) == 5); } { @@ -99,6 +107,7 @@ test_main(int,char*[]) BOOST_CHECK(r9.start() == -2); BOOST_CHECK(r9.stride() == 1); BOOST_CHECK(r9.finish() == 3); + BOOST_CHECK(r9.size(0) == 5); } return boost::exit_success; From 11d00187fac18376b0e8e65b4215532b8596bd18 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Mon, 18 Feb 2019 15:42:25 -0500 Subject: [PATCH 3/6] Switch to Boost.Lightweight_Test for faster test build and run times --- test/Jamfile.v2 | 87 +++++++++++++++++----------------- test/access.cpp | 12 ++--- test/assert.cpp | 8 ++-- test/assign.cpp | 10 ++-- test/assign_to_array.cpp | 10 ++-- test/compare.cpp | 54 ++++++++++----------- test/concept_checks.cpp | 14 +++--- test/constructors.cpp | 36 +++++++------- test/dimtest.cpp | 6 +-- test/fail_cbracket.cpp | 10 ++-- test/fail_cdata.cpp | 10 ++-- test/fail_citerator.cpp | 8 ++-- test/fail_cparen.cpp | 10 ++-- test/fail_criterator.cpp | 8 ++-- test/fail_csubarray.cpp | 10 ++-- test/fail_csubarray2.cpp | 10 ++-- test/fail_csubarray3.cpp | 10 ++-- test/fail_cview.cpp | 12 ++--- test/fail_cview2.cpp | 14 +++--- test/fail_cview3.cpp | 12 ++--- test/fail_ref_cbracket.cpp | 10 ++-- test/fail_ref_cdata.cpp | 10 ++-- test/fail_ref_citerator.cpp | 8 ++-- test/fail_ref_cparen.cpp | 10 ++-- test/fail_ref_criterator.cpp | 8 ++-- test/fail_ref_csubarray.cpp | 10 ++-- test/fail_ref_csubarray2.cpp | 10 ++-- test/fail_ref_csubarray3.cpp | 10 ++-- test/fail_ref_cview.cpp | 12 ++--- test/fail_ref_cview2.cpp | 12 ++--- test/fail_ref_cview3.cpp | 12 ++--- test/generative_tests.hpp | 13 ++--- test/idxgen1.cpp | 28 +++++------ test/index_bases.cpp | 34 ++++++------- test/iterators.cpp | 18 +++---- test/range1.cpp | 74 ++++++++++++++--------------- test/reshape.cpp | 24 +++++----- test/resize.cpp | 16 +++---- test/reverse_view.cpp | 12 ++--- test/slice.cpp | 20 ++++---- test/stl_interaction.cpp | 14 +++--- test/storage_order.cpp | 18 +++---- test/storage_order_convert.cpp | 12 ++--- test/vc_death.cpp | 10 ++-- 44 files changed, 376 insertions(+), 380 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 0170da7..1c90413 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -4,48 +4,47 @@ # "as is" without express or implied warranty, and with no claim as # to its suitability for any purpose. -test-suite multi_array - : - [ compile-fail fail_cbracket.cpp ] - [ compile-fail fail_cdata.cpp ] - [ compile-fail fail_citerator.cpp ] - [ compile-fail fail_cparen.cpp ] - [ compile-fail fail_criterator.cpp ] - [ compile-fail fail_csubarray.cpp ] - [ compile-fail fail_csubarray2.cpp ] - [ compile-fail fail_csubarray3.cpp ] - [ compile-fail fail_cview.cpp ] - [ compile-fail fail_cview2.cpp ] - [ compile-fail fail_cview3.cpp ] - [ compile-fail fail_ref_cbracket.cpp ] - [ compile-fail fail_ref_cdata.cpp ] - [ compile-fail fail_ref_citerator.cpp ] - [ compile-fail fail_ref_cparen.cpp ] - [ compile-fail fail_ref_criterator.cpp ] - [ compile-fail fail_ref_csubarray.cpp ] - [ compile-fail fail_ref_csubarray2.cpp ] - [ compile-fail fail_ref_csubarray3.cpp ] - [ compile-fail fail_ref_cview.cpp ] - [ compile-fail fail_ref_cview2.cpp ] - [ compile-fail fail_ref_cview3.cpp ] - - [ run constructors.cpp ../../test/build//boost_test_exec_monitor ] - [ run access.cpp ../../test/build//boost_test_exec_monitor ] - [ run compare.cpp ../../test/build//boost_test_exec_monitor ] - [ run iterators.cpp ../../test/build//boost_test_exec_monitor ] - [ run slice.cpp ../../test/build//boost_test_exec_monitor ] - [ run assign.cpp ../../test/build//boost_test_exec_monitor ] - [ run assign_to_array.cpp ../../test/build//boost_test_exec_monitor ] - [ run index_bases.cpp ../../test/build//boost_test_exec_monitor ] - [ run storage_order_convert.cpp ../../test/build//boost_test_exec_monitor ] - [ run storage_order.cpp ../../test/build//boost_test_exec_monitor ] - [ run reshape.cpp ../../test/build//boost_test_exec_monitor ] - [ run range1.cpp ../../test/build//boost_test_exec_monitor ] - [ run idxgen1.cpp ../../test/build//boost_test_exec_monitor ] - [ run stl_interaction.cpp ../../test/build//boost_test_exec_monitor ] - [ run resize.cpp ../../test/build//boost_test_exec_monitor ] - [ run assert.cpp ../../test/build//boost_test_exec_monitor ] - [ run reverse_view.cpp ../../test/build//boost_test_exec_monitor ] +import testing ; - [ compile concept_checks.cpp ] - ; +compile-fail fail_cbracket.cpp ; +compile-fail fail_cdata.cpp ; +compile-fail fail_citerator.cpp ; +compile-fail fail_cparen.cpp ; +compile-fail fail_criterator.cpp ; +compile-fail fail_csubarray.cpp ; +compile-fail fail_csubarray2.cpp ; +compile-fail fail_csubarray3.cpp ; +compile-fail fail_cview.cpp ; +compile-fail fail_cview2.cpp ; +compile-fail fail_cview3.cpp ; +compile-fail fail_ref_cbracket.cpp ; +compile-fail fail_ref_cdata.cpp ; +compile-fail fail_ref_citerator.cpp ; +compile-fail fail_ref_cparen.cpp ; +compile-fail fail_ref_criterator.cpp ; +compile-fail fail_ref_csubarray.cpp ; +compile-fail fail_ref_csubarray2.cpp ; +compile-fail fail_ref_csubarray3.cpp ; +compile-fail fail_ref_cview.cpp ; +compile-fail fail_ref_cview2.cpp ; +compile-fail fail_ref_cview3.cpp ; + +run constructors.cpp ; +run access.cpp ; +run compare.cpp ; +run iterators.cpp ; +run slice.cpp ; +run assign.cpp ; +run assign_to_array.cpp ; +run index_bases.cpp ; +run storage_order_convert.cpp ; +run storage_order.cpp ; +run reshape.cpp ; +run range1.cpp ; +run idxgen1.cpp ; +run stl_interaction.cpp ; +run resize.cpp ; +run assert.cpp ; +run reverse_view.cpp ; + +compile concept_checks.cpp ; diff --git a/test/access.cpp b/test/access.cpp index 755a152..0b9f803 100644 --- a/test/access.cpp +++ b/test/access.cpp @@ -16,7 +16,7 @@ // #include "generative_tests.hpp" -#include "boost/static_assert.hpp" +#include template void access(Array& A, const mutable_array_tag&) { @@ -42,8 +42,8 @@ void access(Array& A, const const_array_tag&) { 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_CHECK(A[i][j][k] == cnum++); - BOOST_CHECK(CA[i][j][k] == A[i][j][k]); + BOOST_TEST(A[i][j][k] == cnum++); + BOOST_TEST(CA[i][j][k] == A[i][j][k]); } // operator() @@ -52,12 +52,12 @@ void access(Array& A, const const_array_tag&) { for (index k2 = idx2; k2 != idx2+4; ++k2) { boost::array indices; indices[0] = i2; indices[1] = j2; indices[2] = k2; - BOOST_CHECK(A(indices) == A[i2][j2][k2]); - BOOST_CHECK(CA(indices) == A(indices)); + BOOST_TEST(A(indices) == A[i2][j2][k2]); + BOOST_TEST(CA(indices) == A(indices)); } ++tests_run; } -int test_main(int,char*[]) { +int main() { return run_generative_tests(); } diff --git a/test/assert.cpp b/test/assert.cpp index fe1f36a..7bdfb31 100644 --- a/test/assert.cpp +++ b/test/assert.cpp @@ -15,10 +15,10 @@ // with exceptions // -#include "boost/test/minimal.hpp" +#include #define BOOST_ENABLE_ASSERT_HANDLER -#include "boost/multi_array.hpp" // includes assert.hpp +#include // includes assert.hpp #include @@ -40,7 +40,7 @@ namespace boost { using namespace boost; int -test_main(int,char*[]) { +main() { typedef multi_array array_t; @@ -55,5 +55,5 @@ test_main(int,char*[]) { //...all good } - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/assign.cpp b/test/assign.cpp index 865a377..583c4f1 100644 --- a/test/assign.cpp +++ b/test/assign.cpp @@ -15,9 +15,9 @@ // // #include "generative_tests.hpp" -#include "boost/array.hpp" -#include "boost/multi_array.hpp" -#include "boost/cstdlib.hpp" +#include +#include +#include #include #include @@ -59,7 +59,7 @@ void access(Array& A, const mutable_array_tag&) { A = filler; - BOOST_CHECK(::equal(A,filler)); + BOOST_TEST(::equal(A,filler)); ++tests_run; } @@ -68,6 +68,6 @@ void access(Array&, const const_array_tag&) { } -int test_main(int,char*[]) { +int main() { return run_generative_tests(); } diff --git a/test/assign_to_array.cpp b/test/assign_to_array.cpp index da23d38..c964f04 100644 --- a/test/assign_to_array.cpp +++ b/test/assign_to_array.cpp @@ -16,9 +16,9 @@ // // #include "generative_tests.hpp" -#include "boost/array.hpp" -#include "boost/multi_array.hpp" -#include "boost/cstdlib.hpp" +#include +#include +#include #include #include @@ -50,11 +50,11 @@ template void access(Array& A, const const_array_tag&) { typedef boost::multi_array array3; array3 acopy(A); - BOOST_CHECK(::equal(acopy,A)); + BOOST_TEST(::equal(acopy,A)); ++tests_run; } -int test_main(int,char*[]) { +int main() { return run_generative_tests(); } diff --git a/test/compare.cpp b/test/compare.cpp index 22b556f..3d03b5b 100644 --- a/test/compare.cpp +++ b/test/compare.cpp @@ -12,16 +12,16 @@ -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include #include #include int -test_main(int, char*[]) +main() { typedef boost::multi_array array; typedef array::size_type size_type; @@ -34,9 +34,9 @@ test_main(int, char*[]) std::vector vals(num_elements, 4.5); A.assign(vals.begin(),vals.end()); array B(A); - BOOST_CHECK(A == B); - BOOST_CHECK(B == A); - BOOST_CHECK(A[0] == B[0]); + BOOST_TEST(A == B); + BOOST_TEST(B == A); + BOOST_TEST(A[0] == B[0]); } // Assignment Operator { @@ -44,15 +44,15 @@ test_main(int, char*[]) std::vector vals(num_elements, 4.5); A.assign(vals.begin(),vals.end()); B = A; - BOOST_CHECK(A == B); - BOOST_CHECK(B == A); - BOOST_CHECK(B[0] == A[0]); + BOOST_TEST(A == B); + BOOST_TEST(B == A); + BOOST_TEST(B[0] == A[0]); typedef array::index_range range; array::index_gen indices; array::array_view<2>::type C = A[indices[2][range()][range()]]; array::array_view<2>::type D = B[indices[2][range()][range()]]; - BOOST_CHECK(C == D); + BOOST_TEST(C == D); } // Different Arrays { @@ -62,15 +62,15 @@ test_main(int, char*[]) A.assign(valsA.begin(),valsA.end()); B.assign(valsB.begin(),valsB.end()); - BOOST_CHECK(A != B); - BOOST_CHECK(B != A); - BOOST_CHECK(A[0] != B[0]); + BOOST_TEST(A != B); + BOOST_TEST(B != A); + BOOST_TEST(A[0] != B[0]); typedef array::index_range range; array::index_gen indices; array::array_view<2>::type C = A[indices[2][range()][range()]]; array::array_view<2>::type D = B[indices[2][range()][range()]]; - BOOST_CHECK(C != D); + BOOST_TEST(C != D); } // Comparisons galore! @@ -108,35 +108,35 @@ test_main(int, char*[]) A.assign(valsA,valsA+num_elements); B.assign(valsB,valsB+num_elements); - BOOST_CHECK(B < A); - BOOST_CHECK(A > B); + BOOST_TEST(B < A); + BOOST_TEST(A > B); - BOOST_CHECK(B <= A); - BOOST_CHECK(A >= B); + BOOST_TEST(B <= A); + BOOST_TEST(A >= B); - BOOST_CHECK(B[0] == A[0]); - BOOST_CHECK(B[2] < A[2]); + BOOST_TEST(B[0] == A[0]); + BOOST_TEST(B[2] < A[2]); array C = A; - BOOST_CHECK(C <= A); - BOOST_CHECK(C >= A); + BOOST_TEST(C <= A); + BOOST_TEST(C >= A); - BOOST_CHECK(!(C < A)); - BOOST_CHECK(!(C > A)); + BOOST_TEST(!(C < A)); + BOOST_TEST(!(C > A)); typedef array::index_range range; array::index_gen indices; array::array_view<2>::type D = A[indices[2][range()][range()]]; array::array_view<2>::type E = B[indices[2][range()][range()]]; - BOOST_CHECK(E < D); - BOOST_CHECK(E <= D); + BOOST_TEST(E < D); + BOOST_TEST(E <= D); } - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/concept_checks.cpp b/test/concept_checks.cpp index c2e24ee..24f391e 100644 --- a/test/concept_checks.cpp +++ b/test/concept_checks.cpp @@ -15,18 +15,18 @@ // make sure the types meet concept requirements // -#include "boost/concept_check.hpp" -#include "boost/multi_array/concept_checks.hpp" -#include "boost/multi_array.hpp" +#include +#include +#include -#include "boost/cstdlib.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; diff --git a/test/constructors.cpp b/test/constructors.cpp index 790df0c..cc74b6d 100644 --- a/test/constructors.cpp +++ b/test/constructors.cpp @@ -15,9 +15,9 @@ // -#include "boost/test/minimal.hpp" +#include -#include "boost/multi_array.hpp" +#include #include #include @@ -30,10 +30,10 @@ void check_shape(const Array& A, int* strides, unsigned int num_elements) { - BOOST_CHECK(A.num_elements() == num_elements); - BOOST_CHECK(A.size() == *sizes); - BOOST_CHECK(std::equal(sizes, sizes + A.num_dimensions(), A.shape())); - BOOST_CHECK(std::equal(strides, strides + A.num_dimensions(), A.strides())); + BOOST_TEST(A.num_elements() == num_elements); + BOOST_TEST(A.size() == *sizes); + BOOST_TEST(std::equal(sizes, sizes + A.num_dimensions(), A.shape())); + BOOST_TEST(std::equal(strides, strides + A.num_dimensions(), A.strides())); check_shape(A[0], ++sizes, ++strides, num_elements / A.size()); } @@ -56,7 +56,7 @@ bool equal(const ArrayA& A, const ArrayB& B) int -test_main(int, char*[]) +main() { typedef boost::multi_array::size_type size_type; boost::array sizes = { { 3, 3, 3 } }; @@ -132,20 +132,20 @@ test_main(int, char*[]) A.assign(vals.begin(),vals.end()); boost::multi_array B(A); check_shape(B, &sizes[0], strides, num_elements); - BOOST_CHECK(::equal(A, B)); + BOOST_TEST(::equal(A, B)); double ptr[27]; boost::multi_array_ref C(ptr,sizes); A.assign(vals.begin(),vals.end()); boost::multi_array_ref D(C); check_shape(D, &sizes[0], strides, num_elements); - BOOST_CHECK(C.data() == D.data()); + BOOST_TEST(C.data() == D.data()); const double* cptr = ptr; boost::const_multi_array_ref E(cptr,sizes); boost::const_multi_array_ref F(E); check_shape(F, &sizes[0], strides, num_elements); - BOOST_CHECK(E.data() == F.data()); + BOOST_TEST(E.data() == F.data()); } @@ -161,15 +161,15 @@ test_main(int, char*[]) boost::const_multi_array_ref C(A); check_shape(B, &sizes[0], strides, num_elements); check_shape(C, &sizes[0], strides, num_elements); - BOOST_CHECK(B.data() == A.data()); - BOOST_CHECK(C.data() == A.data()); + BOOST_TEST(B.data() == A.data()); + BOOST_TEST(C.data() == A.data()); double ptr[27]; boost::multi_array_ref D(ptr,sizes); D.assign(vals.begin(),vals.end()); boost::const_multi_array_ref E(D); check_shape(E, &sizes[0], strides, num_elements); - BOOST_CHECK(E.data() == D.data()); + BOOST_TEST(E.data() == D.data()); } // Assignment Operator @@ -182,7 +182,7 @@ test_main(int, char*[]) A.assign(vals.begin(),vals.end()); B = A; check_shape(B, &sizes[0], strides, num_elements); - BOOST_CHECK(::equal(A, B)); + BOOST_TEST(::equal(A, B)); double ptr1[27]; double ptr2[27]; @@ -190,7 +190,7 @@ test_main(int, char*[]) C.assign(vals.begin(),vals.end()); D = C; check_shape(D, &sizes[0], strides, num_elements); - BOOST_CHECK(::equal(C,D)); + BOOST_TEST(::equal(C,D)); } @@ -209,10 +209,10 @@ test_main(int, char*[]) subarray::value_type C = B[0]; // should comparisons between the types work? - BOOST_CHECK(::equal(A[1][0],C)); - BOOST_CHECK(::equal(B[0],C)); + BOOST_TEST(::equal(A[1][0],C)); + BOOST_TEST(::equal(B[0],C)); } - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/dimtest.cpp b/test/dimtest.cpp index 43c635e..109b226 100644 --- a/test/dimtest.cpp +++ b/test/dimtest.cpp @@ -13,9 +13,9 @@ // // Trying to diagnose problems under visual -#include "boost/config.hpp" -#include "boost/array.hpp" -#include "boost/limits.hpp" +#include +#include +#include #include #include diff --git a/test/fail_cbracket.cpp b/test/fail_cbracket.cpp index 45b661f..69bbdca 100644 --- a/test/fail_cbracket.cpp +++ b/test/fail_cbracket.cpp @@ -15,14 +15,14 @@ // checking constness of const operator[]. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; @@ -36,5 +36,5 @@ test_main(int,char*[]) // FAIL! cannot assign to csma. csma[0][0][0] = 5; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_cdata.cpp b/test/fail_cdata.cpp index b7dd077..696f4c8 100644 --- a/test/fail_cdata.cpp +++ b/test/fail_cdata.cpp @@ -15,14 +15,14 @@ // Testing data() member function constness. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; @@ -37,5 +37,5 @@ test_main(int,char*[]) // FAIL! data() returns a const int* *csma.data() = 0; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_citerator.cpp b/test/fail_citerator.cpp index 42601c3..0b1abb9 100644 --- a/test/fail_citerator.cpp +++ b/test/fail_citerator.cpp @@ -15,12 +15,12 @@ // const_iterator/iterator conversion test // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -int test_main(int,char*[]) { +int main() { typedef boost::multi_array array; typedef array::iterator iterator1; @@ -29,5 +29,5 @@ int test_main(int,char*[]) { // ILLEGAL conversion from const_iterator to iterator iterator1 in = citerator1(); - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_cparen.cpp b/test/fail_cparen.cpp index ff6ae1e..1ccbf05 100644 --- a/test/fail_cparen.cpp +++ b/test/fail_cparen.cpp @@ -15,14 +15,14 @@ // Testing const operator() constness. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; @@ -40,5 +40,5 @@ test_main(int,char*[]) // FAIL! Cannot assign to csma csma(indices) = 5; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_criterator.cpp b/test/fail_criterator.cpp index 648a8c1..194c7a5 100644 --- a/test/fail_criterator.cpp +++ b/test/fail_criterator.cpp @@ -15,12 +15,12 @@ // const_reverse_iterator/reverse_iterator conversion test // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -int test_main(int,char*[]) { +int main() { typedef boost::multi_array array; typedef array::reverse_iterator riterator1; @@ -29,5 +29,5 @@ int test_main(int,char*[]) { // ILLEGAL conversion from const_reverse_iterator to reverse_iterator riterator1 in = criterator1(); - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_csubarray.cpp b/test/fail_csubarray.cpp index a7950e2..bde94c8 100644 --- a/test/fail_csubarray.cpp +++ b/test/fail_csubarray.cpp @@ -15,14 +15,14 @@ // Testing subarray and const_subarray assignment // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; @@ -42,5 +42,5 @@ test_main(int,char*[]) // FAIL! Preserve constness (no const_subarray -> subarray conversion). array::subarray::type sba = csba; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_csubarray2.cpp b/test/fail_csubarray2.cpp index 83a576b..8cba414 100644 --- a/test/fail_csubarray2.cpp +++ b/test/fail_csubarray2.cpp @@ -15,14 +15,14 @@ // Testing constness of subarray operations. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; @@ -41,5 +41,5 @@ test_main(int,char*[]) // FAIL! preserve constness. array::subarray::type sba = sma_const[0]; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_csubarray3.cpp b/test/fail_csubarray3.cpp index 225da46..4c34c16 100644 --- a/test/fail_csubarray3.cpp +++ b/test/fail_csubarray3.cpp @@ -15,14 +15,14 @@ // Testing constness of subarray operations. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; @@ -45,5 +45,5 @@ test_main(int,char*[]) // FAIL! sba cannot be assigned to. sba[j][k] = num++; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_cview.cpp b/test/fail_cview.cpp index 15e3bcb..1361e6a 100644 --- a/test/fail_cview.cpp +++ b/test/fail_cview.cpp @@ -15,15 +15,15 @@ // ensure const_array_view doesn't allow element assignment. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" -#include "boost/type.hpp" +#include +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; @@ -54,7 +54,7 @@ test_main(int,char*[]) // FAIL! const_array_view cannot be assigned to. csma2(elmt) = 5; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_cview2.cpp b/test/fail_cview2.cpp index 2af3781..d0f66e0 100644 --- a/test/fail_cview2.cpp +++ b/test/fail_cview2.cpp @@ -15,17 +15,17 @@ // ensure const_array_view cannot be converted to array_view // -#include "boost/multi_array.hpp" +#include #define BOOST_INCLUDE_MAIN -#include "boost/test/test_tools.hpp" +#include -#include "boost/array.hpp" -#include "boost/type.hpp" -#include "boost/cstdlib.hpp" +#include +#include +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; @@ -52,7 +52,7 @@ test_main(int,char*[]) array::array_view::type csma2 = csma[indices[range(0,2)][range(1,3)][range(0,4,2)]]; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_cview3.cpp b/test/fail_cview3.cpp index 7aea023..302028f 100644 --- a/test/fail_cview3.cpp +++ b/test/fail_cview3.cpp @@ -15,15 +15,15 @@ // ensure const_array_ref doesn't allow assignment. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" -#include "boost/type.hpp" +#include +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; @@ -55,7 +55,7 @@ test_main(int,char*[]) // FAIL! csma2 cannot be assigned to. csma2[i][j][k] = 0; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_cbracket.cpp b/test/fail_ref_cbracket.cpp index f715517..833cb31 100644 --- a/test/fail_ref_cbracket.cpp +++ b/test/fail_ref_cbracket.cpp @@ -15,14 +15,14 @@ // checking constness of const operator[]. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array_ref array_ref; @@ -40,5 +40,5 @@ test_main(int,char*[]) // FAIL! can't assign to const multi_array_ref. csma[0][0][0] = 5; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_cdata.cpp b/test/fail_ref_cdata.cpp index 91d93ec..52e9db3 100644 --- a/test/fail_ref_cdata.cpp +++ b/test/fail_ref_cdata.cpp @@ -15,14 +15,14 @@ // Testing data() member function constness. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array_ref array_ref; @@ -36,5 +36,5 @@ test_main(int,char*[]) // FAIL! data() returns const int*. *csma.data() = 0; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_citerator.cpp b/test/fail_ref_citerator.cpp index 601ef35..135aacb 100644 --- a/test/fail_ref_citerator.cpp +++ b/test/fail_ref_citerator.cpp @@ -15,12 +15,12 @@ // const_iterator/iterator conversion test // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -int test_main(int,char*[]) { +int main() { typedef boost::multi_array_ref array_ref; typedef array_ref::iterator iterator1; @@ -29,5 +29,5 @@ int test_main(int,char*[]) { // FAIL! ILLEGAL conversion from const_iterator to iterator iterator1 in = citerator1(); - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_cparen.cpp b/test/fail_ref_cparen.cpp index a279f33..3ae30c4 100644 --- a/test/fail_ref_cparen.cpp +++ b/test/fail_ref_cparen.cpp @@ -15,14 +15,14 @@ // Testing const operator() constness. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array_ref array_ref; @@ -40,5 +40,5 @@ test_main(int,char*[]) // FAIL! cannot assign to a const multi_array_ref csma(indices) = 5; - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_criterator.cpp b/test/fail_ref_criterator.cpp index a273e3d..1af8f19 100644 --- a/test/fail_ref_criterator.cpp +++ b/test/fail_ref_criterator.cpp @@ -15,12 +15,12 @@ // const_reverse_iterator/reverse_iterator conversion test // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -int test_main(int,char*[]) { +int main() { typedef boost::multi_array_ref array_ref; typedef array_ref::reverse_iterator riterator1; @@ -29,5 +29,5 @@ int test_main(int,char*[]) { // Fail! ILLEGAL conversion from const_reverse_iterator to reverse_iterator riterator1 in = criterator1(); - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_csubarray.cpp b/test/fail_ref_csubarray.cpp index 1634bfe..461175a 100644 --- a/test/fail_ref_csubarray.cpp +++ b/test/fail_ref_csubarray.cpp @@ -15,14 +15,14 @@ // Testing subarray and const_subarray assignment // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array_ref array_ref; @@ -44,5 +44,5 @@ test_main(int,char*[]) array_ref::subarray::type sba = csba; // FAIL! preserve constness. - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_csubarray2.cpp b/test/fail_ref_csubarray2.cpp index e98a632..203c136 100644 --- a/test/fail_ref_csubarray2.cpp +++ b/test/fail_ref_csubarray2.cpp @@ -15,14 +15,14 @@ // Testing constness of subarray operations. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array_ref array_ref; @@ -45,5 +45,5 @@ test_main(int,char*[]) array_ref::subarray::type sba = sma_const[0]; // FAIL! // preserve constness - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_csubarray3.cpp b/test/fail_ref_csubarray3.cpp index 79579c7..f4df695 100644 --- a/test/fail_ref_csubarray3.cpp +++ b/test/fail_ref_csubarray3.cpp @@ -15,14 +15,14 @@ // Testing constness of subarray operations. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array_ref array_ref; @@ -48,5 +48,5 @@ test_main(int,char*[]) for (array_ref::index k = 0; k != 4; ++k) sba[j][k] = num++; // FAIL! can't assign to const_subarray. - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_cview.cpp b/test/fail_ref_cview.cpp index d1fea5d..55c0265 100644 --- a/test/fail_ref_cview.cpp +++ b/test/fail_ref_cview.cpp @@ -15,15 +15,15 @@ // ensure const_array_view doesn't allow element assignment. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" -#include "boost/type.hpp" +#include +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array_ref array_ref; @@ -51,7 +51,7 @@ test_main(int,char*[]) csma2(elmt) = 5; // FAIL! csma is read only - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_cview2.cpp b/test/fail_ref_cview2.cpp index a85152b..4083b2e 100644 --- a/test/fail_ref_cview2.cpp +++ b/test/fail_ref_cview2.cpp @@ -15,15 +15,15 @@ // ensure const_array_view cannot be converted to array_view // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" -#include "boost/type.hpp" +#include +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array_ref array_ref; @@ -52,7 +52,7 @@ test_main(int,char*[]) for (array_ref::index k = 0; k != 2; ++k) csma2[i][j][k] = 0; // FAIL! csma2 is read only - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/fail_ref_cview3.cpp b/test/fail_ref_cview3.cpp index 13a8f48..a8d459d 100644 --- a/test/fail_ref_cview3.cpp +++ b/test/fail_ref_cview3.cpp @@ -15,15 +15,15 @@ // ensure const_array_view doesn't allow assignment. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" -#include "boost/type.hpp" +#include +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array_ref array_ref; @@ -53,7 +53,7 @@ test_main(int,char*[]) for (array_ref::index k = 0; k != 2; ++k) csma2[i][j][k] = 0; // FAIL! csma2 is read only. - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/generative_tests.hpp b/test/generative_tests.hpp index d246f87..f4636ee 100644 --- a/test/generative_tests.hpp +++ b/test/generative_tests.hpp @@ -45,9 +45,9 @@ // // int test_main(int,char*[]) { return run_generative_tests(); } // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include #include /* BOOST_NO_SFINAE */ #include @@ -100,7 +100,7 @@ template void access(Array& A, const const_array_tag&); template -int run_configuration(const StorageOrder3& so3, +void run_configuration(const StorageOrder3& so3, const StorageOrder4& so4, const Modifier& modifier) { // multi_array @@ -213,11 +213,10 @@ int run_configuration(const StorageOrder3& so3, access(C,const_array_tag()); } } - return boost::exit_success; } template -int run_storage_tests(const ArrayModifier& modifier) { +void run_storage_tests(const ArrayModifier& modifier) { run_configuration(boost::c_storage_order(), boost::c_storage_order(),modifier); run_configuration(boost::fortran_storage_order(), @@ -228,8 +227,6 @@ int run_storage_tests(const ArrayModifier& modifier) { run_configuration(boost::general_storage_order<3>(ordering,ascending), boost::general_storage_order<4>(ordering,ascending), modifier); - - return boost::exit_success; } struct null_modifier { @@ -279,7 +276,7 @@ int run_generative_tests() { run_storage_tests(reindex_modifier()); run_storage_tests(reshape_modifier()); std::cout << "Total Tests Run: " << tests_run << '\n'; - return boost::exit_success; + return boost::report_errors(); } #endif // GENERATIVE_TESTS_RG072001_HPP diff --git a/test/idxgen1.cpp b/test/idxgen1.cpp index 67cbb2f..ca9dcc7 100644 --- a/test/idxgen1.cpp +++ b/test/idxgen1.cpp @@ -14,12 +14,12 @@ // idxset1.cpp - testing the code for index_gen // -#include "boost/multi_array/index_gen.hpp" -#include "boost/multi_array/index_range.hpp" -#include "boost/multi_array/types.hpp" -#include "boost/test/minimal.hpp" +#include +#include +#include +#include -#include "boost/array.hpp" +#include typedef boost::detail::multi_array::index index_type; typedef boost::detail::multi_array::size_type size_type; @@ -37,7 +37,7 @@ bool operator==(const range& lhs,const range& rhs) { } int -test_main(int,char*[]) +main() { boost::detail::multi_array::index_gen<0,0> indices; @@ -62,20 +62,20 @@ test_main(int,char*[]) { boost::detail::multi_array::index_gen<3,3> is1 = indices[range(0,1,2)][range(1,2,3)][range(2,3,4)]; - BOOST_CHECK(is1.ranges_[0] == range(0,1,2)); - BOOST_CHECK(is1.ranges_[1] == range(1,2,3)); - BOOST_CHECK(is1.ranges_[2] == range(2,3,4)); + BOOST_TEST(is1.ranges_[0] == range(0,1,2)); + BOOST_TEST(is1.ranges_[1] == range(1,2,3)); + BOOST_TEST(is1.ranges_[2] == range(2,3,4)); } { boost::detail::multi_array::index_gen<3,2> is2 = indices[range(0,1,2)][2][range(2,3,4)]; - BOOST_CHECK(is2.ranges_[0] == range(0,1,2)); - BOOST_CHECK(is2.ranges_[1] == range(2)); - BOOST_CHECK(is2.ranges_[1].is_degenerate()); - BOOST_CHECK(is2.ranges_[2] == range(2,3,4)); + BOOST_TEST(is2.ranges_[0] == range(0,1,2)); + BOOST_TEST(is2.ranges_[1] == range(2)); + BOOST_TEST(is2.ranges_[1].is_degenerate()); + BOOST_TEST(is2.ranges_[2] == range(2,3,4)); } - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/index_bases.cpp b/test/index_bases.cpp index 87564c2..159e394 100644 --- a/test/index_bases.cpp +++ b/test/index_bases.cpp @@ -14,15 +14,15 @@ // index_bases - test of the index_base modifying facilities. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include #include #include int -test_main(int,char*[]) +main() { typedef boost::multi_array array; typedef boost::multi_array_ref array_ref; @@ -63,11 +63,11 @@ test_main(int,char*[]) for (size_type a = 0; a < A.shape()[0]; ++a) for (size_type b = 0; b < A.shape()[1]; ++b) for (size_type c = 0; c < A.shape()[2]; ++c) { - BOOST_CHECK(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); - BOOST_CHECK(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); - BOOST_CHECK(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); + BOOST_TEST(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); + BOOST_TEST(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); + BOOST_TEST(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); // Test that E does not inherit A's index_base - BOOST_CHECK(E[a][b][c] == B[a][b][c]); + BOOST_TEST(E[a][b][c] == B[a][b][c]); } } @@ -100,10 +100,10 @@ test_main(int,char*[]) for (size_type a = 0; a < A.shape()[0]; ++a) for (size_type b = 0; b < A.shape()[1]; ++b) for (size_type c = 0; c < A.shape()[2]; ++c) { - BOOST_CHECK(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); - BOOST_CHECK(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); - BOOST_CHECK(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); - BOOST_CHECK(E[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); + BOOST_TEST(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); + BOOST_TEST(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); + BOOST_TEST(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); + BOOST_TEST(E[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); } } @@ -142,12 +142,12 @@ test_main(int,char*[]) for (size_type a = 0; a < A.shape()[0]; ++a) for (size_type b = 0; b < A.shape()[1]; ++b) for (size_type c = 0; c < A.shape()[2]; ++c) { - BOOST_CHECK(A[a+1][b+1][c+1] == B[a][b][c]); - BOOST_CHECK(C[a+1][b+1][c+1] == B[a][b][c]); - BOOST_CHECK(D[a+1][b+1][c+1] == B[a][b][c]); - BOOST_CHECK(E[a+1][b+1][c+1] == B[a][b][c]); + BOOST_TEST(A[a+1][b+1][c+1] == B[a][b][c]); + BOOST_TEST(C[a+1][b+1][c+1] == B[a][b][c]); + BOOST_TEST(D[a+1][b+1][c+1] == B[a][b][c]); + BOOST_TEST(E[a+1][b+1][c+1] == B[a][b][c]); } } - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/iterators.cpp b/test/iterators.cpp index 5686c2b..2b26a96 100644 --- a/test/iterators.cpp +++ b/test/iterators.cpp @@ -17,9 +17,9 @@ #define MULTIARRAY_TEST_ASSIGN #include "generative_tests.hpp" -#include "boost/concept_check.hpp" // for ignore_unused_variable_warning -#include "boost/mpl/if.hpp" -#include "boost/type_traits/is_same.hpp" +#include // for ignore_unused_variable_warning +#include +#include // iterator-test-specific code @@ -107,8 +107,8 @@ void test_iterators(Array& A, const IterTraits&) { typedef typename IterTraits::iterator3 iterator; iterator i1 = A.begin(); iterator i2 = A.end(); - BOOST_CHECK(i1 < i2); - BOOST_CHECK((i2 - i1) == typename iterator::difference_type(2)); + BOOST_TEST(i1 < i2); + BOOST_TEST((i2 - i1) == typename iterator::difference_type(2)); } // Standard Array Iteration @@ -121,7 +121,7 @@ void test_iterators(Array& A, const IterTraits&) { for (iterator3 i = A.begin(); i != A.end(); ++i) for(iterator2 ii = (*i).begin(); ii != (*i).end(); ++ii) for(iterator1 iii = (*ii).begin(); iii != (*ii).end(); ++iii) - BOOST_CHECK(*iii == vals++); + BOOST_TEST(*iii == vals++); } // Using operator->() on iterators @@ -134,7 +134,7 @@ void test_iterators(Array& A, const IterTraits&) { for (iterator3 i = A.begin(); i != A.end(); ++i) for(iterator2 ii = i->begin(); ii != i->end(); ++ii) for(iterator1 iii = ii->begin(); iii != ii->end(); ++iii) - BOOST_CHECK(*iii == vals++); + BOOST_TEST(*iii == vals++); } // Reverse Iterator Hierarchy Test @@ -148,7 +148,7 @@ void test_iterators(Array& A, const IterTraits&) { for(riterator2 ii = (*i).rbegin(); ii != (riterator2)(*i).rend(); ++ii) for(riterator1 iii = (*ii).rbegin(); iii != (riterator1)(*ii).rend(); ++iii) - BOOST_CHECK(*iii == check_iter_val--); + BOOST_TEST(*iii == check_iter_val--); } ++tests_run; } @@ -182,7 +182,7 @@ void access(Array& A, const const_array_tag&) { int -test_main(int, char*[]) +main() { return run_generative_tests(); } diff --git a/test/range1.cpp b/test/range1.cpp index a673a9b..7141d84 100644 --- a/test/range1.cpp +++ b/test/range1.cpp @@ -15,91 +15,91 @@ // -#include "boost/multi_array/index_range.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include #include int -test_main(int,char*[]) +main() { typedef boost::detail::multi_array::index_range range; { // typical range creation and extraction range r1(-3,5); - BOOST_CHECK(r1.start() == -3); - BOOST_CHECK(r1.finish() == 5); - BOOST_CHECK(r1.stride() == 1); - BOOST_CHECK(!r1.is_degenerate()); - BOOST_CHECK(r1.get_start(0) == -3); - BOOST_CHECK(r1.get_finish(100) == 5); + BOOST_TEST(r1.start() == -3); + BOOST_TEST(r1.finish() == 5); + BOOST_TEST(r1.stride() == 1); + BOOST_TEST(!r1.is_degenerate()); + BOOST_TEST(r1.get_start(0) == -3); + BOOST_TEST(r1.get_finish(100) == 5); } { range r2(-3,5,2); - BOOST_CHECK(r2.start() == -3); - BOOST_CHECK(r2.finish() == 5); - BOOST_CHECK(r2.stride() == 2); - BOOST_CHECK(!r2.is_degenerate()); + BOOST_TEST(r2.start() == -3); + BOOST_TEST(r2.finish() == 5); + BOOST_TEST(r2.stride() == 2); + BOOST_TEST(!r2.is_degenerate()); } { // degenerate creation range r3(5); - BOOST_CHECK(r3.start() == 5); - BOOST_CHECK(r3.finish() == 6); - BOOST_CHECK(r3.stride() == 1); - BOOST_CHECK(r3.is_degenerate()); + BOOST_TEST(r3.start() == 5); + BOOST_TEST(r3.finish() == 6); + BOOST_TEST(r3.stride() == 1); + BOOST_TEST(r3.is_degenerate()); } { // default range creation range r4; - BOOST_CHECK(r4.get_start(0) == 0); - BOOST_CHECK(r4.get_finish(100) == 100); - BOOST_CHECK(r4.stride() == 1); + BOOST_TEST(r4.get_start(0) == 0); + BOOST_TEST(r4.get_finish(100) == 100); + BOOST_TEST(r4.stride() == 1); } { // create a range using the setter methods range r5 = range().stride(2).start(-3).finish(7); - BOOST_CHECK(r5.start() == -3); - BOOST_CHECK(r5.stride() == 2); - BOOST_CHECK(r5.finish() == 7); + BOOST_TEST(r5.start() == -3); + BOOST_TEST(r5.stride() == 2); + BOOST_TEST(r5.finish() == 7); } // try out all the comparison operators { range r6 = -3 <= range().stride(2) < 7; - BOOST_CHECK(r6.start() == -3); - BOOST_CHECK(r6.stride() == 2); - BOOST_CHECK(r6.finish() == 7); + BOOST_TEST(r6.start() == -3); + BOOST_TEST(r6.stride() == 2); + BOOST_TEST(r6.finish() == 7); } { range r7 = -3 < range() <= 7; - BOOST_CHECK(r7.start() == -2); - BOOST_CHECK(r7.stride() == 1); - BOOST_CHECK(r7.finish() == 8); + BOOST_TEST(r7.start() == -2); + BOOST_TEST(r7.stride() == 1); + BOOST_TEST(r7.finish() == 8); } // arithmetic operators { range r8 = range(0,5) + 2; - BOOST_CHECK(r8.start() == 2); - BOOST_CHECK(r8.stride() == 1); - BOOST_CHECK(r8.finish() == 7); + BOOST_TEST(r8.start() == 2); + BOOST_TEST(r8.stride() == 1); + BOOST_TEST(r8.finish() == 7); } { range r9 = range(0,5) - 2; - BOOST_CHECK(r9.start() == -2); - BOOST_CHECK(r9.stride() == 1); - BOOST_CHECK(r9.finish() == 3); + BOOST_TEST(r9.start() == -2); + BOOST_TEST(r9.stride() == 1); + BOOST_TEST(r9.finish() == 3); } - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/reshape.cpp b/test/reshape.cpp index a65f75e..a611fe4 100644 --- a/test/reshape.cpp +++ b/test/reshape.cpp @@ -14,15 +14,15 @@ // reshape.cpp - testing reshaping functionality // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" -#include "boost/type.hpp" +#include +#include int -test_main(int,char*[]) +main() { const int ndims=3; typedef boost::multi_array array; @@ -52,9 +52,9 @@ test_main(int,char*[]) for (array::index i = 0; i != 4; ++i) for (array::index j = 0; j != 3; ++j) for (array::index k = 0; k != 2; ++k) { - BOOST_CHECK(A[i][j][k] == *ptr); - BOOST_CHECK(B[i][j][k] == *ptr); - BOOST_CHECK(C[i][j][k] == *ptr++); + BOOST_TEST(A[i][j][k] == *ptr); + BOOST_TEST(B[i][j][k] == *ptr); + BOOST_TEST(C[i][j][k] == *ptr++); } } @@ -80,13 +80,13 @@ test_main(int,char*[]) for (array::index i = 0; i != 4; ++i) for (array::index j = 1; j != 4; ++j) for (array::index k = -1; k != 1; ++k) { - BOOST_CHECK(A[i][j][k] == *ptr); - BOOST_CHECK(B[i][j][k] == *ptr); - BOOST_CHECK(C[i][j][k] == *ptr++); + BOOST_TEST(A[i][j][k] == *ptr); + BOOST_TEST(B[i][j][k] == *ptr); + BOOST_TEST(C[i][j][k] == *ptr++); } } - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/resize.cpp b/test/resize.cpp index c00e740..c242200 100644 --- a/test/resize.cpp +++ b/test/resize.cpp @@ -14,13 +14,13 @@ // resize.cpp - Test of resizing multi_arrays // -#include "boost/test/minimal.hpp" -#include "boost/multi_array.hpp" +#include +#include #include using namespace std; -int test_main(int,char*[]) { +int main() { typedef boost::multi_array marray; @@ -58,7 +58,7 @@ int test_main(int,char*[]) { marray A(boost::extents[2][3][4]); A.assign(A_data,A_data+(2*3*4)); A.resize(boost::extents[4][3][2]); - BOOST_CHECK(std::equal(A_resize,A_resize+(4*3*2),A.data())); + BOOST_TEST(std::equal(A_resize,A_resize+(4*3*2),A.data())); } // resize through the Collection @@ -67,14 +67,14 @@ int test_main(int,char*[]) { A.assign(A_data,A_data+(2*3*4)); boost::array new_extents = {{4,3,2}}; A.resize(new_extents); - BOOST_CHECK(std::equal(A_resize,A_resize+(4*3*2),A.data())); + BOOST_TEST(std::equal(A_resize,A_resize+(4*3*2),A.data())); } // default construct all the new elements (in this case, all elements) { marray defaultA; defaultA.resize(boost::extents[2][3][4]); - BOOST_CHECK(std::accumulate(defaultA.data(), + BOOST_TEST(std::accumulate(defaultA.data(), defaultA.data()+(2*3*4),0) == 0); } @@ -107,7 +107,7 @@ int test_main(int,char*[]) { for (int x = 0; x < 3; x++) { for (int y = 0; y < 4; y++) { for (int z = 0; z < 2; z++) { - BOOST_CHECK(*(A.data() + check) == check); + BOOST_TEST(*(A.data() + check) == check); ++check; } } @@ -123,5 +123,5 @@ int test_main(int,char*[]) { } - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/reverse_view.cpp b/test/reverse_view.cpp index ee2c733..092d906 100644 --- a/test/reverse_view.cpp +++ b/test/reverse_view.cpp @@ -14,12 +14,12 @@ // reverse_view.cpp - a small test of creating a view with negative strides // -#include "boost/multi_array.hpp" -#include "boost/test/minimal.hpp" -#include "boost/array.hpp" +#include +#include +#include int -test_main(int,char*[]) +main() { using namespace boost; @@ -36,8 +36,8 @@ test_main(int,char*[]) array::array_view<1>::type B = A[indices[range(3, -1, -1)]]; for(multi_array_types::size_type i = 0; i != B.size(); ++i) { - BOOST_CHECK(B[i] == rdata[i]); + BOOST_TEST(B[i] == rdata[i]); } - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/slice.cpp b/test/slice.cpp index 5406c81..ba5bccc 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -15,9 +15,9 @@ // #include "generative_tests.hpp" -#include "boost/array.hpp" -#include "boost/mpl/if.hpp" -#include "boost/type_traits/is_same.hpp" +#include +#include +#include template struct view_traits_mutable { @@ -71,10 +71,10 @@ void test_views(Array& A, const ViewTraits&) { for (index i = 0; i != 2; ++i) for (index j = 0; j != 2; ++j) for (index k = 0; k != 2; ++k) { - BOOST_CHECK(B[i][j][k] == A[idx0+i][idx1+j+1][idx2+k*2]); + BOOST_TEST(B[i][j][k] == A[idx0+i][idx1+j+1][idx2+k*2]); boost::array elmts; elmts[0]=i; elmts[1]=j; elmts[2]=k; - BOOST_CHECK(B(elmts) == A[idx0+i][idx1+j+1][idx2+k*2]); + BOOST_TEST(B(elmts) == A[idx0+i][idx1+j+1][idx2+k*2]); } } // Degenerate dimensions @@ -84,10 +84,10 @@ void test_views(Array& A, const ViewTraits&) { for (index i = 0; i != 2; ++i) for (index j = 0; j != 2; ++j) { - BOOST_CHECK(B[i][j] == A[idx0+i][idx1+1][idx2+j*2]); + BOOST_TEST(B[i][j] == A[idx0+i][idx1+1][idx2+j*2]); boost::array elmts; elmts[0]=i; elmts[1]=j; - BOOST_CHECK(B(elmts) == A[idx0+i][idx1+1][idx2+j*2]); + BOOST_TEST(B(elmts) == A[idx0+i][idx1+1][idx2+j*2]); } } @@ -105,10 +105,10 @@ void test_views(Array& A, const ViewTraits&) { for (index i = 0; i != 2; ++i) for (index j = 0; j != 2; ++j) for (index k = 0; k != 2; ++k) { - BOOST_CHECK(B[i][j][k] == A[idx0+i][idx1+j][idx2+2-k]); + BOOST_TEST(B[i][j][k] == A[idx0+i][idx1+j][idx2+2-k]); boost::array elmts; elmts[0]=i; elmts[1]=j; elmts[2]=k; - BOOST_CHECK(B(elmts) == A[idx0+i][idx1+j][idx2+2-k]); + BOOST_TEST(B(elmts) == A[idx0+i][idx1+j][idx2+2-k]); } } @@ -141,6 +141,6 @@ void access(Array& A, const const_array_tag&) { } -int test_main(int,char*[]) { +int main() { return run_generative_tests(); } diff --git a/test/stl_interaction.cpp b/test/stl_interaction.cpp index e6424c8..48e016b 100644 --- a/test/stl_interaction.cpp +++ b/test/stl_interaction.cpp @@ -14,14 +14,14 @@ // stl_interaction.cpp - Make sure multi_arrays work with STL containers. // -#include "boost/test/minimal.hpp" +#include -#include "boost/multi_array.hpp" +#include #include #include int -test_main(int, char*[]) +main() { using boost::extents; using boost::indices; @@ -51,7 +51,7 @@ test_main(int, char*[]) myarray.assign(data,data+data_size); array3vec myvec(5,myarray); - BOOST_CHECK(myarray == myvec[1]); + BOOST_TEST(myarray == myvec[1]); array3::array_view<2>::type myview = myarray[indices[1][range(0,2)][range(1,3)]]; @@ -65,8 +65,8 @@ test_main(int, char*[]) myvec.push_back(myarray); - BOOST_CHECK(myarray != myvec[1]); - BOOST_CHECK(myarray == myvec[5]); + BOOST_TEST(myarray != myvec[1]); + BOOST_TEST(myarray == myvec[5]); - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/storage_order.cpp b/test/storage_order.cpp index 16fe28f..ac77e58 100644 --- a/test/storage_order.cpp +++ b/test/storage_order.cpp @@ -14,14 +14,14 @@ // storage_order.cpp - testing storage_order-isms. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include int -test_main(int,char*[]) +main() { const int ndims=3; @@ -67,7 +67,7 @@ test_main(int,char*[]) for (array::index i = 0; i != 2; ++i) for (array::index j = 0; j != 3; ++j) for (array::index k = 0; k != 4; ++k) - BOOST_CHECK(A[i][j][k] == *num++); + BOOST_TEST(A[i][j][k] == *num++); } // Mimic fortran_storage_order using @@ -88,7 +88,7 @@ test_main(int,char*[]) for (array::index i = 0; i != 2; ++i) for (array::index j = 0; j != 3; ++j) for (array::index k = 0; k != 4; ++k) - BOOST_CHECK(A[i][j][k] == *num++); + BOOST_TEST(A[i][j][k] == *num++); } // general_storage_order with arbitrary storage order @@ -119,7 +119,7 @@ test_main(int,char*[]) for (array::index i = 0; i != 2; ++i) for (array::index j = 0; j != 3; ++j) for (array::index k = 0; k != 4; ++k) - BOOST_CHECK(A[i][j][k] == *num++); + BOOST_TEST(A[i][j][k] == *num++); } @@ -152,8 +152,8 @@ test_main(int,char*[]) for (array::index i = 0; i != 2; ++i) for (array::index j = 0; j != 3; ++j) for (array::index k = 0; k != 4; ++k) - BOOST_CHECK(A[i][j][k] == *num++); + BOOST_TEST(A[i][j][k] == *num++); } - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/storage_order_convert.cpp b/test/storage_order_convert.cpp index 5952584..e1178ed 100644 --- a/test/storage_order_convert.cpp +++ b/test/storage_order_convert.cpp @@ -14,12 +14,12 @@ // test out my new storage_order stuff // -#include "boost/test/minimal.hpp" +#include -#include "boost/multi_array/storage_order.hpp" +#include int -test_main(int,char*[]) { +main() { using namespace boost; @@ -31,9 +31,9 @@ test_main(int,char*[]) { general_storage_order<5> fortran_storage(fortran_ordering.begin(), ascending.begin()); - BOOST_CHECK(c_storage == (general_storage_order<5>) c_storage_order()); - BOOST_CHECK(fortran_storage == + BOOST_TEST(c_storage == (general_storage_order<5>) c_storage_order()); + BOOST_TEST(fortran_storage == (general_storage_order<5>) fortran_storage_order()); - return boost::exit_success; + return boost::report_errors(); } diff --git a/test/vc_death.cpp b/test/vc_death.cpp index 8e1dc9d..e241ca6 100644 --- a/test/vc_death.cpp +++ b/test/vc_death.cpp @@ -14,15 +14,15 @@ // index_bases - test of the index_base modifying facilities. // -#include "boost/multi_array.hpp" +#include -#include "boost/test/minimal.hpp" +#include -#include "boost/array.hpp" +#include #include #include int -test_main(int,char*[]) +main() { typedef boost::multi_array array; typedef array::array_view<3>::type array_view; @@ -40,5 +40,5 @@ test_main(int,char*[]) array_view E = A[indices[irange(1,2)][irange(1,2)][irange(1,2)]]; } - return boost::exit_success; + return boost::report_errors(); } From 453d38b269b4cc9ef7ce3fe3cc5fa3e7520387a3 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Mon, 18 Feb 2019 17:23:39 -0500 Subject: [PATCH 4/6] Update sgi.com/tech URLs in docs to boost.org/sgi --- doc/iterator_categories.html | 6 +++--- doc/reference.html | 20 ++++++++++---------- doc/user.html | 2 +- doc/xml/MultiArray.xml | 14 +++++++------- doc/xml/const_multi_array_ref.xml | 2 +- doc/xml/multi_array.xml | 2 +- doc/xml/multi_array_ref.xml | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/doc/iterator_categories.html b/doc/iterator_categories.html index f8d7451..df10ff1 100644 --- a/doc/iterator_categories.html +++ b/doc/iterator_categories.html @@ -651,8 +651,8 @@ Iterator. The Forward Iterator is an iterator that can be incremented. Also, it is permissible to make multiple passes through the iterator's range.

Refinement of

Copy -Constructible, Assignable, Default -Constructible, and Equality +Constructible, Assignable, Default +Constructible, and Equality Comparable

Associated types

@@ -725,7 +725,7 @@ Traversal Iterator Iterator An iterator that provides constant-time methods for moving forward and backward in arbitrary-sized steps.

Refinement of

Bidirectional -Traversal Iterator and Less Than +Traversal Iterator and Less Than Comparable where < is a total ordering

Associated types

diff --git a/doc/reference.html b/doc/reference.html index 3cd136d..bde4fe2 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -353,21 +353,21 @@ This expression generates a view of the array determined by the used to construct indices.
a == bboolThis performs a lexicographical comparison of the values of a and b. The element -type must model EqualityComparable for this +type must model EqualityComparable for this expression to be valid.
a < bboolThis performs a lexicographical comparison of the values of a and b. The element -type must model LessThanComparable for this +type must model LessThanComparable for this expression to be valid.
a <= bboolThis performs a lexicographical comparison of the values of a and b. The element -type must model EqualityComparable and -LessThanComparable for this +type must model EqualityComparable and +LessThanComparable for this expression to be valid.
a > bboolThis performs a lexicographical comparison of the values of a and b. The element -type must model EqualityComparable and -LessThanComparable for this +type must model EqualityComparable and +LessThanComparable for this expression to be valid.
a >= bboolThis performs a lexicographical comparison of the values of a and b. The element -type must model LessThanComparable for this +type must model LessThanComparable for this expression to be valid.

Complexity guarantees

begin() and end() execute in amortized constant time. size() executes in at most linear time in the @@ -589,7 +589,7 @@ using a replaceable allocator.

Model Of.  MultiArray, CopyConstructible. Depending on the element type, -it may also model EqualityComparable and LessThanComparable. +it may also model EqualityComparable and LessThanComparable.

Synopsis. 

 
 namespace boost {
@@ -818,7 +818,7 @@ of the constructors.
 MultiArray,
 CopyConstructible.
 and depending on the element type, it may also model
-EqualityComparable and LessThanComparable. 
+EqualityComparable and LessThanComparable. 
 Detailed descriptions are provided here only for operations that are
 not described in the multi_array reference.
 

Synopsis. 

@@ -978,7 +978,7 @@ of the constructors.
 MultiArray,
 CopyConstructible.
 and depending on the element type, it may also model
-EqualityComparable and LessThanComparable. 
+EqualityComparable and LessThanComparable. 
 
 Detailed descriptions are provided here only for operations that are
 not described in the multi_array reference.
diff --git a/doc/user.html b/doc/user.html
index 57d73a3..53a45b4 100644
--- a/doc/user.html
+++ b/doc/user.html
@@ -612,7 +612,7 @@ cases can be found here.
 

Related Work

boost::array - and std::vector are + and std::vector are one-dimensional containers of user data. Both manage their own memory. std::valarray is a low-level C++ Standard Library component diff --git a/doc/xml/MultiArray.xml b/doc/xml/MultiArray.xml index 5978b07..ec336e7 100644 --- a/doc/xml/MultiArray.xml +++ b/doc/xml/MultiArray.xml @@ -567,7 +567,7 @@ This expression generates a view of the array determined by the bool This performs a lexicographical comparison of the values of a and b. The element -type must model EqualityComparable for this +type must model EqualityComparable for this expression to be valid. @@ -575,7 +575,7 @@ expression to be valid. bool This performs a lexicographical comparison of the values of a and b. The element -type must model LessThanComparable for this +type must model LessThanComparable for this expression to be valid. @@ -583,8 +583,8 @@ expression to be valid. bool This performs a lexicographical comparison of the values of a and b. The element -type must model EqualityComparable and -LessThanComparable for this +type must model EqualityComparable and +LessThanComparable for this expression to be valid. @@ -592,8 +592,8 @@ expression to be valid. bool This performs a lexicographical comparison of the values of a and b. The element -type must model EqualityComparable and -LessThanComparable for this +type must model EqualityComparable and +LessThanComparable for this expression to be valid. @@ -601,7 +601,7 @@ expression to be valid. bool This performs a lexicographical comparison of the values of a and b. The element -type must model LessThanComparable for this +type must model LessThanComparable for this expression to be valid. diff --git a/doc/xml/const_multi_array_ref.xml b/doc/xml/const_multi_array_ref.xml index edf43bf..d052416 100644 --- a/doc/xml/const_multi_array_ref.xml +++ b/doc/xml/const_multi_array_ref.xml @@ -17,7 +17,7 @@ of the constructors. MultiArray, CopyConstructible. and depending on the element type, it may also model -EqualityComparable and LessThanComparable. +EqualityComparable and LessThanComparable. Detailed descriptions are provided here only for operations that are not described in the multi_array reference. diff --git a/doc/xml/multi_array.xml b/doc/xml/multi_array.xml index 01e2d8d..c2cb69c 100644 --- a/doc/xml/multi_array.xml +++ b/doc/xml/multi_array.xml @@ -18,7 +18,7 @@ using a replaceable allocator. MultiArray, CopyConstructible. Depending on the element type, -it may also model EqualityComparable and LessThanComparable. +it may also model EqualityComparable and LessThanComparable. diff --git a/doc/xml/multi_array_ref.xml b/doc/xml/multi_array_ref.xml index 3e21b54..50bcc03 100644 --- a/doc/xml/multi_array_ref.xml +++ b/doc/xml/multi_array_ref.xml @@ -17,7 +17,7 @@ of the constructors. MultiArray, CopyConstructible. and depending on the element type, it may also model -EqualityComparable and LessThanComparable. +EqualityComparable and LessThanComparable. Detailed descriptions are provided here only for operations that are not described in the multi_array reference. From 9642ba7103eef6fe9f01386ed769ffeecb3d2b8e Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Tue, 19 Feb 2019 00:54:36 -0500 Subject: [PATCH 5/6] Add test cases for allocators --- doc/test_cases.html | 7 ++ test/Jamfile.v2 | 1 + test/allocators.cpp | 151 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 test/allocators.cpp diff --git a/doc/test_cases.html b/doc/test_cases.html index f0ad9d3..f0a1226 100644 --- a/doc/test_cases.html +++ b/doc/test_cases.html @@ -179,6 +179,13 @@ by library users. + +libs/multi_array/test/allocators.cpp + +Test support for custom allocators. + + + libs/multi_array/test/generative_tests.hpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1c90413..ef1260e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -46,5 +46,6 @@ run stl_interaction.cpp ; run resize.cpp ; run assert.cpp ; run reverse_view.cpp ; +run allocators.cpp ; compile concept_checks.cpp ; diff --git a/test/allocators.cpp b/test/allocators.cpp new file mode 100644 index 0000000..8bb099f --- /dev/null +++ b/test/allocators.cpp @@ -0,0 +1,151 @@ +// Copyright 2019 Glen Joseph Fernandes +// (glenjofe@gmail.com) +// +// Distributed under 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) + +#include +#include +#include + +template +class creator { +public: + typedef T value_type; + typedef T* pointer; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + template + struct rebind { + typedef creator other; + }; + + creator(int state) + : state_(state) { } + + template + creator(const creator& other) + : state_(other.state()) { } + + T* allocate(std::size_t size) { + return static_cast(::operator new(sizeof(T) * size)); + } + + void deallocate(T* ptr, std::size_t) { + ::operator delete(ptr); + } + + int state() const { + return state_; + } + +private: + int state_; +}; + +template +inline bool +operator==(const creator& a, const creator& b) +{ + return a.state() == b.state(); +} + +template +inline bool +operator!=(const creator& a, const creator& b) +{ + return !(a == b); +} + +void test(const double&, std::size_t*, int*, unsigned) +{ +} + +template +void test(const Array& array, std::size_t* sizes, int* strides, + unsigned elements) +{ + BOOST_TEST(array.num_elements() == elements); + BOOST_TEST(array.size() == *sizes); + BOOST_TEST(std::equal(sizes, sizes + array.num_dimensions(), array.shape())); + BOOST_TEST(std::equal(strides, strides + array.num_dimensions(), + array.strides())); + test(array[0], ++sizes, ++strides, elements / array.size()); +} + +bool test(const double& a, const double& b) +{ + return a == b; +} + +template +bool test(const A1& a1, const A2& a2) +{ + typename A1::const_iterator i1 = a1.begin(); + typename A2::const_iterator i2 = a2.begin(); + for (; i1 != a1.end(); ++i1, ++i2) { + if (!test(*i1, *i2)) { + return false; + } + } + return true; +} + +int main() +{ + typedef boost::multi_array > type; + creator state(1); + { + type array(state); + } + boost::array sizes = { { 3, 3, 3 } }; + type::size_type elements = 27; + { + int strides[] = { 9, 3, 1 }; + type array(sizes, state); + test(array, &sizes[0], strides, elements); + } + { + int strides[] = { 1, 3, 9 }; + type array(sizes, boost::fortran_storage_order(), state); + test(array, &sizes[0], strides, elements); + } + { + int strides[] = { 9, 3, 1 }; + type::extent_gen extents; + type array(extents[3][3][3], state); + test(array, &sizes[0], strides, elements); + } + { + type array1(sizes, state); + std::vector values(elements, 4.5); + array1.assign(values.begin(), values.end()); + type array2(array1); + int strides[] = { 9, 3, 1 }; + test(array2, &sizes[0], strides, elements); + BOOST_TEST(test(array1, array2)); + } + { + type array1(sizes, state); + type array2(sizes, state); + std::vector values(elements, 4.5); + array1.assign(values.begin(), values.end()); + array2 = array1; + int strides[] = { 9, 3, 1 }; + test(array2, &sizes[0], strides, elements); + BOOST_TEST(test(array1, array2)); + } + { + type array1(sizes, state); + std::vector values(elements, 4.5); + array1.assign(values.begin(), values.end()); + typedef type::subarray<2>::type other; + other array2 = array1[1]; + other::value_type value = array2[0]; + BOOST_TEST(test(array1[1][0], value)); + BOOST_TEST(test(array2[0], value)); + } + return boost::report_errors(); +} From 72763d70be3f16b4f3626cbe3ae0521ccdd5e587 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Sun, 24 Feb 2019 23:09:05 -0500 Subject: [PATCH 6/6] Fix contribution from CromwellEnage to actually compile --- include/boost/multi_array/index_range.hpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/boost/multi_array/index_range.hpp b/include/boost/multi_array/index_range.hpp index b0896a0..6230138 100644 --- a/include/boost/multi_array/index_range.hpp +++ b/include/boost/multi_array/index_range.hpp @@ -109,11 +109,8 @@ namespace multi_array { size_type size(index idx) const { - return ( - (this->start_ == this_type::from_start()) || ( - this->finish_ == this_type::to_end() - ) - ) ? idx : ((this->finish_ - this->start_) / this->stride_); + return (start_ == from_start() || finish_ == to_end()) + ? idx : ((finish_ - start_) / stride_); } void set_index_range(index start, index finish, index stride=1)