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
cdfe2c22
Commit
cdfe2c22
authored
Jun 04, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add convenience functions to fixture
parent
63106cb5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
15 deletions
+42
-15
libcaf_test/caf/test/dsl.hpp
libcaf_test/caf/test/dsl.hpp
+42
-15
No files found.
libcaf_test/caf/test/dsl.hpp
View file @
cdfe2c22
...
@@ -519,6 +519,31 @@ protected:
...
@@ -519,6 +519,31 @@ protected:
std
::
function
<
void
()
>
check_
;
std
::
function
<
void
()
>
check_
;
};
};
template
<
class
...
Ts
>
struct
test_coordinator_fixture_fetch_helper
{
template
<
class
Self
,
class
Interface
>
std
::
tuple
<
Ts
...
>
operator
()(
caf
::
response_handle
<
Self
,
Interface
,
true
>&
from
)
const
{
std
::
tuple
<
Ts
...
>
result
;
from
.
receive
(
[
&
](
Ts
&
...
xs
)
{
result
=
std
::
make_tuple
(
std
::
move
(
xs
)...);
},
[
&
](
caf
::
error
&
err
)
{
FAIL
(
from
.
self
()
->
system
().
render
(
err
));
});
return
result
;
}
};
template
<
class
T
>
struct
test_coordinator_fixture_fetch_helper
<
T
>
{
template
<
class
Self
,
class
Interface
>
T
operator
()(
caf
::
response_handle
<
Self
,
Interface
,
true
>&
from
)
const
{
T
result
;
from
.
receive
(
[
&
](
T
&
x
)
{
result
=
std
::
move
(
x
);
},
[
&
](
caf
::
error
&
err
)
{
FAIL
(
from
.
self
()
->
system
().
render
(
err
));
});
return
result
;
}
};
/// A fixture with a deterministic scheduler setup.
/// A fixture with a deterministic scheduler setup.
template
<
class
Config
=
caf
::
actor_system_config
>
template
<
class
Config
=
caf
::
actor_system_config
>
struct
test_coordinator_fixture
{
struct
test_coordinator_fixture
{
...
@@ -584,21 +609,23 @@ struct test_coordinator_fixture {
...
@@ -584,21 +609,23 @@ struct test_coordinator_fixture {
sched
.
run_dispatch_loop
(
predicate
,
streaming_cycle
);
sched
.
run_dispatch_loop
(
predicate
,
streaming_cycle
);
}
}
template
<
class
T
=
int
>
/// Sends a request to `from`, then calls `run_exhaustively`, and finally
caf
::
expected
<
T
>
fetch_result
()
{
/// fetches and returns the result.
caf
::
expected
<
T
>
result
=
caf
::
error
{};
template
<
class
T
,
class
...
Ts
,
class
Handle
,
class
...
Us
>
self
->
receive
(
typename
std
::
conditional
<
sizeof
...(
Ts
)
==
0
,
T
,
std
::
tuple
<
T
,
Ts
...
>>::
type
[
&
](
T
&
x
)
{
request
(
Handle
from
,
Us
...
args
)
{
result
=
std
::
move
(
x
);
auto
res_hdl
=
self
->
request
(
from
,
caf
::
infinite
,
std
::
move
(
args
)...);
},
run_exhaustively
();
[
&
](
caf
::
error
&
x
)
{
test_coordinator_fixture_fetch_helper
<
T
,
Ts
...
>
f
;
result
=
std
::
move
(
x
);
return
f
(
res_hdl
);
},
}
caf
::
after
(
std
::
chrono
::
seconds
(
0
))
>>
[
&
]
{
result
=
caf
::
sec
::
request_timeout
;
/// Unboxes an expected value or fails the test if it doesn't exist.
}
template
<
class
T
>
);
T
unbox
(
caf
::
expected
<
T
>
x
)
{
return
result
;
if
(
!
x
)
FAIL
(
sys
.
render
(
x
.
error
()));
return
std
::
move
(
*
x
);
}
}
template
<
class
T
>
template
<
class
T
>
...
...
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