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
3731fc84
Commit
3731fc84
authored
Jun 18, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add compile-time checks for recent code additions
parent
97dffef0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
0 deletions
+145
-0
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+1
-0
libcaf_core/test/scheduled_actor.cpp
libcaf_core/test/scheduled_actor.cpp
+144
-0
No files found.
libcaf_core/CMakeLists.txt
View file @
3731fc84
...
@@ -324,6 +324,7 @@ caf_add_component(
...
@@ -324,6 +324,7 @@ caf_add_component(
response_promise
response_promise
result
result
save_inspector
save_inspector
scheduled_actor
selective_streaming
selective_streaming
serial_reply
serial_reply
serialization
serialization
...
...
libcaf_core/test/scheduled_actor.cpp
0 → 100644
View file @
3731fc84
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#define CAF_SUITE scheduled_actor
#include "caf/scheduled_actor.hpp"
#include "caf/test/dsl.hpp"
using
namespace
caf
;
#define ASSERT_COMPILES(expr, msg) \
static_assert(std::is_void_v<decltype(expr)>, msg);
namespace
{
constexpr
scheduled_actor
*
nil_actor
=
nullptr
;
// -- compile-time checks for set_default_handler ------------------------------
struct
mutable_default_fn
{
skippable_result
operator
()(
message
&
)
{
return
{};
}
};
ASSERT_COMPILES
(
nil_actor
->
set_default_handler
(
mutable_default_fn
{}),
"set_default_handler must accept mutable function objects"
);
struct
const_default_fn
{
skippable_result
operator
()(
message
&
)
const
{
return
{};
}
};
ASSERT_COMPILES
(
nil_actor
->
set_default_handler
(
const_default_fn
{}),
"set_default_handler must accept const function objects"
);
// -- compile-time checks for set_error_handler --------------------------------
struct
mutable_error_fn
{
void
operator
()(
error
&
)
{
// nop
}
};
ASSERT_COMPILES
(
nil_actor
->
set_error_handler
(
mutable_error_fn
{}),
"set_error_handler must accept mutable function objects"
);
struct
const_error_fn
{
void
operator
()(
error
&
)
const
{
// nop
}
};
ASSERT_COMPILES
(
nil_actor
->
set_error_handler
(
const_error_fn
{}),
"set_error_handler must accept const function objects"
);
// -- compile-time checks for set_down_handler ---------------------------------
struct
mutable_down_fn
{
void
operator
()(
down_msg
&
)
{
// nop
}
};
ASSERT_COMPILES
(
nil_actor
->
set_down_handler
(
mutable_down_fn
{}),
"set_down_handler must accept mutable function objects"
);
struct
const_down_fn
{
void
operator
()(
down_msg
&
)
const
{
// nop
}
};
ASSERT_COMPILES
(
nil_actor
->
set_down_handler
(
const_down_fn
{}),
"set_down_handler must accept const function objects"
);
// -- compile-time checks for set_node_down_handler ----------------------------
struct
mutable_node_down_fn
{
void
operator
()(
node_down_msg
&
)
{
// nop
}
};
ASSERT_COMPILES
(
nil_actor
->
set_node_down_handler
(
mutable_node_down_fn
{}),
"set_node_down_handler must accept mutable function objects"
);
struct
const_node_down_fn
{
void
operator
()(
node_down_msg
&
)
const
{
// nop
}
};
ASSERT_COMPILES
(
nil_actor
->
set_node_down_handler
(
const_node_down_fn
{}),
"set_node_down_handler must accept const function objects"
);
// -- compile-time checks for set_exit_handler ---------------------------------
struct
mutable_exit_fn
{
void
operator
()(
exit_msg
&
)
{
// nop
}
};
ASSERT_COMPILES
(
nil_actor
->
set_exit_handler
(
mutable_exit_fn
{}),
"set_exit_handler must accept mutable function objects"
);
struct
const_exit_fn
{
void
operator
()(
exit_msg
&
)
const
{
// nop
}
};
ASSERT_COMPILES
(
nil_actor
->
set_exit_handler
(
const_exit_fn
{}),
"set_exit_handler must accept const function objects"
);
// -- compile-time checks for set_exception_handler ----------------------------
#ifdef CAF_ENABLE_EXCEPTIONS
struct
mutable_exception_fn
{
error
operator
()(
std
::
exception_ptr
&
)
{
return
{};
}
};
ASSERT_COMPILES
(
nil_actor
->
set_exception_handler
(
mutable_exception_fn
{}),
"set_exception_handler must accept mutable function objects"
);
struct
const_exception_fn
{
error
operator
()(
std
::
exception_ptr
&
)
const
{
return
{};
}
};
ASSERT_COMPILES
(
nil_actor
->
set_exception_handler
(
const_exception_fn
{}),
"set_exception_handler must accept const function objects"
);
#endif // CAF_ENABLE_EXCEPTIONS
}
// namespace
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