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
e1bd6cc9
Commit
e1bd6cc9
authored
Sep 26, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor FP formatting
parent
027fcaf0
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
115 deletions
+93
-115
include/fmt/format-inl.h
include/fmt/format-inl.h
+86
-105
test/format-impl-test.cc
test/format-impl-test.cc
+7
-10
No files found.
include/fmt/format-inl.h
View file @
e1bd6cc9
This diff is collapsed.
Click to expand it.
test/format-impl-test.cc
View file @
e1bd6cc9
...
@@ -278,25 +278,22 @@ TEST(fp_test, get_round_direction) {
...
@@ -278,25 +278,22 @@ TEST(fp_test, get_round_direction) {
}
}
TEST
(
fp_test
,
fixed_handler
)
{
TEST
(
fp_test
,
fixed_handler
)
{
struct
handler
:
fmt
::
detail
::
fixed
_handler
{
struct
handler
:
fmt
::
detail
::
gen_digits
_handler
{
char
buffer
[
10
];
char
buffer
[
10
];
handler
(
int
prec
=
0
)
:
fmt
::
detail
::
fixed
_handler
()
{
handler
(
int
prec
=
0
)
:
fmt
::
detail
::
gen_digits
_handler
()
{
buf
=
buffer
;
buf
=
buffer
;
precision
=
prec
;
precision
=
prec
;
}
}
};
};
int
exp
=
0
;
handler
().
on_digit
(
'0'
,
100
,
99
,
0
,
false
);
handler
().
on_digit
(
'0'
,
100
,
99
,
0
,
exp
,
false
);
EXPECT_THROW
(
handler
().
on_digit
(
'0'
,
100
,
100
,
0
,
false
),
assertion_failure
);
EXPECT_THROW
(
handler
().
on_digit
(
'0'
,
100
,
100
,
0
,
exp
,
false
),
assertion_failure
);
namespace
digits
=
fmt
::
detail
::
digits
;
namespace
digits
=
fmt
::
detail
::
digits
;
EXPECT_EQ
(
handler
(
1
).
on_digit
(
'0'
,
100
,
10
,
10
,
exp
,
false
),
digits
::
error
);
EXPECT_EQ
(
handler
(
1
).
on_digit
(
'0'
,
100
,
10
,
10
,
false
),
digits
::
error
);
// Check that divisor - error doesn't overflow.
// Check that divisor - error doesn't overflow.
EXPECT_EQ
(
handler
(
1
).
on_digit
(
'0'
,
100
,
10
,
101
,
exp
,
false
),
digits
::
error
);
EXPECT_EQ
(
handler
(
1
).
on_digit
(
'0'
,
100
,
10
,
101
,
false
),
digits
::
error
);
// Check that 2 * error doesn't overflow.
// Check that 2 * error doesn't overflow.
uint64_t
max
=
max_value
<
uint64_t
>
();
uint64_t
max
=
max_value
<
uint64_t
>
();
EXPECT_EQ
(
handler
(
1
).
on_digit
(
'0'
,
max
,
10
,
max
-
1
,
exp
,
false
),
EXPECT_EQ
(
handler
(
1
).
on_digit
(
'0'
,
max
,
10
,
max
-
1
,
false
),
digits
::
error
);
digits
::
error
);
}
}
TEST
(
fp_test
,
grisu_format_compiles_with_on_ieee_double
)
{
TEST
(
fp_test
,
grisu_format_compiles_with_on_ieee_double
)
{
...
...
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