Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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 Framework
Commits
467a9c77
Commit
467a9c77
authored
Nov 04, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test for new fan_out_request
parent
764ca189
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
libcaf_core/test/mixin/requester.cpp
libcaf_core/test/mixin/requester.cpp
+28
-0
No files found.
libcaf_core/test/mixin/requester.cpp
View file @
467a9c77
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include "caf/test/dsl.hpp"
#include "caf/test/dsl.hpp"
#include "caf/event_based_actor.hpp"
#include "caf/event_based_actor.hpp"
#include "caf/policy/fan_in_responses.hpp"
using
namespace
caf
;
using
namespace
caf
;
...
@@ -150,4 +151,31 @@ CAF_TEST(delegated request with integer result) {
...
@@ -150,4 +151,31 @@ CAF_TEST(delegated request with integer result) {
CAF_CHECK_EQUAL
(
*
result
,
3
);
CAF_CHECK_EQUAL
(
*
result
,
3
);
}
}
CAF_TEST
(
requesters
support
fan_out_request
)
{
using
policy
::
fan_in_responses
;
std
::
vector
<
adding_server_type
>
workers
{
adding_server
=
make_server
([](
int
x
,
int
y
)
{
return
x
+
y
;
}),
adding_server
=
make_server
([](
int
x
,
int
y
)
{
return
x
+
y
;
}),
adding_server
=
make_server
([](
int
x
,
int
y
)
{
return
x
+
y
;
}),
};
run
();
auto
sum
=
std
::
make_shared
<
int
>
(
0
);
auto
client
=
sys
.
spawn
([
=
](
event_based_actor
*
self
)
{
self
->
fan_out_request
<
fan_in_responses
>
(
workers
,
infinite
,
1
,
2
)
.
then
([
=
](
std
::
vector
<
int
>
results
)
{
for
(
auto
result
:
results
)
CAF_CHECK_EQUAL
(
result
,
3
);
*
sum
=
std
::
accumulate
(
results
.
begin
(),
results
.
end
(),
0
);
});
});
run_once
();
expect
((
int
,
int
),
from
(
client
).
to
(
workers
[
0
]).
with
(
1
,
2
));
expect
((
int
,
int
),
from
(
client
).
to
(
workers
[
1
]).
with
(
1
,
2
));
expect
((
int
,
int
),
from
(
client
).
to
(
workers
[
2
]).
with
(
1
,
2
));
expect
((
int
),
from
(
client
).
to
(
workers
[
0
]).
with
(
3
));
expect
((
int
),
from
(
client
).
to
(
workers
[
1
]).
with
(
3
));
expect
((
int
),
from
(
client
).
to
(
workers
[
2
]).
with
(
3
));
CAF_CHECK_EQUAL
(
*
sum
,
9
);
}
CAF_TEST_FIXTURE_SCOPE_END
()
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