Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76498 - sandbox/closure/libs/scope_exit/test
From: lorcaminiti_at_[hidden]
Date: 2012-01-14 16:39:42


Author: lcaminiti
Date: 2012-01-14 16:39:41 EST (Sat, 14 Jan 2012)
New Revision: 76498
URL: http://svn.boost.org/trac/boost/changeset/76498

Log:
Added this_ unit test.
Added:
   sandbox/closure/libs/scope_exit/test/native_this.cpp (contents, props changed)

Added: sandbox/closure/libs/scope_exit/test/native_this.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/native_this.cpp 2012-01-14 16:39:41 EST (Sat, 14 Jan 2012)
@@ -0,0 +1,40 @@
+
+#include <boost/scope_exit.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/test/unit_test.hpp>
+
+using namespace boost::unit_test;
+
+struct this_tester;
+BOOST_TYPEOF_REGISTER_TYPE(this_tester) // Register before capture of `this_`.
+
+struct this_tester
+{
+ void check()
+ {
+ int target;
+ BOOST_SCOPE_EXIT( (&target) (this_) )
+ {
+ BOOST_CHECK(this_->value_ == target);
+ } BOOST_SCOPE_EXIT_END
+#if !defined(BOOST_NO_LAMBDAS) && !defined(BOOST_SCOPE_EXIT_CONFIG_NO_CPP11)
+ BOOST_SCOPE_EXIT_ALL(&, this)
+ {
+ BOOST_CHECK(this->value_ == target);
+ };
+#endif
+ value_ = target = 3;
+ }
+private:
+ int value_;
+};
+
+void test_this() { this_tester().check(); }
+
+test_suite* init_unit_test_suite( int, char* [] )
+{
+ framework::master_test_suite().p_name.value = "Unit test for ScopeExit";
+ framework::master_test_suite().add( BOOST_TEST_CASE( &test_this ) );
+ return 0;
+}


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