test
test_divider.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
"
21
#include <
fkie_message_filters/divider.h
>
22
#include <
fkie_message_filters/user_source.h
>
23
#include <
fkie_message_filters/simple_user_filter.h
>
24
25
TEST
(
fkie_message_filters
, Divider)
26
{
27
using
Source =
mf::UserSource<int_M, double_M>
;
28
using
Divider =
mf::Divider<Source::Output>
;
29
using
Sink1 =
mf::SimpleUserFilter<int_M>
;
30
using
Sink2 =
mf::SimpleUserFilter<double_M>
;
31
32
std::size_t callback_counts = 0;
33
Source src;
34
Divider div;
35
Sink1 snk1;
36
Sink2 snk2;
37
38
snk1.
set_processing_function
(
39
[&](
const
int_M
& i) ->
bool
40
{
41
++callback_counts;
42
if
(i != 42)
throw
std::domain_error(
"i != 42"
);
43
return
true
;
44
}
45
);
46
snk2.set_processing_function(
47
[&](
const
double_M
&
d
) ->
bool
48
{
49
++callback_counts;
50
if
(
d
!= 3.14)
throw
std::domain_error(
"d != 3.14"
);
51
return
true
;
52
}
53
);
54
mf::chain
(src, div);
55
div.connect_to_sinks(snk1, snk2);
56
src(
int_M
(42),
double_M
(3.14));
57
ASSERT_EQ(2u, callback_counts);
58
}
fkie_message_filters
Definition:
buffer.h:33
fkie_message_filters::chain
void chain(Filter1 &flt1, Filter2 &flt2, MoreFilters &... filters) noexcept
Convenience function to chain multiple filters.
Definition:
filter_impl.h:71
NotDefaultConstructable
Definition:
test.h:35
simple_user_filter.h
fkie_message_filters::SimpleUserFilter::set_processing_function
void set_processing_function(const ProcessingFunction &f) noexcept
Set the user-defined processing function.
Definition:
simple_user_filter_impl.h:47
fkie_message_filters::UserSource
Manually operated data source.
Definition:
user_source.h:55
fkie_message_filters::SimpleUserFilter
Simplified filter with user-defined callback function.
Definition:
simple_user_filter.h:56
divider.h
double_M
NotDefaultConstructable< double > double_M
Definition:
test.h:48
int_M
NotDefaultConstructable< int > int_M
Definition:
test.h:47
fkie_message_filters::Divider
Split an N-ary source into N unary ones.
Definition:
divider.h:77
d
d
test.h
TEST
TEST(fkie_message_filters, Divider)
Definition:
test_divider.cpp:25
user_source.h
fkie_message_filters
Author(s): Timo Röhling
autogenerated on Wed Mar 2 2022 00:18:57