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
8678de68
Commit
8678de68
authored
Feb 03, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test for message lifetime
parent
a376b31a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
0 deletions
+89
-0
unit_testing/CMakeLists.txt
unit_testing/CMakeLists.txt
+1
-0
unit_testing/test_message_lifetime.cpp
unit_testing/test_message_lifetime.cpp
+88
-0
No files found.
unit_testing/CMakeLists.txt
View file @
8678de68
...
...
@@ -35,6 +35,7 @@ add_unit_test(constructor_attach)
add_unit_test
(
custom_exception_handler
)
add_unit_test
(
typed_spawn
)
add_unit_test
(
actor_lifetime
)
add_unit_test
(
message_lifetime
)
add_unit_test
(
local_group
)
add_unit_test
(
sync_send
)
add_unit_test
(
broker
)
...
...
unit_testing/test_message_lifetime.cpp
0 → 100644
View file @
8678de68
#include <atomic>
#include <iostream>
#include "test.hpp"
#include "caf/all.hpp"
using
std
::
cout
;
using
std
::
endl
;
using
namespace
caf
;
class
testee
:
public
event_based_actor
{
public:
testee
();
~
testee
();
behavior
make_behavior
()
override
;
};
testee
::
testee
()
{
// nop
}
testee
::~
testee
()
{
// nop
}
behavior
testee
::
make_behavior
()
{
return
{
others
()
>>
[
=
]
{
CAF_CHECK_EQUAL
(
last_dequeued
().
vals
()
->
get_reference_count
(),
2
);
quit
();
return
last_dequeued
();
}
};
}
class
tester
:
public
event_based_actor
{
public:
tester
(
actor
aut
);
~
tester
();
behavior
make_behavior
()
override
;
private:
actor
m_aut
;
message
m_msg
;
};
tester
::
tester
(
actor
aut
)
:
m_aut
(
std
::
move
(
aut
)),
m_msg
(
make_message
(
1
,
2
,
3
))
{
// nop
}
tester
::~
tester
()
{
// nop
}
behavior
tester
::
make_behavior
()
{
monitor
(
m_aut
);
send
(
m_aut
,
m_msg
);
return
{
on
(
1
,
2
,
3
)
>>
[
=
]
{
CAF_CHECK
(
last_dequeued
().
vals
()
->
get_reference_count
()
>=
2
);
CAF_CHECK
(
last_dequeued
().
vals
().
get
()
==
m_msg
.
vals
().
get
());
},
[
=
](
const
down_msg
&
dm
)
{
CAF_CHECK
(
dm
.
source
==
m_aut
);
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
normal
);
CAF_CHECK_EQUAL
(
last_dequeued
().
vals
()
->
get_reference_count
(),
1
);
quit
();
},
others
()
>>
CAF_UNEXPECTED_MSG_CB
(
this
)
};
}
void
test_message_lifetime
()
{
// put some preassure on the scheduler
for
(
size_t
i
=
0
;
i
<
1000
;
++
i
)
{
spawn
<
tester
>
(
spawn
<
testee
>
());
}
}
int
main
()
{
CAF_TEST
(
test_message_lifetime
);
test_message_lifetime
();
await_all_actors_done
();
shutdown
();
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