diff options
author | Tim King <taking@cs.nyu.edu> | 2012-04-02 20:56:55 +0000 |
---|---|---|
committer | Tim King <taking@cs.nyu.edu> | 2012-04-02 20:56:55 +0000 |
commit | 1a558a30bec496444742ed75c0a6973d9789daf7 (patch) | |
tree | 81d5f4aedc3a320c4b95945c71a1e3cf0d8e88af /test/unit | |
parent | f9d3552033d8214c833b58ed54d99c836de4ce37 (diff) |
- Merged in the branch cdlist-cleanup.
- This adds a CleanUp template argument to CDList.
- CDChunkList<T> replaces the CDList specialization for ContextMemoryAllocator.
- CDVector<T> has been simplified and improved.
- The expected performance impact is negligible.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/context/cdlist_black.h | 36 | ||||
-rw-r--r-- | test/unit/context/cdlist_context_memory_black.h | 32 | ||||
-rw-r--r-- | test/unit/context/cdmap_black.h | 12 | ||||
-rw-r--r-- | test/unit/context/cdvector_black.h | 8 |
4 files changed, 45 insertions, 43 deletions
diff --git a/test/unit/context/cdlist_black.h b/test/unit/context/cdlist_black.h index fcc6a7e55..ccdbb210b 100644 --- a/test/unit/context/cdlist_black.h +++ b/test/unit/context/cdlist_black.h @@ -28,7 +28,6 @@ #include "util/exception.h" #include "context/context.h" #include "context/cdlist.h" -#include "context/cdlist_context_memory.h" using namespace std; using namespace CVC4::context; @@ -58,12 +57,12 @@ public: // test at different sizes. this triggers grow() behavior differently. // grow() was completely broken in revision 256 - void testCDList10() { listTest(10); } - void testCDList15() { listTest(15); } - void testCDList20() { listTest(20); } - void testCDList35() { listTest(35); } - void testCDList50() { listTest(50); } - void testCDList99() { listTest(99); } + void testCDList_BE10() { listTest(10); } + void testCDList_BE15() { listTest(15); } + void testCDList_BE20() { listTest(20); } + void testCDList_BE35() { listTest(35); } + void testCDList_BE50() { listTest(50); } + void testCDList_BE99() { listTest(99); } void listTest(int N) { listTest(N, true); @@ -71,7 +70,7 @@ public: } void listTest(int N, bool callDestructor) { - CDList<int> list(d_context, callDestructor); + CDList_BE<int> list(d_context, callDestructor); TS_ASSERT(list.empty()); for(int i = 0; i < N; ++i) { @@ -80,7 +79,7 @@ public: TS_ASSERT(!list.empty()); TS_ASSERT_EQUALS(list.back(), i); int i2 = 0; - for(CDList<int>::const_iterator j = list.begin(); + for(CDList_BE<int>::const_iterator j = list.begin(); j != list.end(); ++j) { TS_ASSERT_EQUALS(*j, i2++); @@ -100,8 +99,8 @@ public: bool shouldAlsoRemainFalse = false; bool aThirdFalse = false; - CDList<DtorSensitiveObject> listT(d_context, true); - CDList<DtorSensitiveObject> listF(d_context, false); + CDList_BE<DtorSensitiveObject> listT(d_context, true); + CDList_BE<DtorSensitiveObject> listF(d_context, false); DtorSensitiveObject shouldRemainFalseDSO(shouldRemainFalse); DtorSensitiveObject shouldFlipToTrueDSO(shouldFlipToTrue); @@ -136,15 +135,10 @@ public: TS_ASSERT_EQUALS(aThirdFalse, false); } - void testEmptyIterators() { - CDList<int>* list1 = new(true) CDList<int>(d_context); - CDList< int, ContextMemoryAllocator<int> >* list2 = - new(d_context->getCMM()) - CDList< int, ContextMemoryAllocator<int> >(true, d_context, false, - ContextMemoryAllocator<int>(d_context->getCMM())); - TS_ASSERT_EQUALS(list1->begin(), list1->end()); - TS_ASSERT_EQUALS(list2->begin(), list2->end()); - list1->deleteSelf(); + void testEmptyIterator() { + CDList_BE<int>* list = new(true) CDList_BE<int>(d_context); + TS_ASSERT_EQUALS(list->begin(), list->end()); + list->deleteSelf(); } /* setrlimit() totally broken on Mac OS X */ @@ -155,7 +149,7 @@ public: #else /* __APPLE__ */ - CDList<unsigned> list(d_context); + CDList_BE<unsigned> list(d_context); WithLimitedMemory wlm(1); TS_ASSERT_THROWS({ diff --git a/test/unit/context/cdlist_context_memory_black.h b/test/unit/context/cdlist_context_memory_black.h index a57fd131d..83fb20fd8 100644 --- a/test/unit/context/cdlist_context_memory_black.h +++ b/test/unit/context/cdlist_context_memory_black.h @@ -26,7 +26,7 @@ #include "memory.h" #include "context/context.h" -#include "context/cdlist_context_memory.h" +#include "context/cdchunk_list.h" using namespace std; using namespace CVC4::context; @@ -55,12 +55,12 @@ public: // test at different sizes. this triggers grow() behavior differently. // grow() was completely broken in revision 256 - void testCDList10() { listTest(10); } - void testCDList15() { listTest(15); } - void testCDList20() { listTest(20); } - void testCDList35() { listTest(35); } - void testCDList50() { listTest(50); } - void testCDList99() { listTest(99); } + void testCDChunkList10() { listTest(10); } + void testCDChunkList15() { listTest(15); } + void testCDChunkList20() { listTest(20); } + void testCDChunkList35() { listTest(35); } + void testCDChunkList50() { listTest(50); } + void testCDChunkList99() { listTest(99); } void listTest(int N) { listTest(N, true); @@ -68,7 +68,7 @@ public: } void listTest(int N, bool callDestructor) { - CDList<int, ContextMemoryAllocator<int> > + CDChunkList<int> list(d_context, callDestructor, ContextMemoryAllocator<int>(d_context->getCMM())); TS_ASSERT(list.empty()); @@ -78,7 +78,7 @@ public: TS_ASSERT(!list.empty()); TS_ASSERT_EQUALS(list.back(), i); int i2 = 0; - for(CDList<int, ContextMemoryAllocator<int> >::const_iterator j = list.begin(); + for(CDChunkList<int>::const_iterator j = list.begin(); j != list.end(); ++j) { TS_ASSERT_EQUALS(*j, i2++); @@ -91,6 +91,14 @@ public: } } + void testEmptyIterator() { + CDChunkList< int>* list = + new(d_context->getCMM()) + CDChunkList< int >(true, d_context, false, + ContextMemoryAllocator<int>(d_context->getCMM())); + TS_ASSERT_EQUALS(list->begin(), list->end()); + } + void testDtorCalled() { bool shouldRemainFalse = false; bool shouldFlipToTrue = false; @@ -98,8 +106,8 @@ public: bool shouldAlsoRemainFalse = false; bool aThirdFalse = false; - CDList<DtorSensitiveObject, ContextMemoryAllocator<DtorSensitiveObject> > listT(d_context, true, ContextMemoryAllocator<DtorSensitiveObject>(d_context->getCMM())); - CDList<DtorSensitiveObject, ContextMemoryAllocator<DtorSensitiveObject> > listF(d_context, false, ContextMemoryAllocator<DtorSensitiveObject>(d_context->getCMM())); + CDChunkList<DtorSensitiveObject> listT(d_context, true, ContextMemoryAllocator<DtorSensitiveObject>(d_context->getCMM())); + CDChunkList<DtorSensitiveObject> listF(d_context, false, ContextMemoryAllocator<DtorSensitiveObject>(d_context->getCMM())); DtorSensitiveObject shouldRemainFalseDSO(shouldRemainFalse); DtorSensitiveObject shouldFlipToTrueDSO(shouldFlipToTrue); @@ -142,7 +150,7 @@ public: #else /* __APPLE__ */ - CDList<unsigned, ContextMemoryAllocator<unsigned> > list(d_context); + CDChunkList<unsigned> list(d_context); WithLimitedMemory wlm(1); TS_ASSERT_THROWS({ diff --git a/test/unit/context/cdmap_black.h b/test/unit/context/cdmap_black.h index 0358d1edd..281d814aa 100644 --- a/test/unit/context/cdmap_black.h +++ b/test/unit/context/cdmap_black.h @@ -933,9 +933,9 @@ public: //Debug.on("gc"); //Debug.on("context"); - CDHashMap<int, CDList<myint>*, int_hasher> map(d_context); + CDHashMap<int, CDList_BE<myint>*, int_hasher> map(d_context); - CDList<myint> *list1, *list2, *list3, *list4; + CDList_BE<myint> *list1, *list2, *list3, *list4; TS_ASSERT(map.find(1) == map.end()); TS_ASSERT(map.find(2) == map.end()); @@ -947,10 +947,10 @@ public: int* x = (int*) d_context->getCMM()->newData(sizeof(int)); - list1 = new(d_context->getCMM()) CDList<myint>(true, d_context); - list2 = new(d_context->getCMM()) CDList<myint>(true, d_context); - list3 = new(d_context->getCMM()) CDList<myint>(true, d_context); - list4 = new(d_context->getCMM()) CDList<myint>(true, d_context); + list1 = new(d_context->getCMM()) CDList_BE<myint>(true, d_context); + list2 = new(d_context->getCMM()) CDList_BE<myint>(true, d_context); + list3 = new(d_context->getCMM()) CDList_BE<myint>(true, d_context); + list4 = new(d_context->getCMM()) CDList_BE<myint>(true, d_context); list1->push_back(1); list2->push_back(2); diff --git a/test/unit/context/cdvector_black.h b/test/unit/context/cdvector_black.h index b49186dd0..0f13d957e 100644 --- a/test/unit/context/cdvector_black.h +++ b/test/unit/context/cdvector_black.h @@ -68,8 +68,8 @@ public: void vectorTest(unsigned P, unsigned m){ for(unsigned g=2; g< P; g++){ - vectorTest(P, g, m, 1, false); - vectorTest(P, g, m, 3, false); + vectorTest(P, g, m, 1); + vectorTest(P, g, m, 3); } } vector<unsigned> copy(CDVector<unsigned>& v){ @@ -87,8 +87,8 @@ public: } } - void vectorTest(unsigned P, unsigned g, unsigned m, unsigned r, bool callDestructor) { - CDVector<unsigned> vec(d_context, callDestructor); + void vectorTest(unsigned P, unsigned g, unsigned m, unsigned r) { + CDVector<unsigned> vec(d_context); vector< vector<unsigned> > copies; copies.push_back( copy(vec) ); |