-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix num_get's float-parsing problem
#3982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -532,6 +532,23 @@ void test_gh_3378() { | |
| } | ||
| } | ||
|
|
||
| // Also test GH-3980 <iostream>: Wrong reading of float values | ||
| template <class Flt> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not worth resetting testing: vwls pls.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| void test_gh_3980() { | ||
| auto test_case = [](const char* str, double expected) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not worth resetting testing: there are a log of |
||
| Flt val = 0; | ||
| istringstream{str} >> val; | ||
| assert((ostringstream{} << val).str() == (ostringstream{} << expected).str()); | ||
| }; | ||
|
|
||
| test_case("0x1p+07", 0x1p+07); | ||
| test_case("1e+07", 1e+07); | ||
| test_case("1e+0", 1); | ||
| test_case("1e-0", 1); | ||
| test_case("1e-07", 1e-07); | ||
| test_case("0x1p-07", 0x1p-07); | ||
| } | ||
|
|
||
| #if _HAS_CXX17 | ||
| void test_float_from_char_cases() { | ||
| for (const auto& test_case : float_from_chars_test_cases) { | ||
|
|
@@ -589,6 +606,10 @@ int main() { | |
| test_gh_3378<double>(); | ||
| test_gh_3378<long double>(); | ||
|
|
||
| test_gh_3980<float>(); | ||
| test_gh_3980<double>(); | ||
| test_gh_3980<long double>(); | ||
|
|
||
| #if _HAS_CXX17 | ||
| test_float_from_char_cases(); | ||
| test_double_from_char_cases<double>(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.