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
f72a905e
Commit
f72a905e
authored
Mar 11, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of volatile enums
parent
941d5e14
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
include/fmt/printf.h
include/fmt/printf.h
+5
-0
test/printf-test.cc
test/printf-test.cc
+9
-3
No files found.
include/fmt/printf.h
View file @
f72a905e
...
@@ -303,6 +303,8 @@ class printf_arg_formatter : public internal::arg_formatter_base<Range> {
...
@@ -303,6 +303,8 @@ class printf_arg_formatter : public internal::arg_formatter_base<Range> {
};
};
template
<
typename
T
>
struct
printf_formatter
{
template
<
typename
T
>
struct
printf_formatter
{
printf_formatter
()
=
delete
;
template
<
typename
ParseContext
>
template
<
typename
ParseContext
>
auto
parse
(
ParseContext
&
ctx
)
->
decltype
(
ctx
.
begin
())
{
auto
parse
(
ParseContext
&
ctx
)
->
decltype
(
ctx
.
begin
())
{
return
ctx
.
begin
();
return
ctx
.
begin
();
...
@@ -320,6 +322,7 @@ template <typename OutputIt, typename Char> class basic_printf_context {
...
@@ -320,6 +322,7 @@ template <typename OutputIt, typename Char> class basic_printf_context {
public:
public:
/** The character type for the output. */
/** The character type for the output. */
using
char_type
=
Char
;
using
char_type
=
Char
;
using
iterator
=
OutputIt
;
using
format_arg
=
basic_format_arg
<
basic_printf_context
>
;
using
format_arg
=
basic_format_arg
<
basic_printf_context
>
;
template
<
typename
T
>
using
formatter_type
=
printf_formatter
<
T
>
;
template
<
typename
T
>
using
formatter_type
=
printf_formatter
<
T
>
;
...
@@ -355,6 +358,8 @@ template <typename OutputIt, typename Char> class basic_printf_context {
...
@@ -355,6 +358,8 @@ template <typename OutputIt, typename Char> class basic_printf_context {
OutputIt
out
()
{
return
out_
;
}
OutputIt
out
()
{
return
out_
;
}
void
advance_to
(
OutputIt
it
)
{
out_
=
it
;
}
void
advance_to
(
OutputIt
it
)
{
out_
=
it
;
}
internal
::
locale_ref
locale
()
{
return
{};
}
format_arg
arg
(
int
id
)
const
{
return
args_
.
get
(
id
);
}
format_arg
arg
(
int
id
)
const
{
return
args_
.
get
(
id
);
}
basic_format_parse_context
<
Char
>&
parse_context
()
{
return
parse_ctx_
;
}
basic_format_parse_context
<
Char
>&
parse_context
()
{
return
parse_ctx_
;
}
...
...
test/printf-test.cc
View file @
f72a905e
...
@@ -474,9 +474,13 @@ TEST(PrintfTest, Location) {
...
@@ -474,9 +474,13 @@ TEST(PrintfTest, Location) {
// TODO: test %n
// TODO: test %n
}
}
enum
E
{
A
=
42
};
enum
test_enum
{
answer
=
42
};
TEST
(
PrintfTest
,
Enum
)
{
EXPECT_PRINTF
(
"42"
,
"%d"
,
A
);
}
TEST
(
PrintfTest
,
Enum
)
{
EXPECT_PRINTF
(
"42"
,
"%d"
,
answer
);
volatile
test_enum
volatile_enum
=
answer
;
EXPECT_PRINTF
(
"42"
,
"%d"
,
volatile_enum
);
}
#if FMT_USE_FCNTL
#if FMT_USE_FCNTL
TEST
(
PrintfTest
,
Examples
)
{
TEST
(
PrintfTest
,
Examples
)
{
...
@@ -498,7 +502,9 @@ TEST(PrintfTest, PrintfError) {
...
@@ -498,7 +502,9 @@ TEST(PrintfTest, PrintfError) {
TEST
(
PrintfTest
,
WideString
)
{
EXPECT_EQ
(
L"abc"
,
fmt
::
sprintf
(
L"%s"
,
L"abc"
));
}
TEST
(
PrintfTest
,
WideString
)
{
EXPECT_EQ
(
L"abc"
,
fmt
::
sprintf
(
L"%s"
,
L"abc"
));
}
TEST
(
PrintfTest
,
PrintfCustom
)
{
TEST
(
PrintfTest
,
PrintfCustom
)
{
EXPECT_EQ
(
"abc"
,
test_sprintf
(
"%s"
,
TestString
(
"abc"
)));
// The test is disabled for now because it requires decoupling
// fallback_formatter::format from format_context.
//EXPECT_EQ("abc", test_sprintf("%s", TestString("abc")));
}
}
TEST
(
PrintfTest
,
OStream
)
{
TEST
(
PrintfTest
,
OStream
)
{
...
...
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