Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76490 - sandbox/closure/libs/scope_exit/test
From: lorcaminiti_at_[hidden]
Date: 2012-01-14 11:39:58


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

Log:
Renaming.
Added:
   sandbox/closure/libs/scope_exit/test/world_checkpoint.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world.cpp
   sandbox/closure/libs/scope_exit/test/world_checkpoint_all.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_all.cpp
   sandbox/closure/libs/scope_exit/test/world_checkpoint_all_seq.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_all_seq.cpp
   sandbox/closure/libs/scope_exit/test/world_checkpoint_seq.cpp
      - copied unchanged from r76466, /sandbox/closure/libs/scope_exit/test/world_seq.cpp
Removed:
   sandbox/closure/libs/scope_exit/test/world.cpp
   sandbox/closure/libs/scope_exit/test/world_all.cpp
   sandbox/closure/libs/scope_exit/test/world_all_seq.cpp
   sandbox/closure/libs/scope_exit/test/world_seq.cpp

Deleted: sandbox/closure/libs/scope_exit/test/world.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world.cpp 2012-01-14 11:39:58 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,104 +0,0 @@
-
-#include <boost/scope_exit.hpp>
-#include <boost/foreach.hpp>
-#include <boost/typeof/typeof.hpp>
-#include <boost/typeof/std/vector.hpp>
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
-#define BOOST_TEST_MODULE TestWorld
-#include <boost/test/unit_test.hpp>
-#include <vector>
-#include <iostream>
-#include <sstream>
-
-class person {
- friend class world;
-public:
- typedef unsigned int id_t;
- typedef unsigned int evolution_t;
-
- person(void) : id_(0), evolution_(0) {}
-
- friend std::ostream& operator<<(std::ostream& o, person const& p) {
- return o << "person(" << p.id_ << ", " << p.evolution_ << ")";
- }
-private:
- id_t id_;
- evolution_t evolution_;
-};
-
-BOOST_TYPEOF_REGISTER_TYPE(person)
-
-class world {
-public:
- typedef unsigned int id_t;
-
- world(void) : next_id_(1) {}
-
- void add_person(person const& a_person);
-
- friend std::ostream& operator<<(std::ostream& o, world const& w) {
- o << "world(" << w.next_id_ << ", {";
- BOOST_FOREACH(person const& p, w.persons_) {
- o << " " << p << ", ";
- }
- return o << "})";
- }
-private:
- id_t next_id_;
- std::vector<person> persons_;
-};
-
-BOOST_TYPEOF_REGISTER_TYPE(world)
-
-//[test_world
-void world::add_person(person const& a_person) {
- persons_.push_back(a_person);
-
- // This block must be no-throw.
- person& p = persons_.back();
- person::evolution_t checkpoint = p.evolution_;
- BOOST_SCOPE_EXIT(checkpoint, &p, &persons_) {
- if(checkpoint == p.evolution_) persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
-
- // ...
-
- checkpoint = ++p.evolution_;
-
- // Assign new identifier to the person.
- world::id_t const prev_id = p.id_;
- p.id_ = next_id_++;
- BOOST_SCOPE_EXIT(checkpoint, &p, &next_id_, prev_id) {
- if(checkpoint == p.evolution_) {
- next_id_ = p.id_;
- p.id_ = prev_id;
- }
- } BOOST_SCOPE_EXIT_END
-
- // ...
-
- checkpoint = ++p.evolution_;
-}
-//]
-
-BOOST_AUTO_TEST_CASE( test_world ) {
- person adam, eva;
- std::ostringstream oss;
- oss << adam;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "person(0, 0)" );
-
- oss.str("");
- oss << eva;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "person(0, 0)" );
-
- world w;
- w.add_person(adam);
- w.add_person(eva);
- oss.str("");
- oss << w;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "world(3, { person(1, 2), person(2, 2), })" );
-}
-

