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
68c0fb30
Commit
68c0fb30
authored
Feb 24, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move TESTEE macros to the testing DSL header
parent
641db02e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
26 deletions
+45
-26
libcaf_core/test/local_streaming.cpp
libcaf_core/test/local_streaming.cpp
+1
-22
libcaf_test/caf/test/dsl.hpp
libcaf_test/caf/test/dsl.hpp
+44
-4
No files found.
libcaf_core/test/local_streaming.cpp
View file @
68c0fb30
...
...
@@ -33,30 +33,9 @@ using std::vector;
using
namespace
caf
;
#define TESTEE_STATE(tname) \
struct tname##_state; \
template <> \
struct state_base<tname##_state>
#define TESTEE_SCAFFOLD(tname) \
struct tname##_state : state_base<tname##_state> { \
static const char* name; \
}; \
const char* tname##_state::name = #tname; \
using tname##_actor = stateful_actor<tname##_state>
#define TESTEE(tname) \
TESTEE_SCAFFOLD(tname); \
behavior tname(tname##_actor* self)
#define VARARGS_TESTEE(tname, ...) \
TESTEE_SCAFFOLD(tname); \
behavior tname(tname##_actor* self, __VA_ARGS__)
namespace
{
template
<
class
T
>
struct
state_base
{};
TESTEE_SETUP
();
VARARGS_TESTEE
(
file_reader
,
size_t
buf_size
)
{
using
buf
=
std
::
deque
<
int
>
;
...
...
libcaf_test/caf/test/dsl.hpp
View file @
68c0fb30
...
...
@@ -474,13 +474,53 @@ struct test_coordinator_fixture {
}
// namespace <anonymous>
/// Expands to its argument.
#define CAF_EXPAND(x) x
/// Expands to its arguments.
#define CAF_DSL_LIST(...) __VA_ARGS__
/// Convenience macro for defining expect clauses.
#define expect(types, fields) \
CAF_MESSAGE("expect" << #types << "." << #fields); \
expect_clause< CAF_EXPAND(CAF_DSL_LIST types) >{sched} . fields
do { \
CAF_MESSAGE("expect" << #types << "." << #fields); \
expect_clause<CAF_EXPAND(CAF_DSL_LIST types)>{sched}.fields; \
} while (false)
/// Convenience macro for defining disallow clauses.
#define disallow(types, fields) \
CAF_MESSAGE("disallow" << #types << "." << #fields); \
disallow_clause< CAF_EXPAND(CAF_DSL_LIST types) >{} . fields
do { \
CAF_MESSAGE("disallow" << #types << "." << #fields); \
disallow_clause<CAF_EXPAND(CAF_DSL_LIST types)>{}.fields; \
} while (false)
/// Defines the required base type for testee states in the current namespace.
#define TESTEE_SETUP() \
template <class T> \
struct testee_state_base {}
/// Convenience macro for adding additional state to a testee.
#define TESTEE_STATE(tname) \
struct tname##_state; \
template <> \
struct testee_state_base<tname##_state>
/// Implementation detail for `TESTEE` and `VARARGS_TESTEE`.
#define TESTEE_SCAFFOLD(tname) \
struct tname##_state : testee_state_base<tname##_state> { \
static const char* name; \
}; \
const char* tname##_state::name = #tname; \
using tname##_actor = stateful_actor<tname##_state>
/// Convenience macro for defining an actor named `tname`.
#define TESTEE(tname) \
TESTEE_SCAFFOLD(tname); \
behavior tname(tname##_actor* self)
/// Convenience macro for defining an actor named `tname` with any number of
/// initialization arguments.
#define VARARGS_TESTEE(tname, ...) \
TESTEE_SCAFFOLD(tname); \
behavior tname(tname##_actor* self, __VA_ARGS__)
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