@@ -34,6 +34,8 @@ using msg_defn =
34
34
message<" test_msg" , opcode_field, sub_opcode_field, field_3, field_4>;
35
35
using test_msg = owning<msg_defn>;
36
36
37
+ using callback_t = auto (*)(test_msg const &) -> bool ;
38
+
37
39
template <auto N> using bitset = stdx::bitset<N, std::uint32_t >;
38
40
39
41
bitset<32 > callbacks_called{};
@@ -45,7 +47,7 @@ TEST_CASE("create empty handler", "[indexed_handler]") {
45
47
msg::indices{msg::index{
46
48
opcode_field{}, lookup::make (CX_VALUE (
47
49
lookup::input<std::uint32_t , bitset<32 >>{}))}},
48
- std::array<void (*)(test_msg const &) , 0 >{}};
50
+ std::array<callback_t , 0 >{}};
49
51
}
50
52
51
53
TEST_CASE (" create handler with one index and callback" , " [indexed_handler]" ) {
@@ -56,8 +58,10 @@ TEST_CASE("create handler with one index and callback", "[indexed_handler]") {
56
58
lookup::make (CX_VALUE (lookup::input<std::uint32_t , bitset<32 >, 1 >{
57
59
bitset<32 >{}, std::array{lookup::entry{
58
60
42u , bitset<32 >{stdx::place_bits, 0 }}}}))}},
59
- std::array<void (*)(test_msg const &), 1 >{
60
- [](test_msg const &) { callbacks_called.set (0 ); }}};
61
+ std::array<callback_t , 1 >{[](test_msg const &) {
62
+ callbacks_called.set (0 );
63
+ return true ;
64
+ }}};
61
65
62
66
callbacks_called.reset ();
63
67
CHECK (h.handle (test_msg{" opcode_field" _field = 42 }));
@@ -97,16 +101,42 @@ TEST_CASE("create handler with multiple indices and callbacks",
97
101
entry{2u , bitset<32 >{stdx::place_bits, 2 , 6 , 8 }},
98
102
entry{3u , bitset<32 >{stdx::place_bits, 3 , 7 , 8 }},
99
103
}}))}},
100
- std::array<void (*)(test_msg const &), 9 >{
101
- [](test_msg const &) { callbacks_called.set (0 ); },
102
- [](test_msg const &) { callbacks_called.set (1 ); },
103
- [](test_msg const &) { callbacks_called.set (2 ); },
104
- [](test_msg const &) { callbacks_called.set (3 ); },
105
- [](test_msg const &) { callbacks_called.set (4 ); },
106
- [](test_msg const &) { callbacks_called.set (5 ); },
107
- [](test_msg const &) { callbacks_called.set (6 ); },
108
- [](test_msg const &) { callbacks_called.set (7 ); },
109
- [](test_msg const &) { callbacks_called.set (8 ); }}};
104
+ std::array<callback_t , 9 >{[](test_msg const &) {
105
+ callbacks_called.set (0 );
106
+ return true ;
107
+ },
108
+ [](test_msg const &) {
109
+ callbacks_called.set (1 );
110
+ return true ;
111
+ },
112
+ [](test_msg const &) {
113
+ callbacks_called.set (2 );
114
+ return true ;
115
+ },
116
+ [](test_msg const &) {
117
+ callbacks_called.set (3 );
118
+ return true ;
119
+ },
120
+ [](test_msg const &) {
121
+ callbacks_called.set (4 );
122
+ return true ;
123
+ },
124
+ [](test_msg const &) {
125
+ callbacks_called.set (5 );
126
+ return true ;
127
+ },
128
+ [](test_msg const &) {
129
+ callbacks_called.set (6 );
130
+ return true ;
131
+ },
132
+ [](test_msg const &) {
133
+ callbacks_called.set (7 );
134
+ return true ;
135
+ },
136
+ [](test_msg const &) {
137
+ callbacks_called.set (8 );
138
+ return true ;
139
+ }}};
110
140
111
141
auto const check_msg = [&](std::uint32_t op, std::uint32_t sub_op,
112
142
std::size_t callback_index) {
@@ -151,8 +181,11 @@ TEST_CASE("create handler with extra callback arg", "[indexed_handler]") {
151
181
lookup::make (CX_VALUE (lookup::input<std::uint32_t , bitset<32 >, 1 >{
152
182
bitset<32 >{}, std::array{lookup::entry{
153
183
42u , bitset<32 >{stdx::place_bits, 0 }}}}))}},
154
- std::array<void (*)(test_msg const &, std::size_t ), 1 >{
155
- [](test_msg const &, std::size_t i) { callbacks_called.set (i); }}};
184
+ std::array<auto (*)(test_msg const &, std::size_t )->bool , 1 >{
185
+ [](test_msg const &, std::size_t i) {
186
+ callbacks_called.set (i);
187
+ return true ;
188
+ }}};
156
189
157
190
callbacks_called.reset ();
158
191
CHECK (h.handle (test_msg{" opcode_field" _field = 42 }, std::size_t {1 }));
0 commit comments