Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
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
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
Libraries
fmt
Commits
d702a68d
Commit
d702a68d
authored
Jun 14, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix formatting of bool with FMT_COMPILE and add more tests
parent
e956a14e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
include/fmt/format.h
include/fmt/format.h
+2
-1
test/compile-test.cc
test/compile-test.cc
+8
-1
No files found.
include/fmt/format.h
View file @
d702a68d
...
...
@@ -3380,7 +3380,8 @@ inline std::string to_string(const T& value) {
}
template
<
typename
T
,
FMT_ENABLE_IF
(
std
::
is_integral
<
T
>
::
value
)
>
inline
std
::
string
to_string
(
T
value
)
{
char
buffer
[
detail
::
digits10
<
T
>
()
+
2
];
// Buffer should be large enough to store the number or "false" (for bool).
char
buffer
[(
std
::
max
)(
detail
::
digits10
<
T
>
()
+
2
,
5
)];
char
*
begin
=
buffer
;
char
*
end
=
detail
::
write
<
char
>
(
begin
,
value
);
return
std
::
string
(
begin
,
end
);
...
...
test/compile-test.cc
View file @
d702a68d
...
...
@@ -144,8 +144,15 @@ TEST(CompileTest, EmptyFormatString) {
}
#ifdef __cpp_if_constexpr
TEST
(
CompileTest
,
Basic
)
{
TEST
(
CompileTest
,
FormatDefault
)
{
EXPECT_EQ
(
"42"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
42
));
EXPECT_EQ
(
"42"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
42u
));
EXPECT_EQ
(
"42"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
42ll
));
EXPECT_EQ
(
"42"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
42ull
));
EXPECT_EQ
(
"true"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
true
));
EXPECT_EQ
(
"x"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
'x'
));
EXPECT_EQ
(
"4.2"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
4.2
));
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
"foo"
));
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
std
::
string
(
"foo"
)));
}
#endif
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