diff options
author | Johannes Schickel | 2008-03-30 01:26:51 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-03-30 01:26:51 +0000 |
commit | 3db24addcdc09db817c220620138eb463fd8b58d (patch) | |
tree | 7027db727db821d65b0653c9768886e5fe2c7ac2 /test | |
parent | 08b54da75ecfb16e5dcc0b86aecf1171748aeac4 (diff) | |
download | scummvm-rg350-3db24addcdc09db817c220620138eb463fd8b58d.tar.gz scummvm-rg350-3db24addcdc09db817c220620138eb463fd8b58d.tar.bz2 scummvm-rg350-3db24addcdc09db817c220620138eb463fd8b58d.zip |
- Added support for custom deletion operator (aka deleter) support for SharedPtr.
- Removed two failing comparison tests of SharedPtr in our test suite (those were not supported according to our documentation anyway)
svn-id: r31312
Diffstat (limited to 'test')
-rw-r--r-- | test/common/ptr.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/test/common/ptr.h b/test/common/ptr.h index 7102a819cf..b7ed637040 100644 --- a/test/common/ptr.h +++ b/test/common/ptr.h @@ -34,6 +34,24 @@ class PtrTestSuite : public CxxTest::TestSuite TS_ASSERT(p1.unique()); } + template<class T> + struct Deleter { + bool *test; + void operator()(T *ptr) { *test = true; delete ptr; } + }; + + void test_deleter() { + Deleter<int> myDeleter; + myDeleter.test = new bool(false); + + { + Common::SharedPtr<int> p(new int(1), myDeleter); + } + + TS_ASSERT_EQUALS(*myDeleter.test, true); + delete myDeleter.test; + } + void test_compare() { Common::SharedPtr<int> p1(new int(1)); Common::SharedPtr<int> p2; @@ -43,10 +61,5 @@ class PtrTestSuite : public CxxTest::TestSuite TS_ASSERT(p1 != 0); TS_ASSERT(p2 == 0); - - // Note: The following two currently do *not* work, contrary to - // what the Doxygen comments of SharedPtr claim. - TS_ASSERT(p1 != (int *)0); - TS_ASSERT(p2 == (int *)0); } }; |