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
7733a014
Commit
7733a014
authored
Mar 06, 2017
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve wildcard feature in testing DSL
parent
e8f5ec99
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
5 deletions
+40
-5
libcaf_test/caf/test/dsl.hpp
libcaf_test/caf/test/dsl.hpp
+40
-5
No files found.
libcaf_test/caf/test/dsl.hpp
View file @
7733a014
...
...
@@ -21,12 +21,51 @@
#include "caf/meta/annotation.hpp"
#include "caf/test/unit_test.hpp"
// allow comparing arbitrary `T`s to `message` objects
namespace
{
struct
wildcard
{
};
constexpr
wildcard
_
=
wildcard
{};
constexpr
bool
operator
==
(
const
wildcard
&
,
const
wildcard
&
)
{
return
true
;
}
template
<
size_t
I
,
class
T
>
bool
cmp_one
(
const
caf
::
message
&
x
,
const
T
&
y
)
{
if
(
std
::
is_same
<
T
,
wildcard
>::
value
)
return
true
;
return
x
.
match_element
<
T
>
(
I
)
&&
x
.
get_as
<
T
>
(
I
)
==
y
;
}
template
<
size_t
I
,
class
...
Ts
>
typename
std
::
enable_if
<
(
I
==
sizeof
...(
Ts
)),
bool
>::
type
msg_cmp_rec
(
const
caf
::
message
&
,
const
std
::
tuple
<
Ts
...
>&
)
{
return
true
;
}
template
<
size_t
I
,
class
...
Ts
>
typename
std
::
enable_if
<
(
I
<
sizeof
...(
Ts
)),
bool
>::
type
msg_cmp_rec
(
const
caf
::
message
&
x
,
const
std
::
tuple
<
Ts
...
>&
ys
)
{
return
cmp_one
<
I
>
(
x
,
std
::
get
<
I
>
(
ys
))
&&
msg_cmp_rec
<
I
+
1
>
(
x
,
ys
);
}
}
// namespace <anonymous>
// allow comparing arbitrary `T`s to `message` objects for the purpose of the
// testing DSL
namespace
caf
{
template
<
class
...
Ts
>
bool
operator
==
(
const
message
&
x
,
const
std
::
tuple
<
Ts
...
>&
y
)
{
return
msg_cmp_rec
<
0
>
(
x
,
y
);
}
template
<
class
T
>
bool
operator
==
(
const
message
&
x
,
const
T
&
y
)
{
return
x
.
match_elements
<
T
>
()
&&
x
.
get_as
<
T
>
(
0
)
==
y
;
}
}
// namespace caf
namespace
{
...
...
@@ -54,10 +93,6 @@ T get(const U&);
template
<
class
T
,
class
U
>
bool
is
(
const
U
&
);
struct
wildcard
{
};
constexpr
wildcard
_
=
wildcard
{};
template
<
class
Tup
>
class
elementwise_compare_inspector
{
public:
...
...
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