|
Boost-Commit : |
From: daniel_james_at_[hidden]
Date: 2008-04-13 07:29:33
Author: danieljames
Date: 2008-04-13 07:29:33 EDT (Sun, 13 Apr 2008)
New Revision: 44365
URL: http://svn.boost.org/trac/boost/changeset/44365
Log:
Import some of the tests from the old Boost Move library, and convert them to use this one.
Added:
sandbox/move/libs/move/test/const_lvalue_by_ref_fail.cpp
- copied unchanged from r44364, /sandbox/libs/move/test/const_lvalue_by_ref_fail.cpp
sandbox/move/libs/move/test/const_rvalue_by_ref_fail.cpp
- copied unchanged from r44364, /sandbox/libs/move/test/const_rvalue_by_ref_fail.cpp
sandbox/move/libs/move/test/move.cpp
- copied unchanged from r44364, /sandbox/libs/move/test/move.cpp
sandbox/move/libs/move/test/move_test.cpp
- copied, changed from r44354, /sandbox/libs/move/test/move_test.cpp
sandbox/move/libs/move/test/rvalue_by_ref_fail.cpp
- copied unchanged from r44364, /sandbox/libs/move/test/rvalue_by_ref_fail.cpp
sandbox/move/libs/move/test/say.hpp
- copied unchanged from r44364, /sandbox/libs/move/test/say.hpp
sandbox/move/libs/move/test/x.hpp
- copied, changed from r44364, /sandbox/libs/move/test/x.hpp
Text files modified:
sandbox/move/libs/move/test/Jamfile.v2 | 24 ++++++++++++++++++++++--
sandbox/move/libs/move/test/move_test.cpp | 28 ++++++++++++++++++----------
sandbox/move/libs/move/test/x.hpp | 35 +++++++++++++----------------------
3 files changed, 53 insertions(+), 34 deletions(-)
Modified: sandbox/move/libs/move/test/Jamfile.v2
==============================================================================
--- sandbox/move/libs/move/test/Jamfile.v2 (original)
+++ sandbox/move/libs/move/test/Jamfile.v2 2008-04-13 07:29:33 EDT (Sun, 13 Apr 2008)
@@ -1,4 +1,24 @@
import testing ;
project boost/move ;
-run main.cpp /boost/unit_test//boost_unit_test_framework ;
-run no_sfinae_test.cpp /boost/unit_test//boost_unit_test_framework ;
+
+test-suite "move-suite" :
+ [ run main.cpp /boost/unit_test//boost_unit_test_framework ]
+ [ run move.cpp ]
+ [ run move_test.cpp ]
+ [ run no_sfinae_test.cpp /boost/unit_test//boost_unit_test_framework ]
+;
+
+test-suite "move-fail" :
+ [ compile-fail rvalue_by_ref_fail.cpp ]
+ [ compile-fail const_rvalue_by_ref_fail.cpp ]
+ [ compile-fail const_lvalue_by_ref_fail.cpp ]
+;
+
+# Tests from the old version of Boost.Move that haven't been converted:
+#
+# [ compile has_swap.cpp ]
+# [ run move_only.cpp ]
+# [ run move_swap_test.cpp ]
+# [ compile-fail copy_move_only_fail.cpp ]
+#
+# These can be found at https://svn.boost.org/svn/boost/sandbox/libs/move/test/
Copied: sandbox/move/libs/move/test/move_test.cpp (from r44354, /sandbox/libs/move/test/move_test.cpp)
==============================================================================
--- /sandbox/libs/move/test/move_test.cpp (original)
+++ sandbox/move/libs/move/test/move_test.cpp 2008-04-13 07:29:33 EDT (Sun, 13 Apr 2008)
@@ -33,7 +33,6 @@
// Moveable std::string-like type. But look, no implicit copying allowed!
//
class moveable_string
- : public boost::movable<moveable_string>
{
public: // constants
BOOST_STATIC_CONSTANT(
@@ -56,13 +55,24 @@
, str_(0)
{
}
-
- moveable_string(boost::move_from<moveable_string> source)
- : len_(source->len_)
- , str_(source->str_)
+
+ moveable_string(moveable_string const& x)
+ : len_(x.len_),
+ str_(len_ != 0 ? new char[len_ + 1] : 0)
+ {
+ if (str_ != 0)
+ std::strncpy(str_, x.str_, len_);
+
+ // We should never copy the string in these tests.
+ BOOST_ASSERT(false);
+ }
+
+ moveable_string(boost::move_from<moveable_string> x)
+ : len_(x.source.len_)
+ , str_(x.source.str_)
{
- source->len_ = 0;
- source->str_ = 0;
+ x.source.len_ = 0;
+ x.source.str_ = 0;
}
moveable_string(const char* str, std::size_t len = npos)
@@ -74,10 +84,8 @@
}
public: // modifiers
- moveable_string& operator=(boost::move_from<moveable_string> source)
+ moveable_string& operator=(moveable_string rhs)
{
- moveable_string& rhs = *source;
-
clear();
len_ = rhs.len_;
Copied: sandbox/move/libs/move/test/x.hpp (from r44364, /sandbox/libs/move/test/x.hpp)
==============================================================================
--- /sandbox/libs/move/test/x.hpp (original)
+++ sandbox/move/libs/move/test/x.hpp 2008-04-13 07:29:33 EDT (Sun, 13 Apr 2008)
@@ -11,7 +11,7 @@
//
// A sample movable class.
//
-class X : public boost::movable<X>
+class X
{
public: // "Ordinary" stuff
X() : resource(++cnt)
@@ -19,48 +19,39 @@
SAY("X() #" << resource);
}
- // non-const lvalue - copy ctor
- BOOST_LVALUE_COPY_CTOR(
- X, (rhs)(: resource(++cnt)),
+ X(X const& rhs) : resource(++cnt)
{
copy(rhs);
- })
+ }
~X()
{
release();
}
- BOOST_LVALUE_ASSIGN(
- X, (rhs),
- {
- release();
- this->resource = ++cnt;
- copy(rhs);
- return *this;
- })
+ // Assign is declared in the move stuff
public: // Move stuff
- // non-const rvalue - move ctor
+ // move constructor
X(boost::move_from<X> rhs)
- : resource(rhs->resource)
+ : resource(rhs.source.resource)
{
- BOOST_ASSERT(rhs->resource <= cnt); // check for garbage
+ BOOST_ASSERT(rhs.source.resource <= cnt); // check for garbage
SAY("MOVE #" << resource);
BOOST_ASSERT(move_expected);
- rhs->resource = 0;
+ rhs.source.resource = 0;
BOOST_ASSERT(resource);
}
- // non-const rvalue - move assignment
- X& operator=(boost::move_from<X> rhs)
+ // move assignment
+ X& operator=(X rhs)
{
- BOOST_ASSERT(rhs->resource <= cnt); // check for garbage
+ BOOST_ASSERT(rhs.resource <= cnt); // check for garbage
release();
- resource = rhs->resource;
+ resource = rhs.resource;
SAY("MOVE #" << resource);
BOOST_ASSERT(move_expected);
- rhs->resource = 0;
+ rhs.resource = 0;
BOOST_ASSERT(resource);
return *this;
}
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