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
227bfe62
Commit
227bfe62
authored
Dec 01, 2019
by
Florin Iucha
Committed by
Victor Zverovich
Dec 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean-up sign-conversion warnings in test code
parent
95dfdc6c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
24 deletions
+26
-24
test/format-impl-test.cc
test/format-impl-test.cc
+1
-1
test/format-test.cc
test/format-test.cc
+10
-10
test/printf-test.cc
test/printf-test.cc
+7
-6
test/scan.h
test/scan.h
+8
-7
No files found.
test/format-impl-test.cc
View file @
227bfe62
...
...
@@ -277,7 +277,7 @@ TEST(FPTest, GetRoundDirection) {
EXPECT_EQ
(
fmt
::
internal
::
up
,
get_round_direction
(
100
,
51
,
0
));
EXPECT_EQ
(
fmt
::
internal
::
down
,
get_round_direction
(
100
,
40
,
10
));
EXPECT_EQ
(
fmt
::
internal
::
up
,
get_round_direction
(
100
,
60
,
10
));
for
(
in
t
i
=
41
;
i
<
60
;
++
i
)
for
(
size_
t
i
=
41
;
i
<
60
;
++
i
)
EXPECT_EQ
(
fmt
::
internal
::
unknown
,
get_round_direction
(
100
,
i
,
10
));
uint64_t
max
=
max_value
<
uint64_t
>
();
EXPECT_THROW
(
get_round_direction
(
100
,
100
,
0
),
assertion_failure
);
...
...
test/format-test.cc
View file @
227bfe62
...
...
@@ -1875,7 +1875,7 @@ TEST(FormatTest, Dynamic) {
std
::
string
result
=
fmt
::
vformat
(
"{} and {} and {}"
,
fmt
::
basic_format_args
<
ctx
>
(
args
.
data
(),
static_cast
<
unsigned
>
(
args
.
size
())));
args
.
data
(),
static_cast
<
int
>
(
args
.
size
())));
EXPECT_EQ
(
"42 and abc1 and 1.5"
,
result
);
}
...
...
@@ -2189,12 +2189,12 @@ TEST(FormatTest, WideFormatToN) {
struct
test_arg_id_handler
{
enum
result
{
NONE
,
EMPTY
,
INDEX
,
NAME
,
ERROR
};
result
res
=
NONE
;
unsigned
index
=
0
;
int
index
=
0
;
string_view
name
;
FMT_CONSTEXPR
void
operator
()()
{
res
=
EMPTY
;
}
FMT_CONSTEXPR
void
operator
()(
unsigned
i
)
{
FMT_CONSTEXPR
void
operator
()(
int
i
)
{
res
=
INDEX
;
index
=
i
;
}
...
...
@@ -2230,9 +2230,9 @@ struct test_format_specs_handler {
fmt
::
align_t
align
=
fmt
::
align
::
none
;
char
fill
=
0
;
unsigned
width
=
0
;
int
width
=
0
;
fmt
::
internal
::
arg_ref
<
char
>
width_ref
;
unsigned
precision
=
0
;
int
precision
=
0
;
fmt
::
internal
::
arg_ref
<
char
>
precision_ref
;
char
type
=
0
;
...
...
@@ -2258,14 +2258,14 @@ struct test_format_specs_handler {
FMT_CONSTEXPR
void
on_hash
()
{
res
=
HASH
;
}
FMT_CONSTEXPR
void
on_zero
()
{
res
=
ZERO
;
}
FMT_CONSTEXPR
void
on_width
(
unsigned
w
)
{
width
=
w
;
}
FMT_CONSTEXPR
void
on_width
(
int
w
)
{
width
=
w
;
}
FMT_CONSTEXPR
void
on_dynamic_width
(
fmt
::
internal
::
auto_id
)
{}
FMT_CONSTEXPR
void
on_dynamic_width
(
unsigned
index
)
{
width_ref
=
index
;
}
FMT_CONSTEXPR
void
on_dynamic_width
(
int
index
)
{
width_ref
=
index
;
}
FMT_CONSTEXPR
void
on_dynamic_width
(
string_view
)
{}
FMT_CONSTEXPR
void
on_precision
(
unsigned
p
)
{
precision
=
p
;
}
FMT_CONSTEXPR
void
on_precision
(
int
p
)
{
precision
=
p
;
}
FMT_CONSTEXPR
void
on_dynamic_precision
(
fmt
::
internal
::
auto_id
)
{}
FMT_CONSTEXPR
void
on_dynamic_precision
(
unsigned
index
)
{
FMT_CONSTEXPR
void
on_dynamic_precision
(
int
index
)
{
precision_ref
=
index
;
}
FMT_CONSTEXPR
void
on_dynamic_precision
(
string_view
)
{}
...
...
@@ -2302,7 +2302,7 @@ TEST(FormatTest, ConstexprParseFormatSpecs) {
struct
test_parse_context
{
typedef
char
char_type
;
FMT_CONSTEXPR
unsigned
next_arg_id
()
{
return
11
;
}
FMT_CONSTEXPR
int
next_arg_id
()
{
return
11
;
}
template
<
typename
Id
>
FMT_CONSTEXPR
void
check_arg_id
(
Id
)
{}
FMT_CONSTEXPR
const
char
*
begin
()
{
return
nullptr
;
}
...
...
test/printf-test.cc
View file @
227bfe62
...
...
@@ -5,12 +5,13 @@
//
// For the license information refer to format.h.
#include "fmt/printf.h"
#include <cctype>
#include <climits>
#include <cstring>
#include "fmt/core.h"
#include "fmt/printf.h"
#include "gtest-extra.h"
#include "util.h"
...
...
@@ -300,15 +301,15 @@ void TestLength(const char* length_spec, U value) {
using
fmt
::
internal
::
const_check
;
if
(
const_check
(
max
<=
static_cast
<
unsigned
>
(
max_value
<
int
>
())))
{
signed_value
=
static_cast
<
int
>
(
value
);
unsigned_value
=
static_cast
<
unsigned
>
(
value
);
unsigned_value
=
static_cast
<
unsigned
long
long
>
(
value
);
}
else
if
(
const_check
(
max
<=
max_value
<
unsigned
>
()))
{
signed_value
=
static_cast
<
unsigned
>
(
value
);
unsigned_value
=
static_cast
<
unsigned
>
(
value
);
unsigned_value
=
static_cast
<
unsigned
long
long
>
(
value
);
}
if
(
sizeof
(
U
)
<=
sizeof
(
int
)
&&
sizeof
(
int
)
<
sizeof
(
T
))
{
signed_value
=
static_cast
<
long
long
>
(
value
);
unsigned_value
=
static_cast
<
typename
std
::
make_unsigned
<
unsigned
>::
type
>
(
value
);
unsigned_value
=
static_cast
<
unsigned
long
long
>
(
static_cast
<
typename
std
::
make_unsigned
<
unsigned
>::
type
>
(
value
)
)
;
}
else
{
signed_value
=
static_cast
<
typename
make_signed
<
T
>::
type
>
(
value
);
unsigned_value
=
static_cast
<
typename
std
::
make_unsigned
<
T
>::
type
>
(
value
);
...
...
@@ -589,7 +590,7 @@ class custom_printf_arg_formatter : public formatter_t {
if
(
round
(
value
*
pow
(
10
,
specs
()
->
precision
))
==
0.0
)
value
=
0
;
return
formatter_t
::
operator
()(
value
);
}
}
;
}
typedef
fmt
::
basic_format_args
<
context_t
>
format_args_t
;
...
...
test/scan.h
View file @
227bfe62
...
...
@@ -6,6 +6,8 @@
// For the license information refer to format.h.
#include <array>
#include <cassert>
#include <climits>
#include "fmt/format.h"
...
...
@@ -135,21 +137,20 @@ struct scan_handler : error_handler {
char
c
=
*
it
++
;
if
(
c
<
'0'
||
c
>
'9'
)
on_error
(
"invalid input"
);
// TODO: check overflow
value
=
value
*
10
+
(
c
-
'0'
);
value
=
value
*
10
+
static_cast
<
unsigned
>
(
c
-
'0'
);
}
scan_ctx_
.
advance_to
(
it
);
return
value
;
}
template
<
typename
T
=
int
>
T
read_int
()
{
T
value
=
0
;
auto
it
=
scan_ctx_
.
begin
(),
end
=
scan_ctx_
.
end
();
bool
negative
=
it
!=
end
&&
*
it
==
'-'
;
if
(
negative
)
++
it
;
scan_ctx_
.
advance_to
(
it
);
value
=
read_uint
<
typename
std
::
make_unsigned
<
T
>::
type
>
();
if
(
negative
)
value
=
-
value
;
return
value
;
const
auto
value
=
read_uint
<
typename
std
::
make_unsigned
<
T
>::
type
>
();
if
(
negative
)
return
-
static_cast
<
T
>
(
value
)
;
return
static_cast
<
T
>
(
value
)
;
}
public:
...
...
@@ -159,7 +160,7 @@ struct scan_handler : error_handler {
const
char
*
pos
()
const
{
return
scan_ctx_
.
begin
();
}
void
on_text
(
const
char
*
begin
,
const
char
*
end
)
{
auto
size
=
end
-
begin
;
auto
size
=
to_unsigned
(
end
-
begin
)
;
auto
it
=
scan_ctx_
.
begin
();
if
(
it
+
size
>
scan_ctx_
.
end
()
||
!
std
::
equal
(
begin
,
end
,
make_checked
(
it
,
size
)))
{
...
...
@@ -197,7 +198,7 @@ struct scan_handler : error_handler {
case
scan_type
:
:
string_view_type
:
{
auto
s
=
it
;
while
(
it
!=
end
&&
*
it
!=
' '
)
++
it
;
*
arg_
.
string_view
=
fmt
::
string_view
(
s
,
it
-
s
);
*
arg_
.
string_view
=
fmt
::
string_view
(
s
,
to_unsigned
(
it
-
s
)
);
scan_ctx_
.
advance_to
(
it
);
break
;
}
...
...
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