/*
- * Copyright (c) 2000-2020 Samsung Electronics Co., Ltd. All rights reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd. All rights reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <string>
#include <random>
#include <chrono>
+#include <stdexcept>
namespace {
struct MessageA {
BOOST_REQUIRE_MESSAGE(c == 0, "Unexpected number of MessageC: " << c);
}
+NEGATIVE_TEST_CASE(TMM_0070_ThrowingListener)
+{
+ CKM::CommunicationManager<char> mgr;
+
+ bool called[3] = {};
+ mgr.Register<char>([&](const char&) {
+ called[0] = true;
+ });
+ mgr.Register<char>([&](const char&) {
+ called[1] = true;
+ throw std::runtime_error("Everything is awesome!");
+ });
+ mgr.Register<char>([&](const char&) {
+ called[2] = true;
+ });
+
+ BOOST_REQUIRE_THROW(mgr.SendMessage('|'), std::runtime_error);
+ BOOST_REQUIRE_MESSAGE(called[0], "1st listener not called");
+ BOOST_REQUIRE_MESSAGE(called[1], "2nd listener not called");
+ BOOST_REQUIRE_MESSAGE(!called[2], "3rd listener called");
+}
+
BOOST_AUTO_TEST_SUITE_END()