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
b99e3e9c
Commit
b99e3e9c
authored
Feb 06, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix deep_to_string output
parent
9549ca47
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
33 deletions
+51
-33
libcaf_core/caf/detail/stringification_inspector.hpp
libcaf_core/caf/detail/stringification_inspector.hpp
+15
-0
libcaf_core/src/detail/stringification_inspector.cpp
libcaf_core/src/detail/stringification_inspector.cpp
+0
-2
libcaf_test/caf/test/unit_test.hpp
libcaf_test/caf/test/unit_test.hpp
+36
-31
No files found.
libcaf_core/caf/detail/stringification_inspector.hpp
View file @
b99e3e9c
...
...
@@ -215,6 +215,21 @@ public:
return
true
;
}
// -- convenience API --------------------------------------------------------
template
<
class
T
>
static
std
::
string
render
(
const
T
&
x
)
{
if
constexpr
(
std
::
is_constructible
<
string_view
,
T
>::
value
)
{
auto
str
=
string_view
{
x
};
return
std
::
string
{
str
.
begin
(),
str
.
end
()};
}
else
{
std
::
string
result
;
stringification_inspector
f
{
result
};
save
(
f
,
detail
::
as_mutable_ref
(
x
));
return
result
;
}
}
private:
template
<
class
T
>
void
append
(
T
&&
str
)
{
...
...
libcaf_core/src/detail/stringification_inspector.cpp
View file @
b99e3e9c
...
...
@@ -156,9 +156,7 @@ bool stringification_inspector::value(string_view str) {
};
if
(
always_quote_strings
||
std
::
any_of
(
str
.
begin
(),
str
.
end
(),
needs_escaping
))
{
result_
+=
'"'
;
detail
::
print_escaped
(
result_
,
str
);
result_
+=
'"'
;
}
else
{
result_
.
insert
(
result_
.
end
(),
str
.
begin
(),
str
.
end
());
}
...
...
libcaf_test/caf/test/unit_test.hpp
View file @
b99e3e9c
...
...
@@ -573,9 +573,10 @@ using caf_test_case_auto_fixture = caf::test::dummy_fixture;
#define CAF_REQUIRE(...) \
do { \
auto CAF_UNIQUE(__result) = ::caf::test::detail::check( \
::caf::test::engine::current_test(), __FILE__, __LINE__, #__VA_ARGS__, \
false, static_cast<bool>(__VA_ARGS__)); \
auto CAF_UNIQUE(__result) \
= ::caf::test::detail::check(::caf::test::engine::current_test(), \
__FILE__, __LINE__, #__VA_ARGS__, false, \
static_cast<bool>(__VA_ARGS__)); \
if (!CAF_UNIQUE(__result)) \
::caf::test::detail::requirement_failed(#__VA_ARGS__); \
::caf::test::engine::last_check_file(__FILE__); \
...
...
@@ -630,78 +631,82 @@ using caf_test_case_auto_fixture = caf::test::dummy_fixture;
#define CAF_CHECK_EQUAL(x_expr, y_expr) \
[](const auto& x_val, const auto& y_val) { \
return ::caf::test::detail::check_bin(
x_val == y_val, __FILE__, __LINE__,
\
#x_expr " == " #y_expr, \
caf::deep_to_string(x_val),
\
caf::deep_to_string(y_val));
\
return ::caf::test::detail::check_bin(
\
x_val == y_val, __FILE__, __LINE__,
#x_expr " == " #y_expr, \
caf::detail::stringification_inspector::render(x_val),
\
caf::detail::stringification_inspector::render(y_val));
\
}(x_expr, y_expr)
#define CAF_CHECK_NOT_EQUAL(x_expr, y_expr) \
[](const auto& x_val, const auto& y_val) { \
return ::caf::test::detail::check_bin(
x_val != y_val, __FILE__, __LINE__,
\
#x_expr " != " #y_expr, \
caf::deep_to_string(x_val),
\
caf::deep_to_string(y_val));
\
return ::caf::test::detail::check_bin(
\
x_val != y_val, __FILE__, __LINE__,
#x_expr " != " #y_expr, \
caf::detail::stringification_inspector::render(x_val),
\
caf::detail::stringification_inspector::render(y_val));
\
}(x_expr, y_expr)
#define CAF_CHECK_LESS(x_expr, y_expr) \
[](const auto& x_val, const auto& y_val) { \
return ::caf::test::detail::check_bin(
x_val < y_val, __FILE__, __LINE__,
\
#x_expr " < " #y_expr,
\
caf::deep_to_string(x_val),
\
caf::deep_to_string(y_val));
\
return ::caf::test::detail::check_bin(
\
x_val < y_val, __FILE__, __LINE__, #x_expr " < " #y_expr,
\
caf::detail::stringification_inspector::render(x_val),
\
caf::detail::stringification_inspector::render(y_val));
\
}(x_expr, y_expr)
#define CAF_CHECK_NOT_LESS(x_expr, y_expr) \
[](const auto& x_val, const auto& y_val) { \
return ::caf::test::detail::check_bin( \
!(x_val < y_val), __FILE__, __LINE__, "not " #x_expr " < " #y_expr, \
caf::deep_to_string(x_val), caf::deep_to_string(y_val)); \
caf::detail::stringification_inspector::render(x_val), \
caf::detail::stringification_inspector::render(y_val)); \
}(x_expr, y_expr)
#define CAF_CHECK_LESS_OR_EQUAL(x_expr, y_expr) \
[](const auto& x_val, const auto& y_val) { \
return ::caf::test::detail::check_bin(
x_val <= y_val, __FILE__, __LINE__,
\
#x_expr " <= " #y_expr, \
caf::deep_to_string(x_val),
\
caf::deep_to_string(y_val));
\
return ::caf::test::detail::check_bin(
\
x_val <= y_val, __FILE__, __LINE__,
#x_expr " <= " #y_expr, \
caf::detail::stringification_inspector::render(x_val),
\
caf::detail::stringification_inspector::render(y_val));
\
}(x_expr, y_expr)
#define CAF_CHECK_NOT_LESS_OR_EQUAL(x_expr, y_expr) \
[](const auto& x_val, const auto& y_val) { \
return ::caf::test::detail::check_bin( \
!(x_val <= y_val), __FILE__, __LINE__, "not " #x_expr " <= " #y_expr, \
caf::deep_to_string(x_val), caf::deep_to_string(y_val)); \
caf::detail::stringification_inspector::render(x_val), \
caf::detail::stringification_inspector::render(y_val)); \
}(x_expr, y_expr)
#define CAF_CHECK_GREATER(x_expr, y_expr) \
[](const auto& x_val, const auto& y_val) { \
return ::caf::test::detail::check_bin(
x_val > y_val, __FILE__, __LINE__,
\
#x_expr " > " #y_expr,
\
caf::deep_to_string(x_val),
\
caf::deep_to_string(y_val));
\
return ::caf::test::detail::check_bin(
\
x_val > y_val, __FILE__, __LINE__, #x_expr " > " #y_expr,
\
caf::detail::stringification_inspector::render(x_val),
\
caf::detail::stringification_inspector::render(y_val));
\
}(x_expr, y_expr)
#define CAF_CHECK_NOT_GREATER(x_expr, y_expr) \
[](const auto& x_val, const auto& y_val) { \
return ::caf::test::detail::check_bin( \
!(x_val > y_val), __FILE__, __LINE__, "not " #x_expr " > " #y_expr, \
caf::deep_to_string(x_val), caf::deep_to_string(y_val)); \
caf::detail::stringification_inspector::render(x_val), \
caf::detail::stringification_inspector::render(y_val)); \
}(x_expr, y_expr)
#define CAF_CHECK_GREATER_OR_EQUAL(x_expr, y_expr) \
[](const auto& x_val, const auto& y_val) { \
return ::caf::test::detail::check_bin(
x_val >= y_val, __FILE__, __LINE__,
\
#x_expr " >= " #y_expr, \
caf::deep_to_string(x_val),
\
caf::deep_to_string(y_val));
\
return ::caf::test::detail::check_bin(
\
x_val >= y_val, __FILE__, __LINE__,
#x_expr " >= " #y_expr, \
caf::detail::stringification_inspector::render(x_val),
\
caf::detail::stringification_inspector::render(y_val));
\
}(x_expr, y_expr)
#define CAF_CHECK_NOT_GREATER_OR_EQUAL(x_expr, y_expr) \
[](const auto& x_val, const auto& y_val) { \
return ::caf::test::detail::check_bin( \
!(x_val >= y_val), __FILE__, __LINE__, "not " #x_expr " >= " #y_expr, \
caf::deep_to_string(x_val), caf::deep_to_string(y_val)); \
caf::detail::stringification_inspector::render(x_val), \
caf::detail::stringification_inspector::render(y_val)); \
}(x_expr, y_expr)
// -- CAF_CHECK* predicate family ----------------------------------------------
...
...
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