aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/common/ptr.h23
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);
}
};