diff options
author | Morgan Deters <mdeters@gmail.com> | 2010-04-09 16:25:32 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2010-04-09 16:25:32 +0000 |
commit | e390a4207d3858927354b3d4b40d540c00f8064c (patch) | |
tree | 589fd13ed8f6ba835cd79a2894092860b66b7696 /test/unit/context/cdlist_black.h | |
parent | c3a6ff8c6e4a0c743cd33eb29931f837eeb2959e (diff) |
added experimental "make lcov" target (it runs only unit tests); better coverage for util and context classes; implemented some output functionality that was missing; reclassified some tests white -> black or black -> public; other minor fixes
Diffstat (limited to 'test/unit/context/cdlist_black.h')
-rw-r--r-- | test/unit/context/cdlist_black.h | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/test/unit/context/cdlist_black.h b/test/unit/context/cdlist_black.h index f31d5f273..418357630 100644 --- a/test/unit/context/cdlist_black.h +++ b/test/unit/context/cdlist_black.h @@ -23,6 +23,14 @@ using namespace std; using namespace CVC4::context; + +struct DtorSensitiveObject { + bool& d_dtorCalled; + DtorSensitiveObject(bool& dtorCalled) : d_dtorCalled(dtorCalled) {} + ~DtorSensitiveObject() { d_dtorCalled = true; } +}; + + class CDListBlack : public CxxTest::TestSuite { private: @@ -34,6 +42,10 @@ public: d_context = new Context(); } + void tearDown() { + delete d_context; + } + // test at different sizes. this triggers grow() behavior differently. // grow() was completely broken in revision 256 void testCDList10() { listTest(10); } @@ -44,7 +56,12 @@ public: void testCDList99() { listTest(99); } void listTest(int N) { - CDList<int> list(d_context); + listTest(N, true); + listTest(N, false); + } + + void listTest(int N, bool callDestructor) { + CDList<int> list(d_context, callDestructor); TS_ASSERT(list.empty()); for(int i = 0; i < N; ++i) { @@ -66,7 +83,46 @@ public: } } - void tearDown() { - delete d_context; + void testDtorCalled() { + bool shouldRemainFalse = false; + bool shouldFlipToTrue = false; + bool alsoFlipToTrue = false; + bool shouldAlsoRemainFalse = false; + bool aThirdFalse = false; + + CDList<DtorSensitiveObject> listT(d_context, true); + CDList<DtorSensitiveObject> listF(d_context, false); + + DtorSensitiveObject shouldRemainFalseDSO(shouldRemainFalse); + DtorSensitiveObject shouldFlipToTrueDSO(shouldFlipToTrue); + DtorSensitiveObject alsoFlipToTrueDSO(alsoFlipToTrue); + DtorSensitiveObject shouldAlsoRemainFalseDSO(shouldAlsoRemainFalse); + DtorSensitiveObject aThirdFalseDSO(aThirdFalse); + + listT.push_back(shouldAlsoRemainFalseDSO); + listF.push_back(shouldAlsoRemainFalseDSO); + + d_context->push(); + + listT.push_back(shouldFlipToTrueDSO); + listT.push_back(alsoFlipToTrueDSO); + + listF.push_back(shouldRemainFalseDSO); + listF.push_back(shouldAlsoRemainFalseDSO); + listF.push_back(aThirdFalseDSO); + + TS_ASSERT_EQUALS(shouldRemainFalse, false); + TS_ASSERT_EQUALS(shouldFlipToTrue, false); + TS_ASSERT_EQUALS(alsoFlipToTrue, false); + TS_ASSERT_EQUALS(shouldAlsoRemainFalse, false); + TS_ASSERT_EQUALS(aThirdFalse, false); + + d_context->pop(); + + TS_ASSERT_EQUALS(shouldRemainFalse, false); + TS_ASSERT_EQUALS(shouldFlipToTrue, true); + TS_ASSERT_EQUALS(alsoFlipToTrue, true); + TS_ASSERT_EQUALS(shouldAlsoRemainFalse, false); + TS_ASSERT_EQUALS(aThirdFalse, false); } }; |