]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright (C) 2005, 2006 Douglas Gregor. |
2 | ||
3 | // Use, modification and distribution is subject to the Boost Software | |
4 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
5 | // http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | ||
8 | // a test of pointer serialization | |
9 | #include <boost/mpi.hpp> | |
7c673cae FG |
10 | #include <boost/serialization/shared_ptr.hpp> |
11 | ||
92f5a8d4 TL |
12 | #define BOOST_TEST_MODULE mpi_pointer |
13 | #include <boost/test/included/unit_test.hpp> | |
14 | ||
7c673cae FG |
15 | class A |
16 | { | |
17 | public: | |
18 | int i; | |
19 | template<class Archive> | |
20 | void serialize(Archive & ar, const unsigned int version) | |
21 | { | |
22 | ar & i; | |
23 | } | |
24 | }; | |
25 | ||
92f5a8d4 | 26 | BOOST_AUTO_TEST_CASE(pointer) |
7c673cae | 27 | { |
92f5a8d4 | 28 | boost::mpi::environment env; |
7c673cae FG |
29 | boost::mpi::communicator world; |
30 | ||
92f5a8d4 | 31 | if (world.rank() == 0) { |
7c673cae FG |
32 | boost::shared_ptr<A> p(new A); |
33 | p->i = 42; | |
34 | world.send(1, 0, p); | |
92f5a8d4 | 35 | } else if (world.rank() == 1) { |
7c673cae FG |
36 | boost::shared_ptr<A> p; |
37 | world.recv(0, 0, p); | |
38 | std::cout << p->i << std::endl; | |
39 | BOOST_CHECK(p->i==42); | |
40 | } | |
7c673cae FG |
41 | } |
42 |