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
85ecb9b3
Commit
85ecb9b3
authored
Apr 09, 2013
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ported pub/sub unit test to new interface
parent
554bf7bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
15 deletions
+19
-15
unit_testing/test_local_group.cpp
unit_testing/test_local_group.cpp
+19
-15
No files found.
unit_testing/test_local_group.cpp
View file @
85ecb9b3
...
...
@@ -22,31 +22,35 @@ using std::endl;
using
std
::
string
;
using
namespace
cppa
;
void
testee
(
int
current_value
,
int
final_result
)
{
become
(
on_arg_match
>>
[
=
](
int
result
)
{
auto
next
=
result
+
current_value
;
if
(
next
>=
final_result
)
self
->
quit
();
else
testee
(
next
,
final_result
);
},
after
(
std
::
chrono
::
seconds
(
2
))
>>
[]
{
CPPA_UNEXPECTED_TOUT
();
self
->
quit
(
exit_reason
::
user_defined
);
}
);
}
int
main
()
{
CPPA_TEST
(
test__local_group
);
auto
foo_group
=
group
::
get
(
"local"
,
"foo"
);
actor_ptr
master
=
s
elf
;
actor_ptr
master
=
s
pawn_in_group
(
foo_group
,
testee
,
0
,
10
)
;
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
// spawn five workers and let them join local/foo
spawn_in_group
(
foo_group
,
[
master
]
()
{
receive
(
on
<
int
>
()
>>
[
master
](
int
v
)
{
spawn_in_group
(
foo_group
,
[
master
]
{
become
(
on_arg_match
>>
[
master
](
int
v
)
{
send
(
master
,
v
);
self
->
quit
();
});
});
}
send
(
foo_group
,
2
);
int
result
=
0
;
do_receive
(
on
<
int
>
()
>>
[
&
](
int
value
)
{
CPPA_CHECK_EQUAL
(
value
,
2
);
result
+=
value
;
},
after
(
std
::
chrono
::
seconds
(
2
))
>>
[
&
]()
{
CPPA_UNEXPECTED_TOUT
();
result
=
10
;
}
)
.
until
(
gref
(
result
)
==
10
);
await_all_others_done
();
shutdown
();
return
CPPA_TEST_RESULT
();
}
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