aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utility/smartPtrTest.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2005-09-02 11:02:12 +0000
committerVincent Richard <[email protected]>2005-09-02 11:02:12 +0000
commit2dd861c907bd0634f720ce36ec4b1d3a18597bfa (patch)
tree94ee53d6befadc56dfde9b56a0f6efeb1c7e0247 /tests/utility/smartPtrTest.cpp
parentThrow exception in debug mode when thisRef()/thisWeakRef() is called from the... (diff)
downloadvmime-2dd861c907bd0634f720ce36ec4b1d3a18597bfa.tar.gz
vmime-2dd861c907bd0634f720ce36ec4b1d3a18597bfa.zip
Throw exception in debug mode when thisRef()/thisWeakRef() is called from the object's constructor.
Diffstat (limited to 'tests/utility/smartPtrTest.cpp')
-rw-r--r--tests/utility/smartPtrTest.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/utility/smartPtrTest.cpp b/tests/utility/smartPtrTest.cpp
index 35824f42..f741f12b 100644
--- a/tests/utility/smartPtrTest.cpp
+++ b/tests/utility/smartPtrTest.cpp
@@ -35,6 +35,7 @@ VMIME_TEST_SUITE_BEGIN
VMIME_TEST(testCast)
VMIME_TEST(testContainer)
VMIME_TEST(testCompare)
+ VMIME_TEST(testThisRefCtor)
VMIME_TEST_LIST_END
@@ -60,6 +61,12 @@ VMIME_TEST_SUITE_BEGIN
bool* m_aliveFlag;
};
+ struct X : public vmime::object
+ {
+ X() { f(thisRef().dynamicCast <X>()); }
+ static void f(vmime::ref <X> /* x */) { }
+ };
+
void testNull()
{
@@ -237,5 +244,11 @@ VMIME_TEST_SUITE_BEGIN
VASSERT("10", std::find(v.begin(), v.end(), r3) == v.end());
}
+ void testThisRefCtor()
+ {
+ // BUGFIX: thisRef() MUST NOT be called from the object constructor
+ VASSERT_THROW("1", vmime::create <X>(), std::runtime_error);
+ }
+
VMIME_TEST_SUITE_END