diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-05-08 10:03:20 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2024-08-21 10:16:59 +0100 |
commit | 878bb62cfc158b5324cc2b2476f92fb4237fd82a (patch) | |
tree | 16ca59ef81dbf1c77364e8c94a6145221e8c7f23 /libstdc++-v3/testsuite | |
parent | 723b30bee4e4fa3feba9ef03ce7dca95501e1555 (diff) | |
download | gcc-878bb62cfc158b5324cc2b2476f92fb4237fd82a.zip gcc-878bb62cfc158b5324cc2b2476f92fb4237fd82a.tar.gz gcc-878bb62cfc158b5324cc2b2476f92fb4237fd82a.tar.bz2 |
libstdc++: Check ios::uppercase for ios::fixed floating-point output [PR114862]
This is LWG 4084 which I filed recently. LWG seems to support making the
change, so that std::num_put can use the %F format for floating-point
numbers.
libstdc++-v3/ChangeLog:
PR libstdc++/114862
* src/c++98/locale_facets.cc (__num_base::_S_format_float):
Check uppercase flag for fixed format.
* testsuite/22_locale/num_put/put/char/lwg4084.cc: New test.
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/num_put/put/char/lwg4084.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/lwg4084.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/lwg4084.cc new file mode 100644 index 0000000..b7c7da1 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/lwg4084.cc @@ -0,0 +1,46 @@ +// { dg-do run } +// LWG 4084. std::fixed ignores std::uppercase +// PR libstdc++/114862 std::uppercase not applying to nan's and inf's + +#include <sstream> +#include <limits> +#include <iomanip> +#include <testsuite_hooks.h> + +void +test_nan() +{ + std::ostringstream out; + double nan = std::numeric_limits<double>::quiet_NaN(); + out << std::fixed; + out << ' ' << nan << ' ' << -nan; + out << std::uppercase; + out << ' ' << nan << ' ' << -nan; + out << std::showpoint; + out << ' ' << nan << ' ' << -nan; + out << std::showpos; + out << ' ' << nan << ' ' << -nan; + VERIFY( out.str() == " nan -nan NAN -NAN NAN -NAN +NAN -NAN" ); +} + +void +test_inf() +{ + std::ostringstream out; + double inf = std::numeric_limits<double>::infinity(); + out << std::fixed; + out << ' ' << inf << ' ' << -inf; + out << std::uppercase; + out << ' ' << inf << ' ' << -inf; + out << std::showpoint; + out << ' ' << inf << ' ' << -inf; + out << std::showpos; + out << ' ' << inf << ' ' << -inf; + VERIFY( out.str() == " inf -inf INF -INF INF -INF +INF -INF" ); +} + +int main() +{ + test_nan(); + test_inf(); +} |