diff options
Diffstat (limited to 'test/unit/context')
-rw-r--r-- | test/unit/context/cdlist_black.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/test/unit/context/cdlist_black.h b/test/unit/context/cdlist_black.h index 418357630..bcc95b470 100644 --- a/test/unit/context/cdlist_black.h +++ b/test/unit/context/cdlist_black.h @@ -17,12 +17,17 @@ #include <vector> #include <iostream> + +#include <limits.h> + +#include "memory.h" + #include "context/context.h" #include "context/cdlist.h" using namespace std; using namespace CVC4::context; - +using namespace CVC4::test; struct DtorSensitiveObject { bool& d_dtorCalled; @@ -30,7 +35,6 @@ struct DtorSensitiveObject { ~DtorSensitiveObject() { d_dtorCalled = true; } }; - class CDListBlack : public CxxTest::TestSuite { private: @@ -125,4 +129,17 @@ public: TS_ASSERT_EQUALS(shouldAlsoRemainFalse, false); TS_ASSERT_EQUALS(aThirdFalse, false); } + + void testOutOfMemory() { + CDList<unsigned> list(d_context); + WithLimitedMemory wlm(0); + + 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); + } }; |