@@ -101,6 +101,54 @@ class saved_handler_test : public unit_test::suite
101101 }
102102 };
103103
104+ class throwing_cancellation_slot
105+ {
106+ public:
107+ throwing_cancellation_slot ()
108+ {
109+ }
110+
111+ template <typename CancellationHandler, typename ... Args>
112+ CancellationHandler& emplace (Args&&...)
113+ {
114+ BOOST_THROW_EXCEPTION (std::exception{});
115+ }
116+
117+ template <typename CancellationHandler>
118+ CancellationHandler& assign (CancellationHandler&&)
119+ {
120+ BOOST_THROW_EXCEPTION (std::exception{});
121+ }
122+
123+ void clear ()
124+ {
125+ }
126+
127+ bool is_connected () const noexcept
128+ {
129+ return true ;
130+ }
131+
132+ bool has_handler () const noexcept
133+ {
134+ return false ;
135+ }
136+
137+ friend constexpr bool operator ==(
138+ const throwing_cancellation_slot&,
139+ const throwing_cancellation_slot&) noexcept
140+ {
141+ return false ;
142+ }
143+
144+ friend constexpr bool operator !=(
145+ const throwing_cancellation_slot&,
146+ const throwing_cancellation_slot&) noexcept
147+ {
148+ return false ;
149+ }
150+ };
151+
104152 void
105153 testSavedHandler ()
106154 {
@@ -198,7 +246,7 @@ class saved_handler_test : public unit_test::suite
198246 net::cancellation_signal sig;
199247
200248 try
201- {
249+ {
202250 sh.emplace (
203251 net::bind_cancellation_slot (
204252 sig.slot (),
@@ -212,6 +260,23 @@ class saved_handler_test : public unit_test::suite
212260 BEAST_EXPECT (!sig.slot ().has_handler ());
213261 BEAST_EXPECT (! sh.has_value ());
214262 }
263+ {
264+ saved_handler sh;
265+
266+ try
267+ {
268+ sh.emplace (
269+ net::bind_cancellation_slot (
270+ throwing_cancellation_slot (),
271+ unhandler{}));
272+ fail ();
273+ }
274+ catch (std::exception const &)
275+ {
276+ pass ();
277+ }
278+ BEAST_EXPECT (! sh.has_value ());
279+ }
215280 }
216281
217282 void
0 commit comments