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 ()); } + static void f(vmime::ref /* 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 (), std::runtime_error); + } + VMIME_TEST_SUITE_END