2 // serial_port_base.cpp
3 // ~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 // Disable autolinking for unit tests.
13 #if !defined(BOOST_ALL_NO_LIB)
14 #define BOOST_ALL_NO_LIB 1
15 #endif // !defined(BOOST_ALL_NO_LIB)
17 // Test that header file is self-contained.
18 #include <boost/asio/serial_port_base.hpp>
20 #include <boost/asio/io_context.hpp>
21 #include <boost/asio/serial_port.hpp>
22 #include "unit_test.hpp"
24 //------------------------------------------------------------------------------
26 // serial_port_base_compile test
27 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 // Verify that all options and and their accessors compile. Runtime failures are
31 namespace serial_port_base_compile
{
35 #if defined(BOOST_ASIO_HAS_SERIAL_PORT)
36 using namespace boost::asio
;
41 serial_port
port(ioc
);
45 serial_port_base::baud_rate
baud_rate1(9600);
46 port
.set_option(baud_rate1
);
47 serial_port_base::baud_rate baud_rate2
;
48 port
.get_option(baud_rate2
);
49 (void)static_cast<unsigned int>(baud_rate2
.value());
51 // flow_control class.
53 serial_port_base::flow_control
flow_control1(
54 serial_port_base::flow_control::none
);
55 port
.set_option(flow_control1
);
56 serial_port_base::flow_control flow_control2
;
57 port
.get_option(flow_control2
);
58 (void)static_cast<serial_port_base::flow_control::type
>(
59 flow_control2
.value());
63 serial_port_base::parity
parity1(serial_port_base::parity::none
);
64 port
.set_option(parity1
);
65 serial_port_base::parity parity2
;
66 port
.get_option(parity2
);
67 (void)static_cast<serial_port_base::parity::type
>(parity2
.value());
71 serial_port_base::stop_bits
stop_bits1(serial_port_base::stop_bits::one
);
72 port
.set_option(stop_bits1
);
73 serial_port_base::stop_bits stop_bits2
;
74 port
.get_option(stop_bits2
);
75 (void)static_cast<serial_port_base::stop_bits::type
>(stop_bits2
.value());
77 // character_size class.
79 serial_port_base::character_size
character_size1(8);
80 port
.set_option(character_size1
);
81 serial_port_base::character_size character_size2
;
82 port
.get_option(character_size2
);
83 (void)static_cast<unsigned int>(character_size2
.value());
85 catch (std::exception
&)
88 #endif // defined(BOOST_ASIO_HAS_SERIAL_PORT)
91 } // namespace serial_port_base_compile
93 //------------------------------------------------------------------------------
98 BOOST_ASIO_TEST_CASE(serial_port_base_compile::test
)