Deleted: sandbox/closure/libs/scope_exit/test/world_all.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_all.cpp 2012-01-14 11:39:58 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,114 +0,0 @@
-
-#include <boost/config.hpp>
-
-#ifndef BOOST_NO_LAMBDAS
-
-#include <boost/scope_exit.hpp>
-#include <boost/foreach.hpp>
-#include <boost/typeof/typeof.hpp>
-#include <boost/typeof/std/vector.hpp>
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
-#define BOOST_TEST_MODULE TestWorldAll
-#include <boost/test/unit_test.hpp>
-#include <vector>
-#include <iostream>
-#include <sstream>
-
-class person {
- friend class world;
-public:
- typedef unsigned int id_t;
- typedef unsigned int evolution_t;
-
- person(void) : id_(0), evolution_(0) {}
-
- friend std::ostream& operator<<(std::ostream& o, person const& p) {
- return o << "person(" << p.id_ << ", " << p.evolution_ << ")";
- }
-private:
- id_t id_;
- evolution_t evolution_;
-};
-
-BOOST_TYPEOF_REGISTER_TYPE(person)
-
-class world {
-public:
- typedef unsigned int id_t;
-
- world(void) : next_id_(1) {}
-
- void add_person(person const& a_person);
-
- friend std::ostream& operator<<(std::ostream& o, world const& w) {
- o << "world(" << w.next_id_ << ", {";
- BOOST_FOREACH(person const& p, w.persons_) {
- o << " " << p << ", ";
- }
- return o << "})";
- }
-private:
- id_t next_id_;
- std::vector<person> persons_;
-};
-
-BOOST_TYPEOF_REGISTER_TYPE(world)
-
-//[test_world_all
-void world::add_person(person const& a_person) {
- persons_.push_back(a_person);
-
- // This block must be no-throw.
- person& p = persons_.back();
- person::evolution_t checkpoint = p.evolution_;
- BOOST_SCOPE_EXIT_ALL(&, checkpoint, this_) { // Capture all by ref (C++11).
- if(checkpoint == p.evolution_) this_->persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
-
- // ...
-
- checkpoint = ++p.evolution_;
-
- // Assign new identifier to the person.
- world::id_t const prev_id = p.id_;
- p.id_ = next_id_++;
- BOOST_SCOPE_EXIT_ALL(=, &p, this) { // Capture all by value, `this` (C++11).
- if(checkpoint == p.evolution_) {
- this->next_id_ = p.id_;
- p.id_ = prev_id;
- }
- }; // Use `;` instead of `SCOPE_EXIT_END` (C++11).
-
- // ...
-
- checkpoint = ++p.evolution_;
-}
-//]
-
-BOOST_AUTO_TEST_CASE( test_world_all ) {
- person adam, eva;
- std::ostringstream oss;
- oss << adam;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "person(0, 0)" );
-
- oss.str("");
- oss << eva;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "person(0, 0)" );
-
- world w;
- w.add_person(adam);
- w.add_person(eva);
- oss.str("");
- oss << w;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "world(3, { person(1, 2), person(2, 2), })" );
-}
-
-#else // No lambdas (trivial test).
-
-int main(void) { return 0; }
-
-#endif
-

Deleted: sandbox/closure/libs/scope_exit/test/world_all_seq.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_all_seq.cpp 2012-01-14 11:39:58 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,114 +0,0 @@
-
-#include <boost/config.hpp>
-
-#ifndef BOOST_NO_LAMBDAS
-
-#include <boost/scope_exit.hpp>
-#include <boost/foreach.hpp>
-#include <boost/typeof/typeof.hpp>
-#include <boost/typeof/std/vector.hpp>
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
-#define BOOST_TEST_MODULE TestWorldAllSeq
-#include <boost/test/unit_test.hpp>
-#include <vector>
-#include <iostream>
-#include <sstream>
-
-class person {
- friend class world;
-public:
- typedef unsigned int id_t;
- typedef unsigned int evolution_t;
-
- person(void) : id_(0), evolution_(0) {}
-
- friend std::ostream& operator<<(std::ostream& o, person const& p) {
- return o << "person(" << p.id_ << ", " << p.evolution_ << ")";
- }
-private:
- id_t id_;
- evolution_t evolution_;
-};
-
-BOOST_TYPEOF_REGISTER_TYPE(person)
-
-class world {
-public:
- typedef unsigned int id_t;
-
- world(void) : next_id_(1) {}
-
- void add_person(person const& a_person);
-
- friend std::ostream& operator<<(std::ostream& o, world const& w) {
- o << "world(" << w.next_id_ << ", {";
- BOOST_FOREACH(person const& p, w.persons_) {
- o << " " << p << ", ";
- }
- return o << "})";
- }
-private:
- id_t next_id_;
- std::vector<person> persons_;
-};
-
-BOOST_TYPEOF_REGISTER_TYPE(world)
-
-//[test_world_all_seq
-void world::add_person(person const& a_person) {
- persons_.push_back(a_person);
-
- // This block must be no-throw.
- person& p = persons_.back();
- person::evolution_t checkpoint = p.evolution_;
- BOOST_SCOPE_EXIT_ALL( (&) (checkpoint) (this_) ) {
- if(checkpoint == p.evolution_) this_->persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
-
- // ...
-
- checkpoint = ++p.evolution_;
-
- // Assign new identifier to the person.
- world::id_t const prev_id = p.id_;
- p.id_ = next_id_++;
- BOOST_SCOPE_EXIT_ALL( (=) (&p) (this) ) {
- if(checkpoint == p.evolution_) {
- this->next_id_ = p.id_;
- p.id_ = prev_id;
- }
- };
-
- // ...
-
- checkpoint = ++p.evolution_;
-}
-//]
-
-BOOST_AUTO_TEST_CASE( test_world_all_seq ) {
- person adam, eva;
- std::ostringstream oss;
- oss << adam;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "person(0, 0)" );
-
- oss.str("");
- oss << eva;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "person(0, 0)" );
-
- world w;
- w.add_person(adam);
- w.add_person(eva);
- oss.str("");
- oss << w;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "world(3, { person(1, 2), person(2, 2), })" );
-}
-
-#else // No lambdas (trivial test).
-
-int main(void) { return 0; }
-
-#endif
-

