added convenient wxON_BLOCK_EXIT_THISn() macros wrapping wxON_BLOCK_EXIT_OBJn(*this)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52856 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -60,12 +60,21 @@ public:
|
||||
CPPUNIT_TEST(Dismiss);
|
||||
CPPUNIT_TEST(BlockExit);
|
||||
CPPUNIT_TEST(BlockExitObj);
|
||||
CPPUNIT_TEST(BlockExitThis);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Normal();
|
||||
void Dismiss();
|
||||
void BlockExit();
|
||||
void BlockExitObj();
|
||||
void BlockExitThis();
|
||||
|
||||
private:
|
||||
void Zero() { m_count = 0; }
|
||||
void Set(int n) { m_count = n; }
|
||||
void Sum(int n, int m) { m_count = n + m; }
|
||||
|
||||
int m_count;
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
@@ -172,3 +181,28 @@ void ScopeGuardTestCase::BlockExitObj()
|
||||
CPPUNIT_ASSERT_EQUAL( 5, count2.GetCount() );
|
||||
}
|
||||
|
||||
void ScopeGuardTestCase::BlockExitThis()
|
||||
{
|
||||
m_count = 1;
|
||||
|
||||
{
|
||||
wxON_BLOCK_EXIT_THIS0(ScopeGuardTestCase::Zero);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 1, m_count );
|
||||
}
|
||||
CPPUNIT_ASSERT_EQUAL( 0, m_count );
|
||||
|
||||
{
|
||||
wxON_BLOCK_EXIT_THIS1(ScopeGuardTestCase::Set, 17);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 0, m_count );
|
||||
}
|
||||
CPPUNIT_ASSERT_EQUAL( 17, m_count );
|
||||
|
||||
{
|
||||
wxON_BLOCK_EXIT_THIS2(ScopeGuardTestCase::Sum, 2, 3);
|
||||
CPPUNIT_ASSERT_EQUAL( 17, m_count );
|
||||
}
|
||||
CPPUNIT_ASSERT_EQUAL( 5, m_count );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user