Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
actor-incubator
Commits
5af7acef
Commit
5af7acef
authored
Feb 20, 2019
by
Hauke Goldhammer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests of caf::bb::container_source
parent
4f554f17
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
4 deletions
+77
-4
libcaf_bb/test/container_source.cpp
libcaf_bb/test/container_source.cpp
+77
-4
No files found.
libcaf_bb/test/container_source.cpp
View file @
5af7acef
...
...
@@ -24,20 +24,93 @@
#include <vector>
#include "caf/actor_system.hpp"
#include "caf/actor_system_config.hpp"
using
namespace
caf
;
namespace
{
struct
fixture
{
using
container_type
=
std
::
vector
<
int
>
;
TESTEE_SETUP
();
TESTEE_STATE
(
container_sink
)
{
container_type
con
;
};
TESTEE
(
container_sink
)
{
return
{[
=
](
stream
<
container_type
::
value_type
>
in
)
{
return
self
->
make_sink
(
// input stream
in
,
// initialize state
[
=
](
unit_t
&
)
{
// nop
},
// Consumer
[
=
](
unit_t
&
,
container_type
::
value_type
val
)
{
self
->
state
.
con
.
emplace_back
(
std
::
move
(
val
));
},
// cleanup and produce result message
[
=
](
unit_t
&
,
const
error
&
)
{
CAF_MESSAGE
(
self
->
name
()
<<
" is done"
);
});
}};
}
TESTEE_STATE
(
container_monitor
)
{
actor
streamer
;
};
TESTEE
(
container_monitor
)
{
self
->
set_down_handler
([
=
](
const
down_msg
&
dm
)
{
CAF_CHECK_EQUAL
(
dm
.
source
,
self
->
state
.
streamer
);
});
return
{[
=
](
join_atom
,
actor
streamer
)
{
self
->
state
.
streamer
=
streamer
;
self
->
monitor
(
streamer
);
}};
}
struct
config
:
actor_system_config
{
config
()
{
add_message_type
<
container_type
::
value_type
>
(
"value_type"
);
}
};
}
// namespace <anonymous>
using
fixture
=
test_coordinator_fixture
<
config
>
;
}
// namespace
CAF_TEST_FIXTURE_SCOPE
(
container_source_tests
,
fixture
)
CAF_TEST
(
todo
)
{
// implement me
CAF_TEST
(
stream_to_sink
)
{
scoped_actor
self
{
sys
};
container_type
test_container
{
0
,
1
,
2
,
3
,
4
,
5
};
auto
sink
=
sys
.
spawn
(
container_sink
);
auto
src
=
sys
.
spawn
(
bb
::
container_source
<
container_type
,
actor
>
,
test_container
,
sink
);
auto
mon
=
sys
.
spawn
(
container_monitor
);
self
->
send
(
mon
,
join_atom
::
value
,
src
);
run
();
CAF_CHECK_EQUAL
(
deref
<
container_sink_actor
>
(
sink
).
state
.
con
,
test_container
);
}
CAF_TEST
(
stream_to_sinks
)
{
scoped_actor
self
{
sys
};
container_type
test_container
{
0
,
1
,
2
,
3
,
4
,
5
};
auto
snk1
=
sys
.
spawn
(
container_sink
);
auto
snk2
=
sys
.
spawn
(
container_sink
);
auto
snk3
=
sys
.
spawn
(
container_sink
);
auto
src
=
sys
.
spawn
(
bb
::
container_source
<
container_type
,
actor
,
actor
,
actor
>
,
test_container
,
snk1
,
snk2
,
snk3
);
auto
mon
=
sys
.
spawn
(
container_monitor
);
self
->
send
(
mon
,
join_atom
::
value
,
src
);
run
();
CAF_CHECK_EQUAL
(
deref
<
container_sink_actor
>
(
snk1
).
state
.
con
,
test_container
);
CAF_CHECK_EQUAL
(
deref
<
container_sink_actor
>
(
snk2
).
state
.
con
,
test_container
);
CAF_CHECK_EQUAL
(
deref
<
container_sink_actor
>
(
snk3
).
state
.
con
,
test_container
);
}
CAF_TEST_FIXTURE_SCOPE_END
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment