Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76491 - sandbox/closure/libs/scope_exit/test
From: lorcaminiti_at_[hidden]
Date: 2012-01-14 11:43:03


Author: lcaminiti
Date: 2012-01-14 11:43:01 EST (Sat, 14 Jan 2012)
New Revision: 76491
URL: http://svn.boost.org/trac/boost/changeset/76491

Log:
Renaming.
Added:
   sandbox/closure/libs/scope_exit/test/world.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_commit.cpp
   sandbox/closure/libs/scope_exit/test/world_lambda.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_commit_lambda.cpp
   sandbox/closure/libs/scope_exit/test/world_seq.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_commit_seq.cpp
   sandbox/closure/libs/scope_exit/test/world_this.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_commit_this.cpp
   sandbox/closure/libs/scope_exit/test/world_this_seq.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_commit_this_seq.cpp
   sandbox/closure/libs/scope_exit/test/world_tpl.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_commit_tpl.cpp
   sandbox/closure/libs/scope_exit/test/world_tpl_seq.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_commit_tpl_seq.cpp
   sandbox/closure/libs/scope_exit/test/world_void.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_commit_void.cpp
Removed:
   sandbox/closure/libs/scope_exit/test/world_commit.cpp
   sandbox/closure/libs/scope_exit/test/world_commit_lambda.cpp
   sandbox/closure/libs/scope_exit/test/world_commit_seq.cpp
   sandbox/closure/libs/scope_exit/test/world_commit_this.cpp
   sandbox/closure/libs/scope_exit/test/world_commit_this_seq.cpp
   sandbox/closure/libs/scope_exit/test/world_commit_tpl.cpp
   sandbox/closure/libs/scope_exit/test/world_commit_tpl_seq.cpp
   sandbox/closure/libs/scope_exit/test/world_commit_void.cpp

Deleted: sandbox/closure/libs/scope_exit/test/world_commit.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_commit.cpp 2012-01-14 11:43:01 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,38 +0,0 @@
-
-#include <boost/scope_exit.hpp>
-//#define BOOST_TEST_MODULE TestWorldCommit
-//#include <boost/test/unit_test.hpp>
-#include <vector>
-
-struct person {};
-
-struct world {
- void add_person(person const& a_person);
- std::vector<person> persons_;
-};
-
-//[test_world_commit
-void world::add_person(person const& a_person) {
- bool commit = false;
-
- persons_.push_back(a_person); // (1) direct action
- // Following block is executed when the enclosing scope exits.
- BOOST_SCOPE_EXIT(&commit, &persons_) {
- if(!commit) persons_.pop_back(); // (2) rollback action
- } BOOST_SCOPE_EXIT_END
-
- // ... // (3) other operations
-
- commit = true; // (4) disable rollback actions
-}
-//]
-
-//BOOST_AUTO_TEST_CASE( test_world_commit ) {
-int main() {
- world w;
- person p;
- w.add_person(p);
-// BOOST_CHECK( w.persons_.size() == 1 );
- return 0;
-}
-

Deleted: sandbox/closure/libs/scope_exit/test/world_commit_lambda.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_commit_lambda.cpp 2012-01-14 11:43:01 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,53 +0,0 @@
-
-#include <boost/config.hpp>
-
-#ifndef BOOST_NO_LAMBDAS
-
-#define BOOST_TEST_MODULE TestWorldCommitLambda
-#include <boost/test/unit_test.hpp>
-#include <vector>
-
-struct person {};
-
-struct world {
- void add_person(person const& a_person);
- std::vector<person> persons_;
-};
-
-//[test_world_commit_lambda
-#include <functional>
-
-struct scope_exit {
- scope_exit(std::function<void (void)> f) : f_(f) {}
- ~scope_exit(void) { f_(); }
-private:
- std::function<void (void)> f_;
-};
-
-void world::add_person(person const& a_person) {
- bool commit = false;
-
- persons_.push_back(a_person);
- scope_exit on_exit1([&commit, &persons_]() { // Use C++11 lambda.
- if(!commit) persons_.pop_back();
- });
-
- // ...
-
- commit = true;
-}
-//]
-
-BOOST_AUTO_TEST_CASE( test_world_commit_lambda ) {
- world w;
- person p;
- w.add_person(p);
- BOOST_CHECK( w.persons_.size() == 1 );
-}
-
-#else // No lambdas (trivial test).
-
-int main(void) { return 0; }
-
-#endif
-

