]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/test_thread_move.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / thread / test / test_thread_move.cpp
1 // Copyright (C) 2007-9 Anthony Williams
2 //
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)
5
6 #define BOOST_TEST_MODULE Boost.Threads: thread move test suite
7
8 #include <boost/thread/thread_only.hpp>
9 #include <boost/test/unit_test.hpp>
10
11 void do_nothing(boost::thread::id* my_id)
12 {
13 *my_id=boost::this_thread::get_id();
14 }
15
16 BOOST_AUTO_TEST_CASE(test_move_on_construction)
17 {
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();
21 x.join();
22 BOOST_CHECK_EQUAL(the_id,x_id);
23 }
24
25 boost::thread make_thread(boost::thread::id* the_id)
26 {
27 return boost::thread(do_nothing,the_id);
28 }
29
30 BOOST_AUTO_TEST_CASE(test_move_from_function_return)
31 {
32 boost::thread::id the_id;
33 boost::thread x=make_thread(&the_id);
34 boost::thread::id x_id=x.get_id();
35 x.join();
36 BOOST_CHECK_EQUAL(the_id,x_id);
37 }
38
39 BOOST_AUTO_TEST_CASE(test_move_assign)
40 {
41 boost::thread::id the_id;
42 boost::thread x(do_nothing,&the_id);
43 boost::thread y;
44 y=boost::move(x);
45 boost::thread::id y_id=y.get_id();
46 y.join();
47 BOOST_CHECK_EQUAL(the_id,y_id);
48 }
49
50