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
7fbbfed8
Commit
7fbbfed8
authored
Jan 31, 2019
by
Elias Kosunen
Committed by
Victor Zverovich
Feb 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warnings caused by usage of deprecated functionality
parent
c3268f4e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
11 deletions
+34
-11
include/fmt/core.h
include/fmt/core.h
+5
-1
test/format-impl-test.cc
test/format-impl-test.cc
+4
-3
test/format-test.cc
test/format-test.cc
+20
-1
test/ostream-test.cc
test/ostream-test.cc
+5
-6
No files found.
include/fmt/core.h
View file @
7fbbfed8
...
...
@@ -1076,7 +1076,11 @@ class context_base {
public:
basic_parse_context
<
char_type
>&
parse_context
()
{
return
parse_context_
;
}
FMT_DEPRECATED
basic_format_args
<
Context
>
args
()
const
{
return
args_
;
}
// basic_format_context::arg() depends on this
// Cannot be marked as deprecated without causing warnings
/*FMT_DEPRECATED*/
basic_format_args
<
Context
>
args
()
const
{
return
args_
;
}
basic_format_arg
<
Context
>
arg
(
unsigned
id
)
const
{
return
args_
.
get
(
id
);
}
internal
::
error_handler
error_handler
()
{
...
...
test/format-impl-test.cc
View file @
7fbbfed8
...
...
@@ -116,9 +116,10 @@ template <typename T> struct ValueExtractor : fmt::internal::function<T> {
TEST
(
FormatTest
,
ArgConverter
)
{
long
long
value
=
std
::
numeric_limits
<
long
long
>::
max
();
auto
arg
=
fmt
::
internal
::
make_arg
<
fmt
::
format_context
>
(
value
);
visit
(
fmt
::
internal
::
arg_converter
<
long
long
,
fmt
::
format_context
>
(
arg
,
'd'
),
arg
);
EXPECT_EQ
(
value
,
visit
(
ValueExtractor
<
long
long
>
(),
arg
));
fmt
::
visit_format_arg
(
fmt
::
internal
::
arg_converter
<
long
long
,
fmt
::
format_context
>
(
arg
,
'd'
),
arg
);
EXPECT_EQ
(
value
,
fmt
::
visit_format_arg
(
ValueExtractor
<
long
long
>
(),
arg
));
}
TEST
(
FormatTest
,
FormatNegativeNaN
)
{
...
...
test/format-test.cc
View file @
7fbbfed8
...
...
@@ -1720,13 +1720,32 @@ TEST(FormatIntTest, FormatInt) {
fmt
::
format_int
(
std
::
numeric_limits
<
int64_t
>::
max
()).
str
());
}
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#if FMT_MSC_VER
#pragma warning(push)
#pragma warning(disable: 4996) // Using a deprecated function
#endif
template
<
typename
T
>
std
::
string
format_decimal
(
T
value
)
{
char
buffer
[
10
];
char
*
ptr
=
buffer
;
fmt
::
format_decimal
(
ptr
,
value
);
// TODO: Replace with safer, non-deprecated overload
fmt
::
format_decimal
(
ptr
,
value
);
return
std
::
string
(
buffer
,
ptr
);
}
#if FMT_MSC_VER
#pragma warning(pop)
#endif
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
TEST
(
FormatIntTest
,
FormatDec
)
{
EXPECT_EQ
(
"-42"
,
format_decimal
(
static_cast
<
signed
char
>
(
-
42
)));
EXPECT_EQ
(
"-42"
,
format_decimal
(
static_cast
<
short
>
(
-
42
)));
...
...
test/ostream-test.cc
View file @
7fbbfed8
...
...
@@ -59,7 +59,8 @@ TEST(OStreamTest, CustomArg) {
fmt
::
format_context
ctx
(
std
::
back_inserter
(
base
),
""
,
fmt
::
format_args
());
fmt
::
format_specs
spec
;
test_arg_formatter
af
(
ctx
,
spec
);
visit
(
af
,
fmt
::
internal
::
make_arg
<
fmt
::
format_context
>
(
TestEnum
()));
fmt
::
visit_format_arg
(
af
,
fmt
::
internal
::
make_arg
<
fmt
::
format_context
>
(
TestEnum
()));
EXPECT_EQ
(
"TestEnum"
,
std
::
string
(
buffer
.
data
(),
buffer
.
size
()));
}
...
...
@@ -178,8 +179,7 @@ template <typename Output> Output& operator<<(Output& out, ABC) {
}
}
// namespace fmt_test
template
<
typename
T
>
struct
TestTemplate
{};
template
<
typename
T
>
struct
TestTemplate
{};
template
<
typename
T
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
TestTemplate
<
T
>
)
{
...
...
@@ -187,14 +187,13 @@ std::ostream& operator<<(std::ostream& os, TestTemplate<T>) {
}
namespace
fmt
{
template
<
typename
T
>
struct
formatter
<
TestTemplate
<
T
>>
:
formatter
<
int
>
{
template
<
typename
T
>
struct
formatter
<
TestTemplate
<
T
>>
:
formatter
<
int
>
{
template
<
typename
FormatContext
>
typename
FormatContext
::
iterator
format
(
TestTemplate
<
T
>
,
FormatContext
&
ctx
)
{
return
formatter
<
int
>::
format
(
2
,
ctx
);
}
};
}
}
// namespace fmt
#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 407
TEST
(
OStreamTest
,
Template
)
{
...
...
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