@@ -93,7 +93,7 @@ TEST_CASE("log mismatch when no match", "[handler]") {
93
93
94
94
TEST_CASE (" match and dispatch only one callback" , " [handler]" ) {
95
95
auto callback1 = msg::callback<" cb1" , msg_defn>(
96
- id_match<0x80 >, [& ](msg::const_view<msg_defn>) { CHECK (false ); });
96
+ id_match<0x80 >, [](msg::const_view<msg_defn>) { CHECK (false ); });
97
97
auto callback2 = msg::callback<" cb2" , msg_defn>(
98
98
id_match<0x44 >, [](msg::const_view<msg_defn>) { dispatched = true ; });
99
99
auto const msg = std::array{0x4400ba11u , 0x0042d00du };
@@ -107,6 +107,25 @@ TEST_CASE("match and dispatch only one callback", "[handler]") {
107
107
CHECK (dispatched);
108
108
}
109
109
110
+ TEST_CASE (" dispatch all callbacks that match" , " [handler]" ) {
111
+ int count{};
112
+
113
+ auto callback1 = msg::callback<" cb1" , msg_defn>(
114
+ id_match<0x80 >, [](msg::const_view<msg_defn>) { CHECK (false ); });
115
+ auto callback2 = msg::callback<" cb2" , msg_defn>(
116
+ id_match<0x44 >, [&](msg::const_view<msg_defn>) { ++count; });
117
+ auto callback3 = msg::callback<" cb3" , msg_defn>(
118
+ id_match<0x44 >, [&](msg::const_view<msg_defn>) { ++count; });
119
+ auto const msg = std::array{0x4400ba11u , 0x0042d00du };
120
+
121
+ auto callbacks = stdx::make_tuple (callback1, callback2, callback3);
122
+ static auto handler =
123
+ msg::handler<decltype (callbacks), decltype (msg)>{callbacks};
124
+
125
+ CHECK (handler.handle (msg));
126
+ CHECK (count == 2 );
127
+ }
128
+
110
129
namespace {
111
130
template <typename T>
112
131
using uint8_view =
0 commit comments