Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50710 - trunk/libs/scope_exit/test
From: Alexander.Nasonov_at_[hidden]
Date: 2009-01-21 15:03:11


Author: nasonov
Date: 2009-01-21 15:03:11 EST (Wed, 21 Jan 2009)
New Revision: 50710
URL: http://svn.boost.org/trac/boost/changeset/50710

Log:
Pass-by-value tests.
Text files modified:
   trunk/libs/scope_exit/test/native.cpp | 49 +++++++++++++++++++++++++++++++++++++++
   1 files changed, 48 insertions(+), 1 deletions(-)

Modified: trunk/libs/scope_exit/test/native.cpp
==============================================================================
--- trunk/libs/scope_exit/test/native.cpp (original)
+++ trunk/libs/scope_exit/test/native.cpp 2009-01-21 15:03:11 EST (Wed, 21 Jan 2009)
@@ -31,6 +31,20 @@
     // ... and one local variable as well:
     int i = 0;
 
+ BOOST_SCOPE_EXIT( (i) )
+ {
+ BOOST_CHECK(i == 0);
+ BOOST_CHECK(Holder<>::g_long == 3);
+ BOOST_CHECK(g_str == "try: g_str");
+ } BOOST_SCOPE_EXIT_END
+
+ BOOST_SCOPE_EXIT( (&i) )
+ {
+ BOOST_CHECK(i == 3);
+ BOOST_CHECK(Holder<>::g_long == 3);
+ BOOST_CHECK(g_str == "try: g_str");
+ } BOOST_SCOPE_EXIT_END
+
     {
         g_str = "";
         Holder<>::g_long = 1;
@@ -60,6 +74,20 @@
     BOOST_CHECK(g_str == "g_str");
     BOOST_CHECK(i == 1); // Check that first declared is executed last
 
+ BOOST_SCOPE_EXIT( (&i) )
+ {
+ BOOST_CHECK(i == 3);
+ BOOST_CHECK(Holder<>::g_long == 3);
+ BOOST_CHECK(g_str == "try: g_str");
+ } BOOST_SCOPE_EXIT_END
+
+ BOOST_SCOPE_EXIT( (i) )
+ {
+ BOOST_CHECK(i == 1);
+ BOOST_CHECK(Holder<>::g_long == 3);
+ BOOST_CHECK(g_str == "try: g_str");
+ } BOOST_SCOPE_EXIT_END
+
     try
     {
         BOOST_SCOPE_EXIT( (&i) )
@@ -95,7 +123,7 @@
 
 void test_types()
 {
- bool (*pf)() = &foo;
+ bool (*pf)() = 0;
     bool (&rf)() = foo;
     bool results[2] = {};
 
@@ -107,12 +135,31 @@
         }
         BOOST_SCOPE_EXIT_END
 
+ pf = &foo;
+
         BOOST_CHECK(results[0] == false);
         BOOST_CHECK(results[1] == false);
     }
 
     BOOST_CHECK(results[0] == true);
     BOOST_CHECK(results[1] == true);
+
+ {
+ BOOST_SCOPE_EXIT( (&results)(pf) )
+ {
+ results[0] = !pf();
+ results[1] = !pf();
+ }
+ BOOST_SCOPE_EXIT_END
+
+ pf = 0;
+
+ BOOST_CHECK(results[0] == true);
+ BOOST_CHECK(results[1] == true);
+ }
+
+ BOOST_CHECK(results[0] == false);
+ BOOST_CHECK(results[1] == false);
 }
 
 test_suite* init_unit_test_suite( int, char* [] )


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk