From db13da3f805c0a50fddb292aa6724d141ceb61e6 Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Sat, 9 Apr 2016 21:18:28 +0200 Subject: [PATCH] Adapt tests and build system to new exception system interface --- src/linalgwrap/CMakeLists.txt | 1 + tests/ArmadilloMatrixTests.cc | 2 +- tests/ArmadilloVectorTests.cc | 2 +- tests/BlockDiagonalMatrixTests.cc | 2 +- tests/BlockViewTests.cc | 2 +- tests/ExceptionTests.cc | 7 +++---- tests/LazyMatrixProductTests.cc | 3 +-- tests/LazyMatrixSumTests.cc | 3 +-- tests/LazyMatrixWrapperTests.cc | 2 +- tests/LazyMatrix_i_Tests.cc | 3 +-- tests/ParameterMapTests.cc | 2 +- tests/RangeTests.cc | 2 +- tests/ScaleViewTests.cc | 2 +- tests/SubscriptionTests.cc | 4 +--- tests/TransposeViewTests.cc | 2 +- 15 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/linalgwrap/CMakeLists.txt b/src/linalgwrap/CMakeLists.txt index 4d81c4f..cf67e6c 100644 --- a/src/linalgwrap/CMakeLists.txt +++ b/src/linalgwrap/CMakeLists.txt @@ -25,6 +25,7 @@ set(LINALGWRAP_SOURCES ParameterMap.cc ExceptionBase.cc + ExceptionSystem.cc version.cc ) diff --git a/tests/ArmadilloMatrixTests.cc b/tests/ArmadilloMatrixTests.cc index 099fcf9..3ecce45 100644 --- a/tests/ArmadilloMatrixTests.cc +++ b/tests/ArmadilloMatrixTests.cc @@ -35,7 +35,7 @@ using namespace rc; #ifdef LINALGWRAP_HAVE_ARMADILLO TEST_CASE("ArmadilloMatrix class", "[ArmadilloMatrix]") { // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); // The type of matrix we wish to test. typedef ArmadilloMatrix matrix_type; diff --git a/tests/ArmadilloVectorTests.cc b/tests/ArmadilloVectorTests.cc index fac7107..f0c6858 100644 --- a/tests/ArmadilloVectorTests.cc +++ b/tests/ArmadilloVectorTests.cc @@ -29,7 +29,7 @@ using namespace rc; #ifdef LINALGWRAP_HAVE_ARMADILLO TEST_CASE("ArmadilloVector class", "[ArmadilloVector]") { // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); // The type of vector we wish to test. typedef ArmadilloVector vector_type; diff --git a/tests/BlockDiagonalMatrixTests.cc b/tests/BlockDiagonalMatrixTests.cc index 8cae43c..c97ab2b 100644 --- a/tests/BlockDiagonalMatrixTests.cc +++ b/tests/BlockDiagonalMatrixTests.cc @@ -29,7 +29,7 @@ using namespace rc; TEST_CASE("BlockDiagonalMatrix class", "[BlockDiagonalMatrix]") { // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); typedef double scalar_type; typedef SmallMatrix stored_matrix_type; diff --git a/tests/BlockViewTests.cc b/tests/BlockViewTests.cc index 75f563e..a4f4754 100644 --- a/tests/BlockViewTests.cc +++ b/tests/BlockViewTests.cc @@ -27,7 +27,7 @@ using namespace rc; TEST_CASE("BlockView", "[BlockView]") { // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); // Define the types we use for the test: struct TestTypes { diff --git a/tests/ExceptionTests.cc b/tests/ExceptionTests.cc index 476ad6b..1df336a 100644 --- a/tests/ExceptionTests.cc +++ b/tests/ExceptionTests.cc @@ -27,8 +27,7 @@ using namespace rc; TEST_CASE("Exception system", "[exception]") { // Make sure that the program does not get aborted - linalgwrap::exceptions::assert_dbg_effect = - linalgwrap::exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); SECTION("Test throw or raise mechanism") { #ifdef DEBUG @@ -46,10 +45,10 @@ TEST_CASE("Exception system", "[exception]") { // Test if an ExcNotImplemented exception would be thrown: REQUIRE_THROWS_AS(assert_throw(false, ExcNotImplemented()), - exceptions::ExcNotImplemented); + ExcNotImplemented); // Test if an ExcIO exception would be thrown: - REQUIRE_THROWS_AS(assert_throw(false, ExcIO()), exceptions::ExcIO); + REQUIRE_THROWS_AS(assert_throw(false, ExcIO()), ExcIO); } // diff --git a/tests/LazyMatrixProductTests.cc b/tests/LazyMatrixProductTests.cc index e5e52aa..4025baa 100644 --- a/tests/LazyMatrixProductTests.cc +++ b/tests/LazyMatrixProductTests.cc @@ -30,8 +30,7 @@ using namespace rc; TEST_CASE("LazyMatrixProduct", "[LazyMatrixProduct]") { // Make sure that the program does not get aborted - linalgwrap::exceptions::assert_dbg_effect = - linalgwrap::exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); // TODO Test swap function // TODO Test constructors diff --git a/tests/LazyMatrixSumTests.cc b/tests/LazyMatrixSumTests.cc index 77544f6..77d182c 100644 --- a/tests/LazyMatrixSumTests.cc +++ b/tests/LazyMatrixSumTests.cc @@ -28,8 +28,7 @@ using namespace rc; TEST_CASE("LazyMatrixSum", "[LazyMatrixSum]") { // Make sure that the program does not get aborted - linalgwrap::exceptions::assert_dbg_effect = - linalgwrap::exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); // TODO Test swap function // TODO Test constructors diff --git a/tests/LazyMatrixWrapperTests.cc b/tests/LazyMatrixWrapperTests.cc index acf862b..a04150f 100644 --- a/tests/LazyMatrixWrapperTests.cc +++ b/tests/LazyMatrixWrapperTests.cc @@ -31,7 +31,7 @@ TEST_CASE("LazyMatrixWrapper class", "[LazyMatrixWrapper]") { // Test swapping // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); typedef double scalar_type; typedef SmallMatrix stored_matrix_type; diff --git a/tests/LazyMatrix_i_Tests.cc b/tests/LazyMatrix_i_Tests.cc index 6b4d10f..bb6ff52 100644 --- a/tests/LazyMatrix_i_Tests.cc +++ b/tests/LazyMatrix_i_Tests.cc @@ -58,9 +58,8 @@ class SimpleLazyMatrix : public LazyMatrix_i { TEST_CASE("LazyMatrix_i abstract class", "[LazyMatrix_i]") { using namespace lazymatrix_i_tests; - // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); // Test constructor // Test swapping diff --git a/tests/ParameterMapTests.cc b/tests/ParameterMapTests.cc index d00701d..6690442 100644 --- a/tests/ParameterMapTests.cc +++ b/tests/ParameterMapTests.cc @@ -29,7 +29,7 @@ using namespace rc; TEST_CASE("ParameterMap tests", "[parametermap]") { // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); // Some data: int i = 5; diff --git a/tests/RangeTests.cc b/tests/RangeTests.cc index fc6bd3e..7d72ffb 100644 --- a/tests/RangeTests.cc +++ b/tests/RangeTests.cc @@ -141,7 +141,7 @@ TEST_CASE("Range tests", "[range]") { using namespace range_tests; // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); SECTION("Range construction") { REQUIRE(rc::check("Range construction (size_t)", diff --git a/tests/ScaleViewTests.cc b/tests/ScaleViewTests.cc index 7ba073b..954a7f9 100644 --- a/tests/ScaleViewTests.cc +++ b/tests/ScaleViewTests.cc @@ -28,7 +28,7 @@ using namespace rc; TEST_CASE("ScaleView", "[ScaleView]") { // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); // Define the types we use for the test: struct TestTypes { diff --git a/tests/SubscriptionTests.cc b/tests/SubscriptionTests.cc index da13821..36e3670 100644 --- a/tests/SubscriptionTests.cc +++ b/tests/SubscriptionTests.cc @@ -998,10 +998,8 @@ struct AssignRemovePointer TEST_CASE("Subscription and SubscriptionPointer system", "[subscription]") { using namespace subscription_tests; -#ifdef DEBUG // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; -#endif + AssertDbgEffect::set(ExceptionEffect::THROW); SECTION("SubscriptionPointer gets the data from Subscribable") { SimpleSubscribable s{}; diff --git a/tests/TransposeViewTests.cc b/tests/TransposeViewTests.cc index 8fd3c71..5e7a47b 100644 --- a/tests/TransposeViewTests.cc +++ b/tests/TransposeViewTests.cc @@ -27,7 +27,7 @@ using namespace rc; TEST_CASE("TransposeView", "[TransposeView]") { // Make sure that the program does not get aborted - exceptions::assert_dbg_effect = exceptions::ExceptionEffect::THROW; + AssertDbgEffect::set(ExceptionEffect::THROW); // Define the types we use for the test: struct TestTypes {