From e14ba1c3e22efb400c3e11b3efd8edf5ba100ee7 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Fri, 17 Nov 2023 15:29:11 -0500 Subject: [PATCH 1/3] print/log feature summary only if not a subproject --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0b5aac514..0c1efb0292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -479,8 +479,11 @@ ADD_CUSTOM_TARGET(release COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) -feature_summary(WHAT ALL - DESCRIPTION "=== TiledArray Package/Feature Info ===") +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + feature_summary(WHAT ALL + DESCRIPTION "=== TiledArray Package/Feature Info ===") + feature_summary(FILENAME ${CMAKE_CURRENT_BINARY_DIR}/features.log WHAT ALL) +endif() option(TA_PYTHON "Build TA python module" OFF) if (TA_PYTHON) From 24e07eb6592d4c8ed4b0ed8753e19d7c95f689bc Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Sat, 18 Nov 2023 08:47:40 -0500 Subject: [PATCH 2/3] [unit] introduced `BOOST_{WARN,CHECK,REQUIRE}_TA_ASSERT` macros to use in place of `BOOST_{WARN,CHECK,REQUIRE}_THROW` --- tests/unit_test_config.h.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unit_test_config.h.in b/tests/unit_test_config.h.in index bd23b8414b..59e485634f 100644 --- a/tests/unit_test_config.h.in +++ b/tests/unit_test_config.h.in @@ -61,4 +61,24 @@ #define TA_UT_LABEL_DISTRIBUTED *boost::unit_test::label("distributed") #define TA_UT_LABEL_SERIAL *boost::unit_test::label("serial") +#if (TA_ASSERT_POLICY == TA_ASSERT_THROW) + +#define BOOST_WARN_TA_ASSERT( S, E ) \ + BOOST_WARN_THROW( S, E ) +#define BOOST_CHECK_TA_ASSERT( S, E ) \ + BOOST_CHECK_THROW( S, E ) +#define BOOST_REQUIRE_TA_ASSERT( S, E ) \ + BOOST_REQUIRE_THROW( S, E ) + +#else + +#define BOOST_WARN_TA_ASSERT( S, E ) \ + BOOST_WARN_MESSAGE( false, "Skipped BOOST_WARN_TA_ASSERT(" BOOST_STRINGIZE(S) "," BOOST_STRINGIZE(E) ") due to TA_ASSERT_POLICY != TA_ASSERT_THROW" ) +#define BOOST_CHECK_TA_ASSERT( S, E ) \ + BOOST_WARN_MESSAGE( false, "Skipped BOOST_CHECK_THROW(" BOOST_STRINGIZE(S) "," BOOST_STRINGIZE(E) ") due to TA_ASSERT_POLICY != TA_ASSERT_THROW" ) +#define BOOST_REQUIRE_TA_ASSERT( S, E ) \ + BOOST_WARN_MESSAGE( false, "Skipped BOOST_REQUIRE_THROW(" BOOST_STRINGIZE(S) "," BOOST_STRINGIZE(E) ") due to TA_ASSERT_POLICY != TA_ASSERT_THROW" ) + +#endif + #endif // TILEDARRAY_CONFIG_H__INCLUDED From 1ba4fbbda0db19613e96aa65fafbf23eadd51012 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Sat, 18 Nov 2023 09:25:19 -0500 Subject: [PATCH 3/3] [unit] convert all uses of `BOOST_{WARN,CHECK,REQUIRE}_THROW` to `BOOST_{WARN,CHECK,REQUIRE}_TA_ASSERT` so that unit tests can be built/run regardless of how `introduced `BOOST_{WARN,CHECK,REQUIRE}_TA_ASSERT` macros to use in place of ` is set --- CMakeLists.txt | 16 ++++---- tests/annotation.cpp | 2 +- tests/bipartite_index_list.cpp | 22 +++++------ tests/bitset.cpp | 4 +- tests/conversions.cpp | 12 +++--- tests/cyclic_pmap.cpp | 42 ++++++++++----------- tests/dist_op_group.cpp | 14 +++---- tests/distributed_storage.cpp | 6 +-- tests/index_list.cpp | 18 ++++----- tests/initializer_list.cpp | 2 +- tests/perm_index.cpp | 5 +-- tests/range.cpp | 4 +- tests/sparse_shape.cpp | 62 +++++++++++++++---------------- tests/ta_test.cpp | 3 -- tests/tile_op_contract_reduce.cpp | 2 +- tests/tiled_range1.cpp | 18 ++++----- tests/tot_dist_array_part1.cpp | 12 +++--- tests/tot_dist_array_part2.cpp | 58 ++++++++++++++--------------- 18 files changed, 150 insertions(+), 152 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c1efb0292..9a47fbd989 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,7 @@ include(LoadFetchContent) include(CMakeDependentOption) include(CMakePackageConfigHelpers) include(FeatureSummary) +include(CTest) # testing, defined BUILD_TESTING set(MPI_CXX_SKIP_MPICXX TRUE CACHE BOOL "MPI_CXX_SKIP_MPICXX") @@ -284,13 +285,6 @@ set_property( CACHE TA_ASSERT_POLICY PROPERTY STRINGS TA_ASSERT_THROW TA_ASSERT_ABORT TA_ASSERT_IGNORE) -# if building unit tests default to throw to be able to test TA_ASSERT statements -if (NOT (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW)) - if (BUILD_TESTING) - message(FATAL_ERROR "TA_ASSERT_POLICY=${TA_ASSERT_POLICY} requires BUILD_TESTING=OFF") - endif(BUILD_TESTING) -endif() - ########################## # Include source dirctories ########################## @@ -368,7 +362,7 @@ add_subdirectory(doc) ########################## # checking/testing ########################## -include(CTest) +# N.B. CTest was included above if (BUILD_TESTING) set(_ctest_args -V -R "tiledarray/unit/run-np.*") set(_ctest_args_serial -V -R "tiledarray/unit/run-np-1") @@ -376,6 +370,12 @@ if (BUILD_TESTING) list(APPEND _ctest_args --timeout ${TA_UT_CTEST_TIMEOUT}) list(APPEND _ctest_args_serial --timeout ${TA_UT_CTEST_TIMEOUT}) endif(DEFINED TA_UT_CTEST_TIMEOUT) + + # if building unit tests need to configure with TA_ASSERT_POLICY=TA_ASSERT_THROW to be able to test TA_ASSERT statements + if (NOT (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW)) + message(WARNING "BUILD_TESTING=ON requires configuring with TA_ASSERT_POLICY=TA_ASSERT_THROW to engage REQUIRE_THROWS() tests; will skip these tests") + endif() + add_custom_target_subproject(tiledarray check USES_TERMINAL COMMAND ${CMAKE_CTEST_COMMAND} ${_ctest_args}) add_custom_target_subproject(tiledarray check_serial USES_TERMINAL COMMAND ${CMAKE_CTEST_COMMAND} ${_ctest_args_serial}) add_subdirectory(tests) diff --git a/tests/annotation.cpp b/tests/annotation.cpp index f3494b5ac9..48acaa189c 100644 --- a/tests/annotation.cpp +++ b/tests/annotation.cpp @@ -201,7 +201,7 @@ BOOST_AUTO_TEST_SUITE(split_index_fxn) BOOST_AUTO_TEST_CASE(invalid_idx) { if (TiledArray::get_default_world().nproc() == 1) - BOOST_CHECK_THROW(split_index("i,"), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(split_index("i,"), TiledArray::Exception); } BOOST_AUTO_TEST_CASE(non_tot) { diff --git a/tests/bipartite_index_list.cpp b/tests/bipartite_index_list.cpp index 71025297af..364f894659 100644 --- a/tests/bipartite_index_list.cpp +++ b/tests/bipartite_index_list.cpp @@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(default_ctor) { */ BOOST_AUTO_TEST_CASE(string_ctor) { if (world.nproc() == 1) { - BOOST_CHECK_THROW(BipartiteIndexList("i,"), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(BipartiteIndexList("i,"), TiledArray::Exception); } for (auto&& [str, idx] : idxs) { @@ -192,7 +192,7 @@ BOOST_AUTO_TEST_CASE(copy_assignment) { BOOST_AUTO_TEST_CASE(string_assignment) { if (world.nproc() == 1) { BipartiteIndexList v1; - BOOST_CHECK_THROW(v1.operator=("i,"), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(v1.operator=("i,"), TiledArray::Exception); } for (auto&& [str, idx] : idxs) { @@ -282,7 +282,7 @@ BOOST_AUTO_TEST_CASE(permute_in_place) { if (world.nproc() == 1) { BipartiteIndexList v0; Permutation p{0, 1}; - BOOST_CHECK_THROW(v0 *= p, TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(v0 *= p, TiledArray::Exception); } Permutation p({1, 2, 3, 0}); @@ -335,13 +335,13 @@ BOOST_AUTO_TEST_CASE(end_itr) { BOOST_AUTO_TEST_CASE(at_member) { for (auto&& [str, idx] : idxs) { if (world.nproc() == 1) { - BOOST_CHECK_THROW(idx.at(idx.size()), + BOOST_CHECK_TA_ASSERT(idx.at(idx.size()), #ifdef BOOST_CONTAINER_USE_STD_EXCEPTIONS - std::out_of_range + std::out_of_range #else - boost::container::out_of_range + boost::container::out_of_range #endif - ); + ); } auto [outer, inner] = detail::split_index(str); for (size_type i = 0; i < outer.size(); ++i) @@ -498,23 +498,23 @@ BOOST_AUTO_TEST_CASE(permutation_fxn) { { // not both ToT BipartiteIndexList v1("i;j"); - BOOST_CHECK_THROW(v1.permutation(v0), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(v1.permutation(v0), TiledArray::Exception); } { // wrong size BipartiteIndexList v1("i"); - BOOST_CHECK_THROW(v1.permutation(v0), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(v1.permutation(v0), TiledArray::Exception); } { // not a permutation BipartiteIndexList v1("i, a"); - BOOST_CHECK_THROW(v1.permutation(v0), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(v1.permutation(v0), TiledArray::Exception); } { // ToTs mix outer and inner BipartiteIndexList v1("i,j;k,l"); BipartiteIndexList v2("i,k;j,l"); - BOOST_CHECK_THROW(v1.permutation(v2), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(v1.permutation(v2), TiledArray::Exception); } } diff --git a/tests/bitset.cpp b/tests/bitset.cpp index 289a47c295..0ffcf56114 100644 --- a/tests/bitset.cpp +++ b/tests/bitset.cpp @@ -102,8 +102,8 @@ BOOST_AUTO_TEST_CASE(accessor) { // Check that exceptions are thrown when accessing an element that is out of // range. - BOOST_CHECK_THROW(set[set.size()], Exception); - BOOST_CHECK_THROW(set[set.size() + 1], Exception); + BOOST_CHECK_TA_ASSERT(set[set.size()], Exception); + BOOST_CHECK_TA_ASSERT(set[set.size() + 1], Exception); } BOOST_AUTO_TEST_CASE(set_bit) { diff --git a/tests/conversions.cpp b/tests/conversions.cpp index e9ae430bbb..107a383c00 100644 --- a/tests/conversions.cpp +++ b/tests/conversions.cpp @@ -530,12 +530,12 @@ BOOST_AUTO_TEST_CASE(concat) { } } // ranges of non-concatted dims must match - BOOST_CHECK_THROW((TiledArray::concat( - {a, b_t}, std::vector{false, true})), - TiledArray::Exception); - BOOST_CHECK_THROW((TiledArray::concat( - {a, b_t}, std::vector{true, false})), - TiledArray::Exception); + BOOST_CHECK_TA_ASSERT((TiledArray::concat( + {a, b_t}, std::vector{false, true})), + TiledArray::Exception); + BOOST_CHECK_TA_ASSERT((TiledArray::concat( + {a, b_t}, std::vector{true, false})), + TiledArray::Exception); }; do_test(static_cast(nullptr)); diff --git a/tests/cyclic_pmap.cpp b/tests/cyclic_pmap.cpp index 509b9f92bf..4d8d76da1f 100644 --- a/tests/cyclic_pmap.cpp +++ b/tests/cyclic_pmap.cpp @@ -60,28 +60,28 @@ BOOST_AUTO_TEST_CASE(constructor) { ProcessID size = GlobalFixture::world->size(); - BOOST_CHECK_THROW(TiledArray::detail::CyclicPmap pmap(*GlobalFixture::world, - 0ul, 10ul, 1, 1), - TiledArray::Exception); - BOOST_CHECK_THROW(TiledArray::detail::CyclicPmap pmap(*GlobalFixture::world, - 10ul, 0ul, 1, 1), - TiledArray::Exception); - BOOST_CHECK_THROW(TiledArray::detail::CyclicPmap pmap(*GlobalFixture::world, - 10ul, 10ul, 0, 1), - TiledArray::Exception); - BOOST_CHECK_THROW(TiledArray::detail::CyclicPmap pmap(*GlobalFixture::world, - 10ul, 10ul, 1, 0), - TiledArray::Exception); - BOOST_CHECK_THROW(TiledArray::detail::CyclicPmap pmap( - *GlobalFixture::world, 10ul, 10ul, size * 2, 1), - TiledArray::Exception); - BOOST_CHECK_THROW(TiledArray::detail::CyclicPmap pmap( - *GlobalFixture::world, 10ul, 10ul, 1, size * 2), - TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(TiledArray::detail::CyclicPmap pmap( + *GlobalFixture::world, 0ul, 10ul, 1, 1), + TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(TiledArray::detail::CyclicPmap pmap( + *GlobalFixture::world, 10ul, 0ul, 1, 1), + TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(TiledArray::detail::CyclicPmap pmap( + *GlobalFixture::world, 10ul, 10ul, 0, 1), + TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(TiledArray::detail::CyclicPmap pmap( + *GlobalFixture::world, 10ul, 10ul, 1, 0), + TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(TiledArray::detail::CyclicPmap pmap( + *GlobalFixture::world, 10ul, 10ul, size * 2, 1), + TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(TiledArray::detail::CyclicPmap pmap( + *GlobalFixture::world, 10ul, 10ul, 1, size * 2), + TiledArray::Exception); if (size > 1) { - BOOST_CHECK_THROW(TiledArray::detail::CyclicPmap pmap( - *GlobalFixture::world, 10ul, 10ul, size, size), - TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(TiledArray::detail::CyclicPmap pmap( + *GlobalFixture::world, 10ul, 10ul, size, size), + TiledArray::Exception); } } diff --git a/tests/dist_op_group.cpp b/tests/dist_op_group.cpp index 8027eab7e1..b4846716f4 100644 --- a/tests/dist_op_group.cpp +++ b/tests/dist_op_group.cpp @@ -56,14 +56,14 @@ BOOST_AUTO_TEST_CASE(constructor_empty) { #if defined(MADNESS_ASSERTIONS_THROW) // Check that accessing group data throws exceptions for an empty group. - BOOST_CHECK_THROW(empty_group.id(), madness::MadnessException); - BOOST_CHECK_THROW(empty_group.get_world(), madness::MadnessException); - BOOST_CHECK_THROW(empty_group.rank(), madness::MadnessException); - BOOST_CHECK_THROW(empty_group.rank(0), madness::MadnessException); - BOOST_CHECK_THROW(empty_group.world_rank(0), madness::MadnessException); + BOOST_CHECK_TA_ASSERT(empty_group.id(), madness::MadnessException); + BOOST_CHECK_TA_ASSERT(empty_group.get_world(), madness::MadnessException); + BOOST_CHECK_TA_ASSERT(empty_group.rank(), madness::MadnessException); + BOOST_CHECK_TA_ASSERT(empty_group.rank(0), madness::MadnessException); + BOOST_CHECK_TA_ASSERT(empty_group.world_rank(0), madness::MadnessException); ProcessID parent, child1, child2; - BOOST_CHECK_THROW(empty_group.make_tree(0, parent, child1, child2), - madness::MadnessException); + BOOST_CHECK_TA_ASSERT(empty_group.make_tree(0, parent, child1, child2), + madness::MadnessException); #endif // MADNESS_ASSERTIONS_THROW } diff --git a/tests/distributed_storage.cpp b/tests/distributed_storage.cpp index 9dec84f967..895b734911 100644 --- a/tests/distributed_storage.cpp +++ b/tests/distributed_storage.cpp @@ -79,8 +79,8 @@ BOOST_AUTO_TEST_CASE(set_value) { BOOST_CHECK_EQUAL(n, t.max_size()); // Check throw for an out-of-range set. - BOOST_CHECK_THROW(t.set(t.max_size(), 1), TiledArray::Exception); - BOOST_CHECK_THROW(t.set(t.max_size() + 2, 1), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.set(t.max_size(), 1), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.set(t.max_size() + 2, 1), TiledArray::Exception); } BOOST_AUTO_TEST_CASE(array_operator) { @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(array_operator) { BOOST_CHECK_EQUAL(n, t.max_size()); // Check throw for an out-of-range set. - BOOST_CHECK_THROW(t.get(t.max_size()), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.get(t.max_size()), TiledArray::Exception); BOOST_CHECK_THROW(t.get(t.max_size() + 2), TiledArray::Exception); } diff --git a/tests/index_list.cpp b/tests/index_list.cpp index bf75aaffac..c53bdd9de7 100644 --- a/tests/index_list.cpp +++ b/tests/index_list.cpp @@ -135,11 +135,11 @@ BOOST_AUTO_TEST_CASE(accessors) { BOOST_CHECK_EQUAL(v.at(3), "d"); // check last variable access BOOST_CHECK_EQUAL(v[0], "a"); // check 1st variable access BOOST_CHECK_EQUAL(v[3], "d"); // check last variable access - BOOST_CHECK_THROW(v.at(4), + BOOST_CHECK_TA_ASSERT(v.at(4), #ifdef BOOST_CONTAINER_USE_STD_EXCEPTIONS - std::out_of_range + std::out_of_range #else - boost::container::out_of_range + boost::container::out_of_range #endif ); // check for out of range throw. } @@ -175,11 +175,11 @@ BOOST_AUTO_TEST_CASE(constructor) { BOOST_CHECK_EQUAL(v10.at(2), "c"); BOOST_CHECK_EQUAL(v10.at(3), "d"); - BOOST_CHECK_THROW(IndexList v3(",a,b,c"), - Exception); // check invalid input - BOOST_CHECK_THROW(IndexList v4("a,,b,c"), Exception); - BOOST_CHECK_THROW(IndexList v5(" ,a,b"), Exception); - BOOST_CHECK_THROW(IndexList v6("a, b, , c"), Exception); + BOOST_CHECK_TA_ASSERT(IndexList v3(",a,b,c"), + Exception); // check invalid input + BOOST_CHECK_TA_ASSERT(IndexList v4("a,,b,c"), Exception); + BOOST_CHECK_TA_ASSERT(IndexList v5(" ,a,b"), Exception); + BOOST_CHECK_TA_ASSERT(IndexList v6("a, b, , c"), Exception); IndexList v7(" a , b, c, d , e e ,f f, g10,h, i "); // check input with // various spacings. @@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(constructor) { BOOST_CHECK_EQUAL(v7.at(7), "h"); BOOST_CHECK_EQUAL(v7.at(8), "i"); - BOOST_REQUIRE_THROW( + BOOST_REQUIRE_TA_ASSERT( IndexList v11(""), TiledArray::Exception); // Empty string is not permitted constructor } diff --git a/tests/initializer_list.cpp b/tests/initializer_list.cpp index 884f5c61fd..4d051f957d 100644 --- a/tests/initializer_list.cpp +++ b/tests/initializer_list.cpp @@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE(scalar) { BOOST_AUTO_TEST_CASE(empty_vector) { vector_il il{}; if (world.rank() == 0) // only rank 0 does the work - BOOST_CHECK_THROW(tiled_range_from_il(il), Exception); + BOOST_CHECK_TA_ASSERT(tiled_range_from_il(il), Exception); } BOOST_AUTO_TEST_CASE(vector) { diff --git a/tests/perm_index.cpp b/tests/perm_index.cpp index 3ba48aa7a1..8a1326d7df 100644 --- a/tests/perm_index.cpp +++ b/tests/perm_index.cpp @@ -49,8 +49,7 @@ const std::array PermIndexFixture::start = { const std::array PermIndexFixture::finish = { {3ul, 5ul, 7ul, 11ul}}; -BOOST_FIXTURE_TEST_SUITE(perm_index_suite, PermIndexFixture, - TA_UT_LABEL_SERIAL) +BOOST_FIXTURE_TEST_SUITE(perm_index_suite, PermIndexFixture, TA_UT_LABEL_SERIAL) BOOST_AUTO_TEST_CASE(default_constructor) { BOOST_CHECK_NO_THROW(PermIndex x;); @@ -61,7 +60,7 @@ BOOST_AUTO_TEST_CASE(default_constructor) { BOOST_CHECK(!x.data()); // Check that an exception is thrown when using a default constructed object - BOOST_CHECK_THROW(x(0), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(x(0), TiledArray::Exception); } BOOST_AUTO_TEST_CASE(constructor) { diff --git a/tests/range.cpp b/tests/range.cpp index a71a0629d0..a5ac8898f9 100644 --- a/tests/range.cpp +++ b/tests/range.cpp @@ -344,8 +344,8 @@ BOOST_AUTO_TEST_CASE(constructors) { BOOST_CHECK_EQUAL(r2.volume(), 48); } #else // TA_SIGNED_1INDEX_TYPE - BOOST_REQUIRE_THROW(Range r2({{-1, 1}, {-2, 2}, {0, 6}}), - TiledArray::Exception); + BOOST_REQUIRE_TA_ASSERT(Range r2({{-1, 1}, {-2, 2}, {0, 6}}), + TiledArray::Exception); #endif // TA_SIGNED_1INDEX_TYPE // Copy Constructor diff --git a/tests/sparse_shape.cpp b/tests/sparse_shape.cpp index 77ada97028..0112f0dac6 100644 --- a/tests/sparse_shape.cpp +++ b/tests/sparse_shape.cpp @@ -49,36 +49,36 @@ BOOST_AUTO_TEST_CASE(default_constructor) { BOOST_CHECK(!x.validate(tr.tiles_range())); BOOST_CHECK_EQUAL(x.init_threshold(), SparseShape::threshold()); - BOOST_CHECK_THROW(x.nnz(), Exception); + BOOST_CHECK_TA_ASSERT(x.nnz(), Exception); - BOOST_CHECK_THROW(x[0], Exception); + BOOST_CHECK_TA_ASSERT(x[0], Exception); - BOOST_CHECK_THROW(x.perm(perm), Exception); + BOOST_CHECK_TA_ASSERT(x.perm(perm), Exception); - BOOST_CHECK_THROW(x.scale(2.0), Exception); - BOOST_CHECK_THROW(x.scale(2.0, perm), Exception); + BOOST_CHECK_TA_ASSERT(x.scale(2.0), Exception); + BOOST_CHECK_TA_ASSERT(x.scale(2.0, perm), Exception); - BOOST_CHECK_THROW(x.add(y), Exception); - BOOST_CHECK_THROW(x.add(y, 2.0), Exception); - BOOST_CHECK_THROW(x.add(y, perm), Exception); - BOOST_CHECK_THROW(x.add(y, 2.0, perm), Exception); - BOOST_CHECK_THROW(x.add(2.0), Exception); - BOOST_CHECK_THROW(x.add(2.0, perm), Exception); + BOOST_CHECK_TA_ASSERT(x.add(y), Exception); + BOOST_CHECK_TA_ASSERT(x.add(y, 2.0), Exception); + BOOST_CHECK_TA_ASSERT(x.add(y, perm), Exception); + BOOST_CHECK_TA_ASSERT(x.add(y, 2.0, perm), Exception); + BOOST_CHECK_TA_ASSERT(x.add(2.0), Exception); + BOOST_CHECK_TA_ASSERT(x.add(2.0, perm), Exception); - BOOST_CHECK_THROW(x.subt(y), Exception); - BOOST_CHECK_THROW(x.subt(y, 2.0), Exception); - BOOST_CHECK_THROW(x.subt(y, perm), Exception); - BOOST_CHECK_THROW(x.subt(y, 2.0, perm), Exception); - BOOST_CHECK_THROW(x.subt(2.0), Exception); - BOOST_CHECK_THROW(x.subt(2.0, perm), Exception); + BOOST_CHECK_TA_ASSERT(x.subt(y), Exception); + BOOST_CHECK_TA_ASSERT(x.subt(y, 2.0), Exception); + BOOST_CHECK_TA_ASSERT(x.subt(y, perm), Exception); + BOOST_CHECK_TA_ASSERT(x.subt(y, 2.0, perm), Exception); + BOOST_CHECK_TA_ASSERT(x.subt(2.0), Exception); + BOOST_CHECK_TA_ASSERT(x.subt(2.0, perm), Exception); - BOOST_CHECK_THROW(x.mult(y), Exception); - BOOST_CHECK_THROW(x.mult(y, 2.0), Exception); - BOOST_CHECK_THROW(x.mult(y, perm), Exception); - BOOST_CHECK_THROW(x.mult(y, 2.0, perm), Exception); + BOOST_CHECK_TA_ASSERT(x.mult(y), Exception); + BOOST_CHECK_TA_ASSERT(x.mult(y, 2.0), Exception); + BOOST_CHECK_TA_ASSERT(x.mult(y, perm), Exception); + BOOST_CHECK_TA_ASSERT(x.mult(y, 2.0, perm), Exception); - BOOST_CHECK_THROW(x.gemm(y, 2.0, gemm_helper), Exception); - BOOST_CHECK_THROW(x.gemm(y, 2.0, gemm_helper, perm), Exception); + BOOST_CHECK_TA_ASSERT(x.gemm(y, 2.0, gemm_helper), Exception); + BOOST_CHECK_TA_ASSERT(x.gemm(y, 2.0, gemm_helper, perm), Exception); } BOOST_AUTO_TEST_CASE(non_comm_constructor) { @@ -350,8 +350,8 @@ BOOST_AUTO_TEST_CASE(block) { #endif } else { // Check that block throws an exception with a bad block range - BOOST_CHECK_THROW(sparse_shape.block(lower, upper), - TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(sparse_shape.block(lower, upper), + TiledArray::Exception); } } } @@ -447,8 +447,8 @@ BOOST_AUTO_TEST_CASE(block_scale) { } else { // Check that block throws an exception with a bad block range - BOOST_CHECK_THROW(sparse_shape.block(lower, upper), - TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(sparse_shape.block(lower, upper), + TiledArray::Exception); } } } @@ -546,8 +546,8 @@ BOOST_AUTO_TEST_CASE(block_perm) { } else { // Check that block throws an exception with a bad block range - BOOST_CHECK_THROW(sparse_shape.block(lower, upper), - TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(sparse_shape.block(lower, upper), + TiledArray::Exception); } } } @@ -649,8 +649,8 @@ BOOST_AUTO_TEST_CASE(block_scale_perm) { } else { // Check that block throws an exception with a bad block range - BOOST_CHECK_THROW(sparse_shape.block(lower, upper), - TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(sparse_shape.block(lower, upper), + TiledArray::Exception); } } } diff --git a/tests/ta_test.cpp b/tests/ta_test.cpp index 8d81e66849..7e5f2184bf 100644 --- a/tests/ta_test.cpp +++ b/tests/ta_test.cpp @@ -28,9 +28,6 @@ #endif #include -#if (TA_ASSERT_POLICY != TA_ASSERT_THROW) -#error "TiledArray unit tests require TA_ASSERT_POLICY=TA_ASSERT_THROW" -#endif GlobalFixture::GlobalFixture() { if (world == nullptr) { diff --git a/tests/tile_op_contract_reduce.cpp b/tests/tile_op_contract_reduce.cpp index 5c30a5b491..b50397097d 100644 --- a/tests/tile_op_contract_reduce.cpp +++ b/tests/tile_op_contract_reduce.cpp @@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE(permute_empty) { TiledArray::math::blas::Op::NoTrans, TiledArray::math::blas::Op::NoTrans, 1, 2u, 2u, 2u); TensorI t, result; - BOOST_REQUIRE_THROW(result = op(t), TiledArray::Exception); + BOOST_REQUIRE_TA_ASSERT(result = op(t), TiledArray::Exception); } // TODO: Test non-empty permutation diff --git a/tests/tiled_range1.cpp b/tests/tiled_range1.cpp index d7379e2fbb..043e4b96ac 100644 --- a/tests/tiled_range1.cpp +++ b/tests/tiled_range1.cpp @@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE(constructor) { BOOST_CHECK_EQUAL(r.tiles_range().second, 0ul); BOOST_CHECK_EQUAL(r.elements_range().first, 0ul); BOOST_CHECK_EQUAL(r.elements_range().second, 0ul); - BOOST_CHECK_THROW(r.tile(0), Exception); + BOOST_CHECK_TA_ASSERT(r.tile(0), Exception); } // check construction with a iterators and the range info. @@ -120,8 +120,8 @@ BOOST_AUTO_TEST_CASE(constructor) { BOOST_CHECK_EQUAL(r.elements_range().second, 28); } #else // TA_SIGNED_1INDEX_TYPE - BOOST_CHECK_THROW(TiledRange1 r({-1, 0, 2, 5, 10, 17, 28}), - TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(TiledRange1 r({-1, 0, 2, 5, 10, 17, 28}), + TiledArray::Exception); #endif // TA_SIGNED_1INDEX_TYPE // check copy constructor @@ -156,14 +156,14 @@ BOOST_AUTO_TEST_CASE(constructor) { #ifndef NDEBUG { std::vector boundaries; - BOOST_CHECK_THROW(TiledRange1 r(boundaries.begin(), boundaries.end()), - Exception); - BOOST_CHECK_THROW(TiledRange1 r(a.begin(), a.begin()), Exception); - BOOST_CHECK_THROW(TiledRange1 r(a.begin(), a.begin() + 1), Exception); + BOOST_CHECK_TA_ASSERT(TiledRange1 r(boundaries.begin(), boundaries.end()), + Exception); + BOOST_CHECK_TA_ASSERT(TiledRange1 r(a.begin(), a.begin()), Exception); + BOOST_CHECK_TA_ASSERT(TiledRange1 r(a.begin(), a.begin() + 1), Exception); boundaries.push_back(2); boundaries.push_back(0); - BOOST_CHECK_THROW(TiledRange1 r(boundaries.begin(), boundaries.end()), - Exception); + BOOST_CHECK_TA_ASSERT(TiledRange1 r(boundaries.begin(), boundaries.end()), + Exception); } #endif } diff --git a/tests/tot_dist_array_part1.cpp b/tests/tot_dist_array_part1.cpp index e71392ef8c..d95bb050a2 100644 --- a/tests/tot_dist_array_part1.cpp +++ b/tests/tot_dist_array_part1.cpp @@ -331,7 +331,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(begin, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.begin(), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.begin(), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -344,7 +344,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(const_begin, TestParam, test_params) { { const tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.begin(), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.begin(), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -356,7 +356,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(const_begin, TestParam, test_params) { BOOST_AUTO_TEST_CASE_TEMPLATE(end, TestParam, test_params) { { tensor_type t; - if (m_world.nproc() == 1) BOOST_CHECK_THROW(t.end(), TiledArray::Exception); + if (m_world.nproc() == 1) + BOOST_CHECK_TA_ASSERT(t.end(), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -368,7 +369,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(end, TestParam, test_params) { BOOST_AUTO_TEST_CASE_TEMPLATE(const_end, TestParam, test_params) { { const tensor_type t; - if (m_world.nproc() == 1) BOOST_CHECK_THROW(t.end(), TiledArray::Exception); + if (m_world.nproc() == 1) + BOOST_CHECK_TA_ASSERT(t.end(), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -391,7 +393,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(find, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.find(0), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.find(0), TiledArray::Exception); } for (auto tr_t : run_all()) { diff --git a/tests/tot_dist_array_part2.cpp b/tests/tot_dist_array_part2.cpp index b916812884..ffd1883198 100644 --- a/tests/tot_dist_array_part2.cpp +++ b/tests/tot_dist_array_part2.cpp @@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(fill_local, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) { - BOOST_CHECK_THROW(t.fill_local(inner_type{}), except_t); + BOOST_CHECK_TA_ASSERT(t.fill_local(inner_type{}), except_t); } } @@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(fill_local, TestParam, test_params) { // Test that it throws if a tile is already set /*{ if(m_world.nproc() == 1) - BOOST_CHECK_THROW(already_set.fill_local(inner_type{}), except_t); + BOOST_CHECK_TA_ASSERT(already_set.fill_local(inner_type{}), except_t); }*/ // Test we can actually fill tiles @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(fill, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) { - BOOST_CHECK_THROW(t.fill(inner_type{}), except_t); + BOOST_CHECK_TA_ASSERT(t.fill(inner_type{}), except_t); } } @@ -106,7 +106,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(fill, TestParam, test_params) { // Test that it throws if a tile is already set /*{ if(m_world.nproc() == 1) - BOOST_CHECK_THROW(already_set.fill(inner_type{}), except_t); + BOOST_CHECK_TA_ASSERT(already_set.fill(inner_type{}), except_t); }*/ // Test we can actually fill tiles @@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(init_tiles, TestParam, test_params) { tensor_type t; if (m_world.nproc() == 1) { auto l = [](const Range&) { return tile_type{}; }; - BOOST_CHECK_THROW(t.init_tiles(l), except_t); + BOOST_CHECK_TA_ASSERT(t.init_tiles(l), except_t); } } @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(init_tiles, TestParam, test_params) { // Test that it throws if a tile is already set /*{ if(m_world.nproc() == 1) - BOOST_CHECK_THROW(corr.init_tiles(l), except_t); + BOOST_CHECK_TA_ASSERT(corr.init_tiles(l), except_t); }*/ // Test we can actually fill tiles @@ -200,7 +200,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(init_elements, TestParam, test_params) { tensor_type t; auto l = [](const index_type&) { return inner_type{}; }; if (m_world.nproc() == 1) { - BOOST_CHECK_THROW(t.init_elements(l), except_t); + BOOST_CHECK_TA_ASSERT(t.init_elements(l), except_t); } } @@ -226,7 +226,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(init_elements, TestParam, test_params) { // Test that it throws if a tile is already set /*{ if(m_world.nproc() == 1) - BOOST_CHECK_THROW(corr.init_elements(l), except_t); + BOOST_CHECK_TA_ASSERT(corr.init_elements(l), except_t); }*/ // Test we can actually fill tiles @@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(trange, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.trange(), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.trange(), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -259,7 +259,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(tiles_range, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.tiles_range(), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.tiles_range(), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(elements_range, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.elements_range(), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.elements_range(), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(size, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.size(), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.size(), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(world, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.world(), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.world(), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -317,7 +317,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(pmap, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.pmap(), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.pmap(), TiledArray::Exception); } } @@ -325,7 +325,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(shape, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.shape(), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.shape(), TiledArray::Exception); } using shape_type = typename tensor_type::shape_type; for (auto tr_t : run_all()) { @@ -351,9 +351,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(call_operator, TestParam, test_params) { if (m_world.nproc() == 1) { using except_t = TiledArray::Exception; // Throws if no semicolon - BOOST_CHECK_THROW(t(outer_idx), except_t); + BOOST_CHECK_TA_ASSERT(t(outer_idx), except_t); // Throws if wrong outer rank - BOOST_CHECK_THROW(t("i,j,k,l,m;" + inner_idx), except_t); + BOOST_CHECK_TA_ASSERT(t("i,j,k,l,m;" + inner_idx), except_t); } auto vars = outer_idx + ";" + inner_idx; @@ -374,9 +374,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(const_call_operator, TestParam, test_params) { if (m_world.nproc() == 1) { using except_t = TiledArray::Exception; // Throws if no semicolon - BOOST_CHECK_THROW(t(outer_idx), except_t); + BOOST_CHECK_TA_ASSERT(t(outer_idx), except_t); // Throws if wrong outer rank - BOOST_CHECK_THROW(t("i,j,k,l,m;" + inner_idx), except_t); + BOOST_CHECK_TA_ASSERT(t("i,j,k,l,m;" + inner_idx), except_t); } auto vars = outer_idx + ";" + inner_idx; @@ -399,7 +399,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(is_dense, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.is_dense(), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.is_dense(), TiledArray::Exception); } using shape_type = typename tensor_type::shape_type; @@ -415,7 +415,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(owner, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.owner(0), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.owner(0), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -426,11 +426,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(owner, TestParam, test_params) { const auto& upbound = tr.tiles_range().upbound(); // Test throws if index is out of bounds - BOOST_CHECK_THROW(corr.owner(upbound), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(corr.owner(upbound), TiledArray::Exception); // Throws if index has wrong rank std::vector bad_idx(upbound.size() + 1, 0); - BOOST_CHECK_THROW(corr.owner(bad_idx), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(corr.owner(bad_idx), TiledArray::Exception); } for (auto idx : corr.tiles_range()) { @@ -445,7 +445,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(owner_init_list, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.owner({0}), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.owner({0}), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -459,13 +459,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(owner_init_list, TestParam, test_params) { // Test throws if index is out of bounds if (rank == 1) - BOOST_CHECK_THROW(corr.owner({upbound[0]}), except_t); + BOOST_CHECK_TA_ASSERT(corr.owner({upbound[0]}), except_t); else if (rank == 2) - BOOST_CHECK_THROW(corr.owner({upbound[0], upbound[1]}), except_t); + BOOST_CHECK_TA_ASSERT(corr.owner({upbound[0], upbound[1]}), except_t); // Throws if index has wrong rank std::initializer_list il2{0, 0, 0, 0, 0, 0}; - BOOST_CHECK_THROW(corr.owner(il2), except_t); + BOOST_CHECK_TA_ASSERT(corr.owner(il2), except_t); } for (auto idx : corr.tiles_range()) { @@ -484,7 +484,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(is_local, TestParam, test_params) { { tensor_type t; if (m_world.nproc() == 1) - BOOST_CHECK_THROW(t.is_local(0), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(t.is_local(0), TiledArray::Exception); } for (auto tr_t : run_all()) { @@ -495,7 +495,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(is_local, TestParam, test_params) { const auto& upbound = tr.tiles_range().upbound(); // Test throws if index is out of bounds - BOOST_CHECK_THROW(corr.is_local(upbound), TiledArray::Exception); + BOOST_CHECK_TA_ASSERT(corr.is_local(upbound), TiledArray::Exception); // Throws if index has wrong rank std::vector bad_idx(upbound.size() + 1, 0);