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
32c909b5
Unverified
Commit
32c909b5
authored
May 28, 2021
by
Dominik Charousset
Committed by
GitHub
May 28, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1263
Fix rendering of zero duration timespans
parents
728f6d82
8e9eb5c6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
27 deletions
+22
-27
CHANGELOG.md
CHANGELOG.md
+8
-0
libcaf_core/caf/detail/print.hpp
libcaf_core/caf/detail/print.hpp
+1
-1
libcaf_core/src/detail/stringification_inspector.cpp
libcaf_core/src/detail/stringification_inspector.cpp
+1
-25
libcaf_core/test/config_value.cpp
libcaf_core/test/config_value.cpp
+10
-1
libcaf_core/test/deep_to_string.cpp
libcaf_core/test/deep_to_string.cpp
+2
-0
No files found.
CHANGELOG.md
View file @
32c909b5
...
@@ -5,6 +5,14 @@ is based on [Keep a Changelog](https://keepachangelog.com).
...
@@ -5,6 +5,14 @@ is based on [Keep a Changelog](https://keepachangelog.com).
## [Unreleased]
## [Unreleased]
## Fixed
-
Printing a
`config_value`
that contains a zero duration
`timespan`
now
properly prints
`0s`
instead of
`1s`
(#1262). This bug most notably showed up
when setting a
`timespan`
parameter such as
`caf.middleman.heartbeat-interval`
via config file or CLI to
`0s`
and then printing the config parameter, e.g.,
via
`--dump-config`
.
## [0.18.3] - 2021-05-21
## [0.18.3] - 2021-05-21
### Added
### Added
...
...
libcaf_core/caf/detail/print.hpp
View file @
32c909b5
...
@@ -188,7 +188,7 @@ template <class Buffer, class Rep, class Period>
...
@@ -188,7 +188,7 @@ template <class Buffer, class Rep, class Period>
void
print
(
Buffer
&
buf
,
std
::
chrono
::
duration
<
Rep
,
Period
>
x
)
{
void
print
(
Buffer
&
buf
,
std
::
chrono
::
duration
<
Rep
,
Period
>
x
)
{
using
namespace
caf
::
literals
;
using
namespace
caf
::
literals
;
if
(
x
.
count
()
==
0
)
{
if
(
x
.
count
()
==
0
)
{
auto
str
=
"
1
s"
_sv
;
auto
str
=
"
0
s"
_sv
;
buf
.
insert
(
buf
.
end
(),
str
.
begin
(),
str
.
end
());
buf
.
insert
(
buf
.
end
(),
str
.
begin
(),
str
.
end
());
return
;
return
;
}
}
...
...
libcaf_core/src/detail/stringification_inspector.cpp
View file @
32c909b5
...
@@ -102,33 +102,9 @@ bool stringification_inspector::value(long double x) {
...
@@ -102,33 +102,9 @@ bool stringification_inspector::value(long double x) {
return
true
;
return
true
;
}
}
namespace
{
template
<
class
Duration
>
auto
dcast
(
timespan
x
)
{
return
std
::
chrono
::
duration_cast
<
Duration
>
(
x
);
}
}
// namespace
bool
stringification_inspector
::
value
(
timespan
x
)
{
bool
stringification_inspector
::
value
(
timespan
x
)
{
namespace
sc
=
std
::
chrono
;
sep
();
sep
();
auto
try_print
=
[
this
](
auto
converted
,
const
char
*
suffix
)
{
detail
::
print
(
result_
,
x
);
if
(
converted
.
count
()
<
1
)
return
false
;
value
(
converted
.
count
());
result_
+=
suffix
;
return
true
;
};
if
(
try_print
(
dcast
<
sc
::
hours
>
(
x
),
"h"
)
||
try_print
(
dcast
<
sc
::
minutes
>
(
x
),
"min"
)
||
try_print
(
dcast
<
sc
::
seconds
>
(
x
),
"s"
)
||
try_print
(
dcast
<
sc
::
milliseconds
>
(
x
),
"ms"
)
||
try_print
(
dcast
<
sc
::
microseconds
>
(
x
),
"us"
))
return
true
;
value
(
x
.
count
());
result_
+=
"ns"
;
return
true
;
return
true
;
}
}
...
...
libcaf_core/test/config_value.cpp
View file @
32c909b5
...
@@ -335,7 +335,7 @@ SCENARIO("get_as can convert config values to timespans") {
...
@@ -335,7 +335,7 @@ SCENARIO("get_as can convert config values to timespans") {
using
namespace
std
::
chrono_literals
;
using
namespace
std
::
chrono_literals
;
GIVEN
(
"a config value with value 42s"
)
{
GIVEN
(
"a config value with value 42s"
)
{
auto
x
=
config_value
{
timespan
{
42s
}};
auto
x
=
config_value
{
timespan
{
42s
}};
WHEN
(
"using get_as with timespan"
)
{
WHEN
(
"using get_as with timespan
or string
"
)
{
THEN
(
"conversion succeeds"
)
{
THEN
(
"conversion succeeds"
)
{
CHECK_EQ
(
get_as
<
timespan
>
(
x
),
timespan
{
42s
});
CHECK_EQ
(
get_as
<
timespan
>
(
x
),
timespan
{
42s
});
CHECK_EQ
(
get_as
<
std
::
string
>
(
x
),
"42s"
);
CHECK_EQ
(
get_as
<
std
::
string
>
(
x
),
"42s"
);
...
@@ -351,6 +351,15 @@ SCENARIO("get_as can convert config values to timespans") {
...
@@ -351,6 +351,15 @@ SCENARIO("get_as can convert config values to timespans") {
}
}
}
}
}
}
GIVEN
(
"a config value with value 0s"
)
{
auto
x
=
config_value
{
timespan
{
0s
}};
WHEN
(
"using get_as with timespan or string"
)
{
THEN
(
"conversion succeeds"
)
{
CHECK_EQ
(
get_as
<
timespan
>
(
x
),
timespan
{
0
});
CHECK_EQ
(
get_as
<
std
::
string
>
(
x
),
"0s"
);
}
}
}
}
}
SCENARIO
(
"get_as can convert config values to strings"
)
{
SCENARIO
(
"get_as can convert config values to strings"
)
{
...
...
libcaf_core/test/deep_to_string.cpp
View file @
32c909b5
...
@@ -13,6 +13,8 @@ using namespace caf;
...
@@ -13,6 +13,8 @@ using namespace caf;
#define CHECK_DEEP_TO_STRING(val, str) CAF_CHECK_EQUAL(deep_to_string(val), str)
#define CHECK_DEEP_TO_STRING(val, str) CAF_CHECK_EQUAL(deep_to_string(val), str)
CAF_TEST
(
timespans
use
the
highest
unit
available
when
printing
)
{
CAF_TEST
(
timespans
use
the
highest
unit
available
when
printing
)
{
CHECK_EQ
(
to_string
(
config_value
{
timespan
{
0
}}),
"0s"
);
CHECK_DEEP_TO_STRING
(
timespan
{
0
},
"0s"
);
CHECK_DEEP_TO_STRING
(
timespan
{
1
},
"1ns"
);
CHECK_DEEP_TO_STRING
(
timespan
{
1
},
"1ns"
);
CHECK_DEEP_TO_STRING
(
timespan
{
1'000
},
"1us"
);
CHECK_DEEP_TO_STRING
(
timespan
{
1'000
},
"1us"
);
CHECK_DEEP_TO_STRING
(
timespan
{
1'000'000
},
"1ms"
);
CHECK_DEEP_TO_STRING
(
timespan
{
1'000'000
},
"1ms"
);
...
...
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