Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49124 - trunk/libs/thread/test
From: anthony_at_[hidden]
Date: 2008-10-03 03:02:57


Author: anthonyw
Date: 2008-10-03 03:02:57 EDT (Fri, 03 Oct 2008)
New Revision: 49124
URL: http://svn.boost.org/trac/boost/changeset/49124

Log:
Enhanced thread move tests
Text files modified:
   trunk/libs/thread/test/test_thread_move.cpp | 40 +++++++++++++++++++++++++++++++---------
   1 files changed, 31 insertions(+), 9 deletions(-)

Modified: trunk/libs/thread/test/test_thread_move.cpp
==============================================================================
--- trunk/libs/thread/test/test_thread_move.cpp (original)
+++ trunk/libs/thread/test/test_thread_move.cpp 2008-10-03 03:02:57 EDT (Fri, 03 Oct 2008)
@@ -5,38 +5,59 @@
 #include <boost/thread/thread.hpp>
 #include <boost/test/unit_test.hpp>
 
-void do_nothing()
-{}
+void do_nothing(boost::thread::id* my_id)
+{
+ *my_id=boost::this_thread::get_id();
+}
 
 void test_move_on_construction()
 {
- boost::thread x=boost::thread(do_nothing);
+ boost::thread::id the_id;
+ boost::thread x=boost::thread(do_nothing,&the_id);
+ boost::thread::id x_id=x.get_id();
     x.join();
+ BOOST_CHECK_EQUAL(the_id,x_id);
 }
 
-boost::thread make_thread()
+boost::thread make_thread(boost::thread::id* the_id)
 {
- return boost::thread(do_nothing);
+ return boost::thread(do_nothing,the_id);
 }
 
 void test_move_from_function_return()
 {
- boost::thread x=make_thread();
+ boost::thread::id the_id;
+ boost::thread x=make_thread(&the_id);
+ boost::thread::id x_id=x.get_id();
     x.join();
+ BOOST_CHECK_EQUAL(the_id,x_id);
 }
 
-boost::thread make_thread_return_lvalue()
+boost::thread make_thread_return_lvalue(boost::thread::id* the_id)
 {
- boost::thread t(do_nothing);
+ boost::thread t(do_nothing,the_id);
     return boost::move(t);
 }
 
 void test_move_from_function_return_lvalue()
 {
- boost::thread x=make_thread_return_lvalue();
+ boost::thread::id the_id;
+ boost::thread x=make_thread_return_lvalue(&the_id);
+ boost::thread::id x_id=x.get_id();
     x.join();
+ BOOST_CHECK_EQUAL(the_id,x_id);
 }
 
+void test_move_assign()
+{
+ boost::thread::id the_id;
+ boost::thread x(do_nothing,&the_id);
+ boost::thread y;
+ y=boost::move(x);
+ boost::thread::id y_id=y.get_id();
+ y.join();
+ BOOST_CHECK_EQUAL(the_id,y_id);
+}
 
 boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
 {
@@ -46,5 +67,6 @@
     test->add(BOOST_TEST_CASE(test_move_on_construction));
     test->add(BOOST_TEST_CASE(test_move_from_function_return));
     test->add(BOOST_TEST_CASE(test_move_from_function_return_lvalue));
+ test->add(BOOST_TEST_CASE(test_move_assign));
     return test;
 }


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