diff options
Diffstat (limited to 'test/ptrlist.cpp')
-rw-r--r-- | test/ptrlist.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ptrlist.cpp b/test/ptrlist.cpp new file mode 100644 index 0000000..ba955c5 --- /dev/null +++ b/test/ptrlist.cpp @@ -0,0 +1,27 @@ +#include <gtest/gtest.h> + +#include "backend/PtrList.h" + +class FooBar { + int val = 3; + bool other = 4; +}; + +TEST(PtrListTest, FreePointers) { + // PtrList only works on classes: + FooBar * ptr1 = new FooBar(); + FooBar * ptr2 = new FooBar(); + + { + PtrList<FooBar> foo; + + foo.push_back(ptr1); + foo.push_back(ptr2); + + // this destructor SHOULD free ptr1 and ptr2 + } + + ASSERT_NE(ptr1, nullptr); + ASSERT_NE(ptr2, nullptr); +} + |