]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/scopeguard/scopeguardtest.cpp
Allow running only some graphics benchmarks to save time.
[wxWidgets.git] / tests / scopeguard / scopeguardtest.cpp
index 977e316af29c8237a7f85b5432742f123ec9e8ec..3a6b3ff67497697e202cf98c0875c7e31ccff1af 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Vadim Zeitlin
 // RCS-ID:      $Id$
 // Copyright:   (c) 2005 Vadim Zeitlin
-// Licence:     wxWidgets licence
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -21,6 +21,7 @@
     #pragma hdrstop
 #endif
 
+#include "wx/string.h"
 #include "wx/scopeguard.h"
 
 // ----------------------------------------------------------------------------
@@ -61,6 +62,7 @@ public:
         CPPUNIT_TEST(BlockExit);
         CPPUNIT_TEST(BlockExitObj);
         CPPUNIT_TEST(BlockExitThis);
+        CPPUNIT_TEST(BlockExitSetVar);
     CPPUNIT_TEST_SUITE_END();
 
     void Normal();
@@ -68,6 +70,7 @@ public:
     void BlockExit();
     void BlockExitObj();
     void BlockExitThis();
+    void BlockExitSetVar();
 
 private:
     void Zero() { m_count = 0; }
@@ -80,7 +83,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION(ScopeGuardTestCase);
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ScopeGuardTestCase,
                                       "ScopeGuardTestCase");
 
@@ -206,3 +209,39 @@ void ScopeGuardTestCase::BlockExitThis()
     CPPUNIT_ASSERT_EQUAL( 5, m_count );
 }
 
+void ScopeGuardTestCase::BlockExitSetVar()
+{
+    m_count = 1;
+    {
+        wxON_BLOCK_EXIT_SET(m_count, 17);
+
+        CPPUNIT_ASSERT_EQUAL( 1, m_count );
+    }
+    CPPUNIT_ASSERT_EQUAL( 17, m_count );
+
+
+    int count = 1;
+    {
+        wxON_BLOCK_EXIT_SET(count, 17);
+
+        CPPUNIT_ASSERT_EQUAL( 1, count );
+    }
+    CPPUNIT_ASSERT_EQUAL( 17, count );
+
+
+    wxString s("hi");
+    {
+        wxON_BLOCK_EXIT_SET(s, "bye");
+
+        CPPUNIT_ASSERT_EQUAL( "hi", s );
+    }
+    CPPUNIT_ASSERT_EQUAL( "bye", s );
+
+    ScopeGuardTestCase *p = this;
+    {
+        wxON_BLOCK_EXIT_NULL(p);
+
+        CPPUNIT_ASSERT( p );
+    }
+    CPPUNIT_ASSERT( !p );
+}