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
2de0c407
Commit
2de0c407
authored
Sep 11, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test_constructor_attach() test case
parent
6475f47e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
unit_testing/test_spawn.cpp
unit_testing/test_spawn.cpp
+53
-0
No files found.
unit_testing/test_spawn.cpp
View file @
2de0c407
...
@@ -894,6 +894,56 @@ void counting_actor(event_based_actor* self) {
...
@@ -894,6 +894,56 @@ void counting_actor(event_based_actor* self) {
CAF_CHECK_EQUAL
(
self
->
mailbox
().
count
(),
200
);
CAF_CHECK_EQUAL
(
self
->
mailbox
().
count
(),
200
);
}
}
// tests attach_functor() inside of an actor's constructor
void
test_constructor_attach
()
{
class
testee
:
public
event_based_actor
{
public:
testee
(
actor
buddy
)
:
m_buddy
(
buddy
)
{
attach_functor
([
=
](
uint32_t
reason
)
{
send
(
m_buddy
,
atom
(
"done"
),
reason
);
});
}
behavior
make_behavior
()
{
return
{
on
(
atom
(
"die"
))
>>
[
=
]
{
quit
(
exit_reason
::
user_shutdown
);
}
};
}
private:
actor
m_buddy
;
};
class
spawner
:
public
event_based_actor
{
public:
spawner
()
:
m_downs
(
0
)
{
}
behavior
make_behavior
()
{
m_testee
=
spawn
<
testee
,
monitored
>
(
this
);
return
{
[
=
](
const
down_msg
&
msg
)
{
CAF_CHECK_EQUAL
(
msg
.
reason
,
exit_reason
::
user_shutdown
);
if
(
++
m_downs
==
2
)
{
quit
(
msg
.
reason
);
}
},
on
(
atom
(
"done"
),
arg_match
)
>>
[
=
](
uint32_t
reason
)
{
CAF_CHECK_EQUAL
(
reason
,
exit_reason
::
user_shutdown
);
if
(
++
m_downs
==
2
)
{
quit
(
reason
);
}
},
others
()
>>
[
=
]
{
forward_to
(
m_testee
);
}
};
}
private:
int
m_downs
;
actor
m_testee
;
};
anon_send
(
spawn
<
spawner
>
(),
atom
(
"die"
));
}
}
// namespace <anonymous>
}
// namespace <anonymous>
int
main
()
{
int
main
()
{
...
@@ -916,6 +966,9 @@ int main() {
...
@@ -916,6 +966,9 @@ int main() {
}
}
await_all_actors_done
();
await_all_actors_done
();
CAF_CHECKPOINT
();
CAF_CHECKPOINT
();
test_constructor_attach
();
await_all_actors_done
();
CAF_CHECKPOINT
();
shutdown
();
shutdown
();
CAF_CHECKPOINT
();
CAF_CHECKPOINT
();
return
CAF_TEST_RESULT
();
return
CAF_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