• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // operation_state.cpp
3 // ~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 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/execution/operation_state.hpp>
18 
19 #include <string>
20 #include <boost/system/error_code.hpp>
21 #include "../unit_test.hpp"
22 
23 struct not_an_operation_state_1
24 {
25 };
26 
27 struct not_an_operation_state_2
28 {
startnot_an_operation_state_229   void start()
30   {
31   }
32 };
33 
34 namespace boost {
35 namespace asio {
36 namespace traits {
37 
38 #if !defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
39 
40 template <>
41 struct start_member<not_an_operation_state_2>
42 {
43   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
44   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
45   typedef void result_type;
46 };
47 
48 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
49 
50 } // namespace traits
51 } // namespace asio
52 } // namespace boost
53 
54 struct operation_state
55 {
startoperation_state56   void start() BOOST_ASIO_NOEXCEPT
57   {
58   }
59 };
60 
61 namespace boost {
62 namespace asio {
63 namespace traits {
64 
65 #if !defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
66 
67 template <>
68 struct start_member<operation_state>
69 {
70   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
71   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
72   typedef void result_type;
73 };
74 
75 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
76 
77 } // namespace traits
78 } // namespace asio
79 } // namespace boost
80 
is_operation_state_test()81 void is_operation_state_test()
82 {
83   BOOST_ASIO_CHECK((
84       !boost::asio::execution::is_operation_state<
85         void
86       >::value));
87 
88   BOOST_ASIO_CHECK((
89       !boost::asio::execution::is_operation_state<
90         not_an_operation_state_1
91       >::value));
92 
93   BOOST_ASIO_CHECK((
94       !boost::asio::execution::is_operation_state<
95         not_an_operation_state_2
96       >::value));
97 
98   BOOST_ASIO_CHECK((
99       boost::asio::execution::is_operation_state<
100         operation_state
101       >::value));
102 }
103 
104 BOOST_ASIO_TEST_SUITE
105 (
106   "operation_state",
107   BOOST_ASIO_TEST_CASE(is_operation_state_test)
108 )
109