diff options
author | Andres Noetzli <andres.noetzli@gmail.com> | 2018-10-02 10:28:38 -0700 |
---|---|---|
committer | Aina Niemetz <aina.niemetz@gmail.com> | 2018-10-02 10:28:38 -0700 |
commit | 8519233cec9501f31aa1789eff60cb802c8df450 (patch) | |
tree | 60c87d9fe4c59ac565b3fdd66710229f58bc6a44 /test/unit/context | |
parent | 64a0e3f1e4a5a8e3070eeadae0f6942b290c2974 (diff) |
Fix "catching polymorphic type by value" warnings (#2556)
When using the `TS_ASSERT_THROWS` marco from CxxTest, we have to make
sure that we use a reference type for the exception, otherwise the unit
test tries to catch the exception by value, resulting in "catching
polymorphic type by value" warnings.
Diffstat (limited to 'test/unit/context')
-rw-r--r-- | test/unit/context/cdlist_black.h | 5 | ||||
-rw-r--r-- | test/unit/context/cdmap_black.h | 11 | ||||
-rw-r--r-- | test/unit/context/cdmap_white.h | 8 | ||||
-rw-r--r-- | test/unit/context/context_black.h | 4 | ||||
-rw-r--r-- | test/unit/context/context_mm_black.h | 2 |
5 files changed, 16 insertions, 14 deletions
diff --git a/test/unit/context/cdlist_black.h b/test/unit/context/cdlist_black.h index 8a31f70ca..b6b7f436c 100644 --- a/test/unit/context/cdlist_black.h +++ b/test/unit/context/cdlist_black.h @@ -142,11 +142,12 @@ class CDListBlack : public CxxTest::TestSuite { { // We cap it at UINT_MAX, preferring to terminate with a // failure than run indefinitely. - for (unsigned i = 0; i < UINT_MAX; ++i) { + for (unsigned i = 0; i < UINT_MAX; ++i) + { list.push_back(i); } }, - bad_alloc); + bad_alloc&); #endif /* CVC4_MEMORY_LIMITING_DISABLED */ } diff --git a/test/unit/context/cdmap_black.h b/test/unit/context/cdmap_black.h index 2d2b3f409..1cb7e50e7 100644 --- a/test/unit/context/cdmap_black.h +++ b/test/unit/context/cdmap_black.h @@ -164,9 +164,9 @@ class CDMapBlack : public CxxTest::TestSuite { ElementsAre(map, {{1, 2}, {3, 4}, {5, 6}, {9, 8}, {23, 317}})); TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 317), - AssertionException); + AssertionException&); TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 472), - AssertionException); + AssertionException&); map.insert(23, 472); TS_ASSERT( @@ -178,7 +178,7 @@ class CDMapBlack : public CxxTest::TestSuite { ElementsAre(map, {{1, 2}, {3, 4}, {5, 6}, {9, 8}, {23, 472}})); TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 0), - AssertionException); + AssertionException&); map.insert(23, 1024); TS_ASSERT( @@ -194,7 +194,8 @@ class CDMapBlack : public CxxTest::TestSuite { TS_ASSERT( ElementsAre(map, {{3, 4}, {5, 6}, {9, 8}, {23, 317}})); - TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 0), AssertionException); + TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 0), + AssertionException&); map.insert(23, 477); TS_ASSERT( @@ -202,7 +203,7 @@ class CDMapBlack : public CxxTest::TestSuite { d_context->pop(); } - TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 0), AssertionException); + TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 0), AssertionException&); TS_ASSERT( ElementsAre(map, {{3, 4}, {23, 317}})); diff --git a/test/unit/context/cdmap_white.h b/test/unit/context/cdmap_white.h index 0f111cd61..53d523c82 100644 --- a/test/unit/context/cdmap_white.h +++ b/test/unit/context/cdmap_white.h @@ -38,12 +38,12 @@ class CDMapWhite : public CxxTest::TestSuite { TS_ASSERT_THROWS_NOTHING(map.makeCurrent()); - TS_ASSERT_THROWS(map.update(), UnreachableCodeException); + TS_ASSERT_THROWS(map.update(), UnreachableCodeException&); - TS_ASSERT_THROWS(map.save(d_context->getCMM()), UnreachableCodeException); - TS_ASSERT_THROWS(map.restore(&map), UnreachableCodeException); + TS_ASSERT_THROWS(map.save(d_context->getCMM()), UnreachableCodeException&); + TS_ASSERT_THROWS(map.restore(&map), UnreachableCodeException&); d_context->push(); - TS_ASSERT_THROWS(map.makeCurrent(), UnreachableCodeException); + TS_ASSERT_THROWS(map.makeCurrent(), UnreachableCodeException&); } }; diff --git a/test/unit/context/context_black.h b/test/unit/context/context_black.h index b4be4197c..4f867525d 100644 --- a/test/unit/context/context_black.h +++ b/test/unit/context/context_black.h @@ -106,8 +106,8 @@ private: d_context->push(); d_context->pop(); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS( d_context->pop(), AssertionException ); - TS_ASSERT_THROWS( d_context->pop(), AssertionException ); + TS_ASSERT_THROWS(d_context->pop(), AssertionException&); + TS_ASSERT_THROWS(d_context->pop(), AssertionException&); #endif /* CVC4_ASSERTIONS */ } diff --git a/test/unit/context/context_mm_black.h b/test/unit/context/context_mm_black.h index beace137e..2684d643c 100644 --- a/test/unit/context/context_mm_black.h +++ b/test/unit/context/context_mm_black.h @@ -90,7 +90,7 @@ private: } // Try popping out of scope - TS_ASSERT_THROWS(d_cmm->pop(), CVC4::AssertionException); + TS_ASSERT_THROWS(d_cmm->pop(), CVC4::AssertionException&); #endif /* __CVC4__CONTEXT__CONTEXT_MM_H */ } |