Deleted: sandbox/closure/libs/scope_exit/test/world_seq.cpp
==============================================================================
--- sandbox/closure/libs/scope_exit/test/world_seq.cpp 2012-01-14 11:39:58 EST (Sat, 14 Jan 2012)
+++ (empty file)
@@ -1,104 +0,0 @@
-
-#include <boost/scope_exit.hpp>
-#include <boost/foreach.hpp>
-#include <boost/typeof/typeof.hpp>
-#include <boost/typeof/std/vector.hpp>
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
-#define BOOST_TEST_MODULE TestWorldSeq
-#include <boost/test/unit_test.hpp>
-#include <vector>
-#include <iostream>
-#include <sstream>
-
-class person {
- friend class world;
-public:
- typedef unsigned int id_t;
- typedef unsigned int evolution_t;
-
- person(void) : id_(0), evolution_(0) {}
-
- friend std::ostream& operator<<(std::ostream& o, person const& p) {
- return o << "person(" << p.id_ << ", " << p.evolution_ << ")";
- }
-private:
- id_t id_;
- evolution_t evolution_;
-};
-
-BOOST_TYPEOF_REGISTER_TYPE(person)
-
-class world {
-public:
- typedef unsigned int id_t;
-
- world(void) : next_id_(1) {}
-
- void add_person(person const& a_person);
-
- friend std::ostream& operator<<(std::ostream& o, world const& w) {
- o << "world(" << w.next_id_ << ", {";
- BOOST_FOREACH(person const& p, w.persons_) {
- o << " " << p << ", ";
- }
- return o << "})";
- }
-private:
- id_t next_id_;
- std::vector<person> persons_;
-};
-
-BOOST_TYPEOF_REGISTER_TYPE(world)
-
-//[test_world_seq
-void world::add_person(person const& a_person) {
- persons_.push_back(a_person);
-
- // This block must be no-throw.
- person& p = persons_.back();
- person::evolution_t checkpoint = p.evolution_;
- BOOST_SCOPE_EXIT( (checkpoint) (&p) (&persons_) ) { // Sequence, not commas.
- if(checkpoint == p.evolution_) persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
-
- // ...
-
- checkpoint = ++p.evolution_;
-
- // Assign new identifier to the person.
- world::id_t const prev_id = p.id_;
- p.id_ = next_id_++;
- BOOST_SCOPE_EXIT( (checkpoint) (&p) (&next_id_) (prev_id) ) {
- if(checkpoint == p.evolution_) {
- next_id_ = p.id_;
- p.id_ = prev_id;
- }
- } BOOST_SCOPE_EXIT_END
-
- // ...
-
- checkpoint = ++p.evolution_;
-}
-//]
-
-BOOST_AUTO_TEST_CASE( test_world_seq ) {
- person adam, eva;
- std::ostringstream oss;
- oss << adam;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "person(0, 0)" );
-
- oss.str("");
- oss << eva;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "person(0, 0)" );
-
- world w;
- w.add_person(adam);
- w.add_person(eva);
- oss.str("");
- oss << w;
- std::cout << oss.str() << std::endl;
- BOOST_CHECK( oss.str() == "world(3, { person(1, 2), person(2, 2), })" );
-}
-


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