Deleted: sandbox/closure/libs/scope_exit/test/world_commit_seq.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_commit_seq.cpp 2012-01-14 11:43:01 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,37 +0,0 @@
-
-#include <boost/scope_exit.hpp>
-//#define BOOST_TEST_MODULE TestWorldCommitSeq
-//#include <boost/test/unit_test.hpp>
-#include <vector>
-
-struct person {};
-
-struct world {
- void add_person(person const& a_person);
- std::vector<person> persons_;
-};
-
-//[test_world_commit_seq
-void world::add_person(person const& a_person) {
- bool commit = false;
-
- persons_.push_back(a_person);
- BOOST_SCOPE_EXIT( (&commit) (&persons_) ) {
- if(!commit) persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
-
- // ...
-
- commit = true;
-}
-//]
-
-//BOOST_AUTO_TEST_CASE( test_world_commit_seq ) {
-int main() {
- world w;
- person p;
- w.add_person(p);
-// BOOST_CHECK( w.persons_.size() == 1 );
- return 0;
-}
-

Deleted: sandbox/closure/libs/scope_exit/test/world_commit_this.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_commit_this.cpp 2012-01-14 11:43:01 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,44 +0,0 @@
-
-#include <boost/scope_exit.hpp>
-#include <boost/config.hpp>
-#define BOOST_TEST_MODULE TestWorldCommitThis
-#include <boost/test/unit_test.hpp>
-#include <vector>
-
-struct person {};
-
-struct world {
- void add_person(person const& a_person);
- std::vector<person> persons_;
-};
-
-void world::add_person(person const& a_person) {
- bool commit = false;
-
- persons_.push_back(a_person);
-#ifdef BOOST_NO_LAMBDAS
- //[test_world_commit_this_
- BOOST_SCOPE_EXIT(&commit, this_) { // Capture object `this_`.
- if(!commit) this_->persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
- //]
-#else
- //[test_world_commit_this
- BOOST_SCOPE_EXIT(&commit, this) { // Use `this` (C++11).
- if(!commit) this->persons_.pop_back();
- }; // Use `;` instead of `BOOST_SCOPE_EXIT_END` (C++11).
- //]
-#endif
-
- // ...
-
- commit = true;
-}
-
-BOOST_AUTO_TEST_CASE( test_world_commit_this ) {
- world w;
- person p;
- w.add_person(p);
- BOOST_CHECK( w.persons_.size() == 1 );
-}
-

Deleted: sandbox/closure/libs/scope_exit/test/world_commit_this_seq.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_commit_this_seq.cpp 2012-01-14 11:43:01 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,44 +0,0 @@
-
-#include <boost/scope_exit.hpp>
-#include <boost/config.hpp>
-#define BOOST_TEST_MODULE TestWorldCommitThis
-#include <boost/test/unit_test.hpp>
-#include <vector>
-
-struct person {};
-
-struct world {
- void add_person(person const& a_person);
- std::vector<person> persons_;
-};
-
-void world::add_person(person const& a_person) {
- bool commit = false;
-
- persons_.push_back(a_person);
-#ifdef BOOST_NO_LAMBDAS
- //[test_world_commit_this_
- BOOST_SCOPE_EXIT( (&commit) (this_) ) { // Capture object `this_`.
- if(!commit) this_->persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
- //]
-#else
- //[test_world_commit_this
- BOOST_SCOPE_EXIT( (&commit) (this) ) { // Use `this` (C++11).
- if(!commit) this->persons_.pop_back();
- }; // Use `;` instead of `BOOST_SCOPE_EXIT_END` (C++11).
- //]
-#endif
-
- // ...
-
- commit = true;
-}
-
-BOOST_AUTO_TEST_CASE( test_world_commit_this ) {
- world w;
- person p;
- w.add_person(p);
- BOOST_CHECK( w.persons_.size() == 1 );
-}
-

Deleted: sandbox/closure/libs/scope_exit/test/world_commit_tpl.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_commit_tpl.cpp 2012-01-14 11:43:01 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,36 +0,0 @@
-
-#include <boost/scope_exit.hpp>
-#define BOOST_TEST_MODULE TestWorldCommitTpl
-#include <boost/test/unit_test.hpp>
-
-struct person {};
-
-template<typename Person>
-struct world {
- void add_person(Person const& a_person);
- std::vector<Person> persons_;
-};
-
-//[test_world_commit_tpl
-template<typename Person>
-void world<Person>::add_person(Person const& a_person) {
- bool commit = false;
- persons_.push_back(a_person);
-
- BOOST_SCOPE_EXIT_TPL(&commit, this_) { // Use `_TPL` postfix.
- if(!commit) this_->persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
-
- // ...
-
- commit = true;
-}
-//]
-
-BOOST_AUTO_TEST_CASE( test_world_commit_tpl ) {
- world<person> w;
- person p;
- w.add_person(p);
- BOOST_CHECK( w.persons_.size() == 1 );
-}
-

Deleted: sandbox/closure/libs/scope_exit/test/world_commit_tpl_seq.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_commit_tpl_seq.cpp 2012-01-14 11:43:01 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,36 +0,0 @@
-
-#include <boost/scope_exit.hpp>
-#define BOOST_TEST_MODULE TestWorldCommitTplSeq
-#include <boost/test/unit_test.hpp>
-
-struct person {};
-
-template<typename Person>
-struct world {
- void add_person(Person const& a_person);
- std::vector<Person> persons_;
-};
-
-//[test_world_commit_tpl_seq
-template<typename Person>
-void world<Person>::add_person(Person const& a_person) {
- bool commit = false;
- persons_.push_back(a_person);
-
- BOOST_SCOPE_EXIT_TPL( (&commit) (this_) ) {
- if(!commit) this_->persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
-
- // ...
-
- commit = true;
-}
-//]
-
-BOOST_AUTO_TEST_CASE( test_world_commit_tpl_seq ) {
- world<person> w;
- person p;
- w.add_person(p);
- BOOST_CHECK( w.persons_.size() == 1 );
-}
-

Deleted: sandbox/closure/libs/scope_exit/test/world_commit_void.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_commit_void.cpp 2012-01-14 11:43:01 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,36 +0,0 @@
-
-#include <boost/scope_exit.hpp>
-//#define BOOST_TEST_MODULE TestWorldCommitVoid
-//#include <boost/test/unit_test.hpp>
-#include <vector>
-
-struct person {};
-
-//[test_world_commit_void
-struct world_t {
- std::vector<person> persons;
- bool commit;
-} world; // Global variable.
-
-void add_person(person const& a_person) {
- world.commit = false;
- world.persons.push_back(a_person);
-
- BOOST_SCOPE_EXIT(void) { // No captures.
- if(!world.commit) world.persons.pop_back();
- } BOOST_SCOPE_EXIT_END
-
- // ...
-
- world.commit = true;
-}
-//]
-
-//BOOST_AUTO_TEST_CASE( test_world_commit_void ) {
-int main() {
- person p;
- add_person(p);
-// BOOST_CHECK( world.persons.size() == 1 );
- 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