1 // Copyright (C) 2007-9 Anthony Williams
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #define BOOST_TEST_MODULE Boost.Threads: thread move test suite
8 #include <boost/thread/thread_only.hpp>
9 #include <boost/test/unit_test.hpp>
11 void do_nothing(boost::thread::id
* my_id
)
13 *my_id
=boost::this_thread::get_id();
16 BOOST_AUTO_TEST_CASE(test_move_on_construction
)
18 boost::thread::id the_id
;
19 boost::thread x
=boost::thread(do_nothing
,&the_id
);
20 boost::thread::id x_id
=x
.get_id();
22 BOOST_CHECK_EQUAL(the_id
,x_id
);
25 boost::thread
make_thread(boost::thread::id
* the_id
)
27 return boost::thread(do_nothing
,the_id
);
30 BOOST_AUTO_TEST_CASE(test_move_from_function_return
)
32 boost::thread::id the_id
;
33 boost::thread x
=make_thread(&the_id
);
34 boost::thread::id x_id
=x
.get_id();
36 BOOST_CHECK_EQUAL(the_id
,x_id
);
39 BOOST_AUTO_TEST_CASE(test_move_assign
)
41 boost::thread::id the_id
;
42 boost::thread
x(do_nothing
,&the_id
);
45 boost::thread::id y_id
=y
.get_id();
47 BOOST_CHECK_EQUAL(the_id
,y_id
);