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
fa492b95
Commit
fa492b95
authored
Aug 16, 2023
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port the action test to the new framework
parent
26e940bc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
24 deletions
+22
-24
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+1
-1
libcaf_core/caf/action.test.cpp
libcaf_core/caf/action.test.cpp
+21
-23
No files found.
libcaf_core/CMakeLists.txt
View file @
fa492b95
...
@@ -71,6 +71,7 @@ caf_add_component(
...
@@ -71,6 +71,7 @@ caf_add_component(
caf/abstract_group.cpp
caf/abstract_group.cpp
caf/abstract_mailbox.cpp
caf/abstract_mailbox.cpp
caf/action.cpp
caf/action.cpp
caf/action.test.cpp
caf/actor.cpp
caf/actor.cpp
caf/actor_addr.cpp
caf/actor_addr.cpp
caf/actor_clock.cpp
caf/actor_clock.cpp
...
@@ -232,7 +233,6 @@ caf_add_component(
...
@@ -232,7 +233,6 @@ caf_add_component(
tests/legacy/core-test.cpp
tests/legacy/core-test.cpp
tests/legacy/nasty.cpp
tests/legacy/nasty.cpp
LEGACY_TEST_SUITES
LEGACY_TEST_SUITES
action
actor_clock
actor_clock
actor_factory
actor_factory
actor_lifetime
actor_lifetime
...
...
libcaf_core/
tests/legacy/action
.cpp
→
libcaf_core/
caf/action.test
.cpp
View file @
fa492b95
...
@@ -2,21 +2,15 @@
...
@@ -2,21 +2,15 @@
// the main distribution directory for license terms and copyright or visit
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#define CAF_SUITE action
#include "caf/action.hpp"
#include "caf/action.hpp"
#include "core-test.hpp"
#include "caf/test/caf_test_main.hpp"
#include "caf/test/fixture/deterministic.hpp"
using
namespace
caf
;
#include "caf/test/scenario.hpp"
namespace
{
using
fixture
=
test_coordinator_fixture
<>
;
#include "caf/event_based_actor.hpp"
}
// namespace
using
namespace
caf
;
BEGIN_FIXTURE_SCOPE
(
fixture
)
SCENARIO
(
"actions wrap function calls"
)
{
SCENARIO
(
"actions wrap function calls"
)
{
GIVEN
(
"an action wrapping a lambda"
)
{
GIVEN
(
"an action wrapping a lambda"
)
{
...
@@ -24,21 +18,21 @@ SCENARIO("actions wrap function calls") {
...
@@ -24,21 +18,21 @@ SCENARIO("actions wrap function calls") {
THEN
(
"it calls the lambda and transitions from scheduled to invoked"
)
{
THEN
(
"it calls the lambda and transitions from scheduled to invoked"
)
{
auto
called
=
false
;
auto
called
=
false
;
auto
uut
=
make_action
([
&
called
]
{
called
=
true
;
});
auto
uut
=
make_action
([
&
called
]
{
called
=
true
;
});
CHECK
(
uut
.
scheduled
());
check
(
uut
.
scheduled
());
uut
.
run
();
uut
.
run
();
CHECK
(
called
);
check
(
called
);
}
}
}
}
WHEN
(
"disposing the action"
)
{
WHEN
(
"disposing the action"
)
{
THEN
(
"it transitions to disposed and run no longer calls the lambda"
)
{
THEN
(
"it transitions to disposed and run no longer calls the lambda"
)
{
auto
called
=
false
;
auto
called
=
false
;
auto
uut
=
make_action
([
&
called
]
{
called
=
true
;
});
auto
uut
=
make_action
([
&
called
]
{
called
=
true
;
});
CHECK
(
uut
.
scheduled
());
check
(
uut
.
scheduled
());
uut
.
dispose
();
uut
.
dispose
();
CHECK
(
uut
.
disposed
());
check
(
uut
.
disposed
());
uut
.
run
();
uut
.
run
();
CHECK
(
!
called
);
check
(
!
called
);
CHECK
(
uut
.
disposed
());
check
(
uut
.
disposed
());
}
}
}
}
WHEN
(
"running the action multiple times"
)
{
WHEN
(
"running the action multiple times"
)
{
...
@@ -48,7 +42,7 @@ SCENARIO("actions wrap function calls") {
...
@@ -48,7 +42,7 @@ SCENARIO("actions wrap function calls") {
uut
.
run
();
uut
.
run
();
uut
.
run
();
uut
.
run
();
uut
.
run
();
uut
.
run
();
CHECK_EQ
(
n
,
3
);
check_eq
(
n
,
3
);
}
}
}
}
WHEN
(
"converting an action to a disposable"
)
{
WHEN
(
"converting an action to a disposable"
)
{
...
@@ -56,13 +50,15 @@ SCENARIO("actions wrap function calls") {
...
@@ -56,13 +50,15 @@ SCENARIO("actions wrap function calls") {
auto
uut
=
make_action
([]
{});
auto
uut
=
make_action
([]
{});
auto
d1
=
uut
.
as_disposable
();
// const& overload
auto
d1
=
uut
.
as_disposable
();
// const& overload
auto
d2
=
action
{
uut
}.
as_disposable
();
// && overload
auto
d2
=
action
{
uut
}.
as_disposable
();
// && overload
CHECK_EQ
(
uut
.
ptr
(),
d1
.
ptr
());
check_eq
(
uut
.
ptr
(),
d1
.
ptr
());
CHECK_EQ
(
uut
.
ptr
(),
d2
.
ptr
());
check_eq
(
uut
.
ptr
(),
d2
.
ptr
());
}
}
}
}
}
}
}
}
WITH_FIXTURE
(
test
::
fixture
::
deterministic
)
{
SCENARIO
(
"actors run actions that they receive"
)
{
SCENARIO
(
"actors run actions that they receive"
)
{
GIVEN
(
"a scheduled actor"
)
{
GIVEN
(
"a scheduled actor"
)
{
WHEN
(
"sending it an action"
)
{
WHEN
(
"sending it an action"
)
{
...
@@ -73,11 +69,13 @@ SCENARIO("actors run actions that they receive") {
...
@@ -73,11 +69,13 @@ SCENARIO("actors run actions that they receive") {
};
};
});
});
auto
n
=
0
;
auto
n
=
0
;
inject
(
(
action
),
to
(
aut
).
with
(
make_action
([
&
n
]
{
++
n
;
}))
);
inject
(
).
with
(
make_action
([
&
n
]
{
++
n
;
})).
to
(
aut
);
CHECK_EQ
(
n
,
1
);
check_eq
(
n
,
1
);
}
}
}
}
}
}
}
}
END_FIXTURE_SCOPE
()
}
// WITH_FIXTURE(test::fixture::deterministic)
CAF_TEST_MAIN
()
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