1 | // |
2 | // signal_set.cpp |
3 | // ~~~~~~~~~~~~~~ |
4 | // |
5 | // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
6 | // |
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
9 | // |
10 | |
11 | // Disable autolinking for unit tests. |
12 | #if !defined(BOOST_ALL_NO_LIB) |
13 | #define BOOST_ALL_NO_LIB 1 |
14 | #endif // !defined(BOOST_ALL_NO_LIB) |
15 | |
16 | // Test that header file is self-contained. |
17 | #include <boost/asio/signal_set.hpp> |
18 | |
19 | #include "archetypes/async_result.hpp" |
20 | #include <boost/asio/io_service.hpp> |
21 | #include "unit_test.hpp" |
22 | |
23 | //------------------------------------------------------------------------------ |
24 | |
25 | // signal_set_compile test |
26 | // ~~~~~~~~~~~~~~~~~~~~~~~ |
27 | // The following test checks that all public member functions on the class |
28 | // signal_set compile and link correctly. Runtime failures are ignored. |
29 | |
30 | namespace signal_set_compile { |
31 | |
32 | void signal_handler(const boost::system::error_code&, int) |
33 | { |
34 | } |
35 | |
36 | void test() |
37 | { |
38 | using namespace boost::asio; |
39 | |
40 | try |
41 | { |
42 | io_service ios; |
43 | archetypes::lazy_handler lazy; |
44 | boost::system::error_code ec; |
45 | |
46 | // basic_signal_set constructors. |
47 | |
48 | signal_set set1(ios); |
49 | signal_set set2(ios, 1); |
50 | signal_set set3(ios, 1, 2); |
51 | signal_set set4(ios, 1, 2, 3); |
52 | |
53 | // basic_io_object functions. |
54 | |
55 | io_service& ios_ref = set1.get_io_service(); |
56 | (void)ios_ref; |
57 | |
58 | // basic_signal_set functions. |
59 | |
60 | set1.add(signal_number: 1); |
61 | set1.add(signal_number: 1, ec); |
62 | |
63 | set1.remove(signal_number: 1); |
64 | set1.remove(signal_number: 1, ec); |
65 | |
66 | set1.clear(); |
67 | set1.clear(ec); |
68 | |
69 | set1.cancel(); |
70 | set1.cancel(ec); |
71 | |
72 | set1.async_wait(handler: &signal_handler); |
73 | int i = set1.async_wait(handler&: lazy); |
74 | (void)i; |
75 | } |
76 | catch (std::exception&) |
77 | { |
78 | } |
79 | } |
80 | |
81 | } // namespace signal_set_compile |
82 | |
83 | //------------------------------------------------------------------------------ |
84 | |
85 | BOOST_ASIO_TEST_SUITE |
86 | ( |
87 | "signal_set" , |
88 | BOOST_ASIO_TEST_CASE(signal_set_compile::test) |
89 | ) |
90 | |