Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame^] | 3 | * Copyright (c) 2013-2016 Regents of the University of California. |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 6 | * |
| 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include "util/signal.hpp" |
| 23 | |
| 24 | #include "boost-test.hpp" |
| 25 | |
| 26 | namespace ndn { |
| 27 | namespace util { |
| 28 | namespace signal { |
| 29 | namespace tests { |
| 30 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame^] | 31 | BOOST_AUTO_TEST_SUITE(Util) |
| 32 | BOOST_AUTO_TEST_SUITE(TestSignal) |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 33 | |
| 34 | class SignalOwner0 |
| 35 | { |
| 36 | public: |
| 37 | Signal<SignalOwner0> sig; |
| 38 | |
| 39 | public: |
| 40 | DECLARE_SIGNAL_EMIT(sig) |
| 41 | |
| 42 | bool |
| 43 | isSigEmpty() |
| 44 | { |
| 45 | return sig.isEmpty(); |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | BOOST_AUTO_TEST_CASE(ZeroSlot) |
| 50 | { |
| 51 | SignalOwner0 so; |
| 52 | BOOST_CHECK_NO_THROW(so.emitSignal(sig)); |
| 53 | } |
| 54 | |
| 55 | BOOST_AUTO_TEST_CASE(TwoListeners) |
| 56 | { |
| 57 | SignalOwner0 so; |
| 58 | |
| 59 | int hit1 = 0, hit2 = 0; |
| 60 | so.sig.connect([&hit1] { ++hit1; }); |
| 61 | so.sig.connect([&hit2] { ++hit2; }); |
| 62 | |
| 63 | so.emitSignal(sig); |
| 64 | |
| 65 | BOOST_CHECK_EQUAL(hit1, 1); |
| 66 | BOOST_CHECK_EQUAL(hit2, 1); |
| 67 | } |
| 68 | |
Junxiao Shi | 018e30d | 2014-12-25 19:42:35 -0700 | [diff] [blame] | 69 | class SignalOwner1 |
| 70 | { |
| 71 | public: |
| 72 | Signal<SignalOwner1, int> sig; |
| 73 | |
| 74 | protected: |
| 75 | DECLARE_SIGNAL_EMIT(sig) |
| 76 | }; |
| 77 | |
| 78 | class SignalEmitter1 : public SignalOwner1 |
| 79 | { |
| 80 | public: |
| 81 | void |
| 82 | emitTestSignal() |
| 83 | { |
| 84 | this->emitSignal(sig, 8106); |
| 85 | } |
| 86 | }; |
| 87 | |
| 88 | BOOST_AUTO_TEST_CASE(OneArgument) |
| 89 | { |
| 90 | SignalEmitter1 se; |
| 91 | |
| 92 | int hit = 0; |
| 93 | se.sig.connect([&hit] (int a) { |
| 94 | ++hit; |
| 95 | BOOST_CHECK_EQUAL(a, 8106); |
| 96 | }); |
| 97 | se.emitTestSignal(); |
| 98 | |
| 99 | BOOST_CHECK_EQUAL(hit, 1); |
| 100 | } |
| 101 | |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 102 | BOOST_AUTO_TEST_CASE(TwoArguments) |
| 103 | { |
| 104 | Signal<std::remove_pointer<decltype(this)>::type, int, int> sig; |
| 105 | |
| 106 | int hit = 0; |
| 107 | sig.connect([&hit] (int a, int b) { |
| 108 | ++hit; |
| 109 | BOOST_CHECK_EQUAL(a, 21); |
| 110 | BOOST_CHECK_EQUAL(b, 22); |
| 111 | }); |
| 112 | sig(21, 22); |
| 113 | |
| 114 | BOOST_CHECK_EQUAL(hit, 1); |
| 115 | } |
| 116 | |
| 117 | class RefObject |
| 118 | { |
| 119 | public: |
| 120 | RefObject() |
| 121 | { |
| 122 | } |
| 123 | |
| 124 | RefObject(const RefObject& other) |
| 125 | { |
| 126 | ++s_copyCount; |
| 127 | } |
| 128 | |
| 129 | public: |
| 130 | static int s_copyCount; |
| 131 | }; |
| 132 | int RefObject::s_copyCount = 0; |
| 133 | |
| 134 | // Signal passes arguments by reference, |
| 135 | // but it also allows a handler that accept arguments by value |
| 136 | BOOST_AUTO_TEST_CASE(HandlerByVal) |
| 137 | { |
| 138 | RefObject refObject; |
| 139 | RefObject::s_copyCount = 0; |
| 140 | |
| 141 | Signal<std::remove_pointer<decltype(this)>::type, RefObject> sig; |
| 142 | sig.connect([] (RefObject ro) {}); |
| 143 | sig(refObject); |
| 144 | |
| 145 | BOOST_CHECK_EQUAL(RefObject::s_copyCount, 1); |
| 146 | } |
| 147 | |
| 148 | // Signal passes arguments by reference, and no copying |
| 149 | // is necessary when handler accepts arguments by reference |
| 150 | BOOST_AUTO_TEST_CASE(HandlerByRef) |
| 151 | { |
| 152 | RefObject refObject; |
| 153 | RefObject::s_copyCount = 0; |
| 154 | |
| 155 | Signal<std::remove_pointer<decltype(this)>::type, RefObject> sig; |
| 156 | sig.connect([] (const RefObject& ro) {}); |
| 157 | sig(refObject); |
| 158 | |
| 159 | BOOST_CHECK_EQUAL(RefObject::s_copyCount, 0); |
| 160 | } |
| 161 | |
| 162 | BOOST_AUTO_TEST_CASE(ManualDisconnect) |
| 163 | { |
| 164 | SignalOwner0 so; |
| 165 | |
| 166 | int hit = 0; |
| 167 | Connection c1 = so.sig.connect([&hit] { ++hit; }); |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 168 | BOOST_CHECK_EQUAL(c1.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 169 | |
| 170 | so.emitSignal(sig); |
| 171 | BOOST_CHECK_EQUAL(hit, 1); // handler called |
| 172 | |
| 173 | Connection c2 = c1; // make a copy |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 174 | BOOST_CHECK_EQUAL(c2.isConnected(), true); |
| 175 | BOOST_CHECK_EQUAL(c1.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 176 | c2.disconnect(); |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 177 | BOOST_CHECK_EQUAL(c2.isConnected(), false); |
| 178 | BOOST_CHECK_EQUAL(c1.isConnected(), false); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 179 | so.emitSignal(sig); |
| 180 | BOOST_CHECK_EQUAL(hit, 1); // handler not called |
| 181 | |
| 182 | BOOST_CHECK_NO_THROW(c2.disconnect()); |
| 183 | BOOST_CHECK_NO_THROW(c1.disconnect()); |
| 184 | } |
| 185 | |
| 186 | BOOST_AUTO_TEST_CASE(ManualDisconnectDestructed) |
| 187 | { |
Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 188 | auto so = make_unique<SignalOwner0>(); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 189 | |
| 190 | int hit = 0; |
| 191 | Connection connection = so->sig.connect([&hit] { ++hit; }); |
| 192 | |
| 193 | so->emitSignal(sig); |
| 194 | BOOST_CHECK_EQUAL(hit, 1); // handler called |
| 195 | |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 196 | BOOST_CHECK_EQUAL(connection.isConnected(), true); |
Junxiao Shi | bbb2435 | 2015-02-28 21:23:51 -0700 | [diff] [blame] | 197 | so.reset(); // destruct Signal |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 198 | BOOST_CHECK_EQUAL(connection.isConnected(), false); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 199 | BOOST_CHECK_NO_THROW(connection.disconnect()); |
| 200 | } |
| 201 | |
| 202 | BOOST_AUTO_TEST_CASE(AutoDisconnect) |
| 203 | { |
| 204 | SignalOwner0 so; |
| 205 | |
| 206 | int hit = 0; |
| 207 | { |
| 208 | ScopedConnection sc = so.sig.connect([&hit] { ++hit; }); |
| 209 | |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 210 | BOOST_CHECK_EQUAL(sc.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 211 | so.emitSignal(sig); |
| 212 | BOOST_CHECK_EQUAL(hit, 1); // handler called |
| 213 | |
| 214 | // sc goes out of scope, disconnecting |
| 215 | } |
| 216 | |
| 217 | so.emitSignal(sig); |
| 218 | BOOST_CHECK_EQUAL(hit, 1); // handler not called |
| 219 | } |
| 220 | |
| 221 | BOOST_AUTO_TEST_CASE(AutoDisconnectAssign) |
| 222 | { |
| 223 | SignalOwner0 so; |
| 224 | |
| 225 | int hit1 = 0, hit2 = 0; |
| 226 | ScopedConnection sc = so.sig.connect([&hit1] { ++hit1; }); |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 227 | BOOST_CHECK_EQUAL(sc.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 228 | |
| 229 | so.emitSignal(sig); |
| 230 | BOOST_CHECK_EQUAL(hit1, 1); // handler1 called |
| 231 | |
| 232 | sc = so.sig.connect([&hit2] { ++hit2; }); // handler1 is disconnected |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 233 | BOOST_CHECK_EQUAL(sc.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 234 | |
| 235 | so.emitSignal(sig); |
| 236 | BOOST_CHECK_EQUAL(hit1, 1); // handler1 not called |
| 237 | BOOST_CHECK_EQUAL(hit2, 1); // handler2 called |
| 238 | } |
| 239 | |
| 240 | BOOST_AUTO_TEST_CASE(AutoDisconnectAssignSame) |
| 241 | { |
| 242 | SignalOwner0 so; |
| 243 | |
| 244 | int hit = 0; |
| 245 | Connection c1 = so.sig.connect([&hit] { ++hit; }); |
| 246 | |
| 247 | ScopedConnection sc(c1); |
| 248 | so.emitSignal(sig); |
| 249 | BOOST_CHECK_EQUAL(hit, 1); // handler called |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 250 | BOOST_CHECK_EQUAL(c1.isConnected(), true); |
| 251 | BOOST_CHECK_EQUAL(sc.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 252 | |
| 253 | sc = c1; // assign same connection |
| 254 | so.emitSignal(sig); |
| 255 | BOOST_CHECK_EQUAL(hit, 2); // handler called |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 256 | BOOST_CHECK_EQUAL(c1.isConnected(), true); |
| 257 | BOOST_CHECK_EQUAL(sc.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 258 | |
| 259 | Connection c2 = c1; |
| 260 | sc = c2; // assign a copy of same connection |
| 261 | so.emitSignal(sig); |
| 262 | BOOST_CHECK_EQUAL(hit, 3); // handler called |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 263 | BOOST_CHECK_EQUAL(c1.isConnected(), true); |
| 264 | BOOST_CHECK_EQUAL(c2.isConnected(), true); |
| 265 | BOOST_CHECK_EQUAL(sc.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | BOOST_AUTO_TEST_CASE(AutoDisconnectRelease) |
| 269 | { |
| 270 | SignalOwner0 so; |
| 271 | |
| 272 | int hit = 0; |
| 273 | { |
| 274 | ScopedConnection sc = so.sig.connect([&hit] { ++hit; }); |
| 275 | |
| 276 | so.emitSignal(sig); |
| 277 | BOOST_CHECK_EQUAL(hit, 1); // handler called |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 278 | BOOST_CHECK_EQUAL(sc.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 279 | |
| 280 | sc.release(); |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 281 | BOOST_CHECK_EQUAL(sc.isConnected(), false); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 282 | // sc goes out of scope, but not disconnecting |
| 283 | } |
| 284 | |
| 285 | so.emitSignal(sig); |
| 286 | BOOST_CHECK_EQUAL(hit, 2); // handler called |
| 287 | } |
| 288 | |
| 289 | BOOST_AUTO_TEST_CASE(AutoDisconnectMove) |
| 290 | { |
| 291 | SignalOwner0 so; |
| 292 | unique_ptr<ScopedConnection> sc2; |
| 293 | |
| 294 | int hit = 0; |
| 295 | { |
| 296 | ScopedConnection sc = so.sig.connect([&hit] { ++hit; }); |
| 297 | |
| 298 | so.emitSignal(sig); |
| 299 | BOOST_CHECK_EQUAL(hit, 1); // handler called |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 300 | BOOST_CHECK_EQUAL(sc.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 301 | |
| 302 | sc2.reset(new ScopedConnection(std::move(sc))); |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 303 | BOOST_CHECK_EQUAL(sc.isConnected(), false); |
| 304 | BOOST_CHECK_EQUAL(sc2->isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 305 | |
| 306 | // sc goes out of scope, but not disconnecting |
| 307 | } |
| 308 | |
| 309 | so.emitSignal(sig); |
| 310 | BOOST_CHECK_EQUAL(hit, 2); // handler called |
| 311 | } |
| 312 | |
Junxiao Shi | ecc57b5 | 2015-01-01 10:47:08 -0700 | [diff] [blame] | 313 | BOOST_AUTO_TEST_CASE(ConnectSingleShot) |
| 314 | { |
| 315 | SignalOwner0 so; |
| 316 | |
| 317 | int hit = 0; |
| 318 | so.sig.connectSingleShot([&hit] { ++hit; }); |
| 319 | |
| 320 | so.emitSignal(sig); |
| 321 | BOOST_CHECK_EQUAL(hit, 1); // handler called |
| 322 | |
| 323 | so.emitSignal(sig); |
| 324 | BOOST_CHECK_EQUAL(hit, 1); // handler not called |
| 325 | } |
| 326 | |
| 327 | BOOST_AUTO_TEST_CASE(ConnectSingleShotDisconnected) |
| 328 | { |
| 329 | SignalOwner0 so; |
| 330 | |
| 331 | int hit = 0; |
| 332 | Connection conn = so.sig.connectSingleShot([&hit] { ++hit; }); |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 333 | BOOST_CHECK_EQUAL(conn.isConnected(), true); |
Junxiao Shi | ecc57b5 | 2015-01-01 10:47:08 -0700 | [diff] [blame] | 334 | conn.disconnect(); |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 335 | BOOST_CHECK_EQUAL(conn.isConnected(), false); |
Junxiao Shi | ecc57b5 | 2015-01-01 10:47:08 -0700 | [diff] [blame] | 336 | |
| 337 | so.emitSignal(sig); |
| 338 | BOOST_CHECK_EQUAL(hit, 0); // handler not called |
| 339 | } |
| 340 | |
| 341 | BOOST_AUTO_TEST_CASE(ConnectSingleShot1) |
| 342 | { |
| 343 | SignalEmitter1 se; |
| 344 | |
| 345 | int hit = 0; |
| 346 | se.sig.connectSingleShot([&hit] (int) { ++hit; }); |
| 347 | |
| 348 | se.emitTestSignal(); |
| 349 | BOOST_CHECK_EQUAL(hit, 1); // handler called |
| 350 | |
| 351 | se.emitTestSignal(); |
| 352 | BOOST_CHECK_EQUAL(hit, 1); // handler not called |
| 353 | } |
| 354 | |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 355 | BOOST_AUTO_TEST_CASE(ConnectInHandler) |
| 356 | { |
| 357 | SignalOwner0 so; |
| 358 | |
| 359 | int hit1 = 0, hit2 = 0; bool hasHandler2 = false; |
| 360 | so.sig.connect([&] { |
| 361 | ++hit1; |
| 362 | if (!hasHandler2) { |
| 363 | so.sig.connect([&] { ++hit2; }); |
| 364 | hasHandler2 = true; |
| 365 | } |
| 366 | }); |
| 367 | |
| 368 | so.emitSignal(sig); |
| 369 | BOOST_CHECK_EQUAL(hit1, 1); // handler1 called |
| 370 | BOOST_CHECK_EQUAL(hit2, 0); // handler2 not called |
| 371 | |
| 372 | // new subscription takes effect |
| 373 | so.emitSignal(sig); |
| 374 | BOOST_CHECK_EQUAL(hit1, 2); // handler1 called |
| 375 | BOOST_CHECK_EQUAL(hit2, 1); // handler2 called |
| 376 | } |
| 377 | |
| 378 | BOOST_AUTO_TEST_CASE(DisconnectSelfInHandler) |
| 379 | { |
| 380 | SignalOwner0 so; |
| 381 | |
| 382 | int hit = 0; |
| 383 | Connection connection; |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 384 | BOOST_CHECK_EQUAL(connection.isConnected(), false); |
Davide Pesavento | be7804f | 2015-10-23 00:53:47 +0200 | [diff] [blame] | 385 | connection = so.sig.connect([&so, &connection, &hit] { |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 386 | ++hit; |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 387 | BOOST_CHECK_EQUAL(connection.isConnected(), true); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 388 | connection.disconnect(); |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 389 | BOOST_CHECK_EQUAL(connection.isConnected(), false); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 390 | BOOST_CHECK_EQUAL(so.isSigEmpty(), false); // disconnecting hasn't taken effect |
Davide Pesavento | be7804f | 2015-10-23 00:53:47 +0200 | [diff] [blame] | 391 | }); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 392 | |
| 393 | so.emitSignal(sig); |
| 394 | BOOST_CHECK_EQUAL(hit, 1); // handler called |
Chengyu Fan | f46482c | 2015-02-03 16:55:53 -0700 | [diff] [blame] | 395 | BOOST_CHECK_EQUAL(connection.isConnected(), false); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 396 | |
| 397 | // disconnecting takes effect |
| 398 | BOOST_CHECK_EQUAL(so.isSigEmpty(), true); |
| 399 | so.emitSignal(sig); |
| 400 | BOOST_CHECK_EQUAL(hit, 1); // handler not called |
| 401 | } |
| 402 | |
| 403 | BOOST_AUTO_TEST_CASE(ThrowInHandler) |
| 404 | { |
| 405 | SignalOwner0 so; |
| 406 | |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 407 | struct HandlerError : public std::exception |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 408 | { |
| 409 | }; |
| 410 | |
| 411 | int hit = 0; |
| 412 | so.sig.connect([&] { |
| 413 | ++hit; |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 414 | BOOST_THROW_EXCEPTION(HandlerError()); |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 415 | }); |
| 416 | |
| 417 | BOOST_CHECK_THROW(so.emitSignal(sig), HandlerError); |
| 418 | BOOST_CHECK_EQUAL(hit, 1); // handler called |
| 419 | |
| 420 | BOOST_CHECK_THROW(so.emitSignal(sig), HandlerError); |
| 421 | BOOST_CHECK_EQUAL(hit, 2); // handler called |
| 422 | } |
| 423 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame^] | 424 | BOOST_AUTO_TEST_SUITE_END() // TestSignal |
| 425 | BOOST_AUTO_TEST_SUITE_END() // Util |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 426 | |
| 427 | } // namespace tests |
| 428 | } // namespace signal |
| 429 | } // namespace util |
| 430 | } // namespace ndn |