Ticket #2151: enum_test.cpp

File enum_test.cpp, 908 bytes (added by Douglas Gregor, 14 years ago)

Test case

Line 
1// Copyright (C) 2008 Trustees of Indiana University
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// A test of the transmission of enumeration values
8#include <boost/mpi/communicator.hpp>
9#include <boost/mpi/environment.hpp>
10#include <boost/test/minimal.hpp>
11#include <utility>
12
13enum color_t { red, blue };
14
15namespace boost { namespace mpi {
16 template<> struct is_mpi_datatype<color_t> : mpl::true_ { };
17} } // end namespace boost::mpi
18
19int test_main(int argc, char* argv[])
20{
21 using namespace boost::mpi;
22 environment env(argc, argv);
23
24 communicator comm;
25 color_t color = red;
26 if (comm.rank() == 0) {
27 comm.send(1, 0, red);
28 } else {
29 color_t recv_color;
30 comm.recv(0, 0, recv_color);
31 BOOST_CHECK(color == recv_color);
32 }
33
34 return 0;
35}
36