test_selector.cpp
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * fkie_message_filters
4  * Copyright © 2018-2020 Fraunhofer FKIE
5  * Author: Timo Röhling
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ****************************************************************************/
20 #include "test.h"
24 
26 {
28  using Select = mf::Selector<Source::Output, 1>;
29  using Sink = mf::SimpleUserFilter<double_M>;
30 
31  std::size_t callback_counts = 0;
32  Source src;
33  Select select;
34  Sink snk;
36  [&](const double_M& d) -> bool
37  {
38  ++callback_counts;
39  if (d == 2.5) throw ExpectedException("d == 2.5");
40  if (d != 5.0) throw std::domain_error("d != 5.0");
41  return true;
42  }
43  );
44  mf::chain(src, select, snk);
45  src(int_M(1), double_M(5.0), string_M("abc"));
46  ASSERT_THROW(src(int_M(0), double_M(2.5), string_M("")), ExpectedException);
47  ASSERT_EQ(2u, callback_counts);
48 }
d
void set_processing_function(const ProcessingFunction &f) noexcept
Set the user-defined processing function.
NotDefaultConstructable< std::string > string_M
Definition: test.h:49
TEST(fkie_message_filters, Selector)
Primary namespace.
Definition: buffer.h:33
void chain(Filter1 &flt1, Filter2 &flt2, MoreFilters &... filters) noexcept
Convenience function to chain multiple filters.
Definition: filter_impl.h:53
NotDefaultConstructable< int > int_M
Definition: test.h:47
Manually operated data source.
Definition: user_source.h:37
Simplified filter with user-defined callback function.
NotDefaultConstructable< double > double_M
Definition: test.h:48


fkie_message_filters
Author(s): Timo Röhling
autogenerated on Mon Feb 28 2022 22:21:43