summaryrefslogtreecommitdiff
path: root/test/unit/context
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2017-12-06 04:45:06 -0800
committerAndrew Reynolds <andrew.j.reynolds@gmail.com>2017-12-06 06:45:06 -0600
commit6a37fd136eea6ad95aae4e598faee0d47c110343 (patch)
treefb6d016a14cded96e6b05d988f3c7856100dc71b /test/unit/context
parent108b5ed9d1f66884af7ede96155670bb1dc2fb43 (diff)
Remove CDChunkList (#1414)
Diffstat (limited to 'test/unit/context')
-rw-r--r--test/unit/context/cdlist_black.h8
-rw-r--r--test/unit/context/cdlist_context_memory_black.h160
2 files changed, 8 insertions, 160 deletions
diff --git a/test/unit/context/cdlist_black.h b/test/unit/context/cdlist_black.h
index 8525ef6f3..5015ae002 100644
--- a/test/unit/context/cdlist_black.h
+++ b/test/unit/context/cdlist_black.h
@@ -150,4 +150,12 @@ class CDListBlack : public CxxTest::TestSuite {
#endif /* CVC4_MEMORY_LIMITING_DISABLED */
}
+
+ void testPopBelowLevelCreated()
+ {
+ d_context->push();
+ CDList<int> list(d_context);
+ d_context->popto(0);
+ list.push_back(42);
+ }
};
diff --git a/test/unit/context/cdlist_context_memory_black.h b/test/unit/context/cdlist_context_memory_black.h
deleted file mode 100644
index 654251a0c..000000000
--- a/test/unit/context/cdlist_context_memory_black.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/********************* */
-/*! \file cdlist_context_memory_black.h
- ** \verbatim
- ** Top contributors (to current version):
- ** Morgan Deters, Tim King, Paul Meng
- ** This file is part of the CVC4 project.
- ** Copyright (c) 2009-2017 by the authors listed in the file AUTHORS
- ** in the top-level source directory) and their institutional affiliations.
- ** All rights reserved. See the file COPYING in the top-level source
- ** directory for licensing information.\endverbatim
- **
- ** \brief Black box testing of CVC4::context::CDList<>.
- **
- ** Black box testing of CVC4::context::CDList<>.
- **/
-
-#include <cxxtest/TestSuite.h>
-
-#include <iostream>
-#include <vector>
-
-#include <limits.h>
-
-#include "memory.h"
-
-#include "context/cdchunk_list.h"
-#include "context/context.h"
-
-using namespace std;
-using namespace CVC4::context;
-
-struct DtorSensitiveObject {
- bool& d_dtorCalled;
- DtorSensitiveObject(bool& dtorCalled) : d_dtorCalled(dtorCalled) {}
- ~DtorSensitiveObject() { d_dtorCalled = true; }
-};
-
-class CDListContextMemoryBlack : public CxxTest::TestSuite {
- private:
- Context* d_context;
-
- public:
- void setUp() { 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 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);
- listTest(N, false);
- }
-
- void listTest(int N, bool callDestructor) {
- CDChunkList<int> list(d_context, callDestructor,
- ContextMemoryAllocator<int>(d_context->getCMM()));
-
- TS_ASSERT(list.empty());
- for (int i = 0; i < N; ++i) {
- TS_ASSERT_EQUALS(list.size(), unsigned(i));
- list.push_back(i);
- TS_ASSERT(!list.empty());
- TS_ASSERT_EQUALS(list.back(), i);
- int i2 = 0;
- for (CDChunkList<int>::const_iterator j = list.begin(); j != list.end();
- ++j) {
- TS_ASSERT_EQUALS(*j, i2++);
- }
- }
- TS_ASSERT_EQUALS(list.size(), unsigned(N));
-
- for (int i = 0; i < N; ++i) {
- TS_ASSERT_EQUALS(list[i], i);
- }
- }
-
- 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;
- bool alsoFlipToTrue = false;
- bool shouldAlsoRemainFalse = false;
- bool aThirdFalse = false;
-
- 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);
- 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);
- }
-
- void testOutOfMemory() {
-#ifdef CVC4_MEMORY_LIMITING_DISABLED
-
- CVC4::test::WarnWithLimitedMemoryDisabledReason();
-
-#else /* CVC4_MEMORY_LIMITING_DISABLED */
-
- CDChunkList<unsigned> list(d_context);
- CVC4::test::WithLimitedMemory wlm(1);
-
- TS_ASSERT_THROWS(
- {
- // We cap it at UINT_MAX, preferring to terminate with a
- // failure than run indefinitely.
- for (unsigned i = 0; i < UINT_MAX; ++i) {
- list.push_back(i);
- }
- },
- bad_alloc);
-
-#endif /* CVC4_MEMORY_LIMITING_DISABLED */
- }
-};
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback