| 1 |
// { dg-do run } |
| 2 |
// LWG 4084. std::fixed ignores std::uppercase |
| 3 |
// PR libstdc++/114862 std::uppercase not applying to nan's and inf's |
| 4 |
|
| 5 |
#include <sstream> |
| 6 |
#include <limits> |
| 7 |
#include <iomanip> |
| 8 |
#include <testsuite_hooks.h> |
| 9 |
|
| 10 |
void |
| 11 |
test_nan() |
| 12 |
{ |
| 13 |
std::ostringstream out; |
| 14 |
double nan = std::numeric_limits<double>::quiet_NaN(); |
| 15 |
out << std::fixed; |
| 16 |
out << ' ' << nan << ' ' << -nan; |
| 17 |
out << std::uppercase; |
| 18 |
out << ' ' << nan << ' ' << -nan; |
| 19 |
out << std::showpoint; |
| 20 |
out << ' ' << nan << ' ' << -nan; |
| 21 |
out << std::showpos; |
| 22 |
out << ' ' << nan << ' ' << -nan; |
| 23 |
VERIFY( out.str() == " nan -nan NAN -NAN NAN -NAN +NAN -NAN" ); |
| 24 |
} |
| 25 |
|
| 26 |
void |
| 27 |
test_inf() |
| 28 |
{ |
| 29 |
std::ostringstream out; |
| 30 |
double inf = std::numeric_limits<double>::infinity(); |
| 31 |
out << std::fixed; |
| 32 |
out << ' ' << inf << ' ' << -inf; |
| 33 |
out << std::uppercase; |
| 34 |
out << ' ' << inf << ' ' << -inf; |
| 35 |
out << std::showpoint; |
| 36 |
out << ' ' << inf << ' ' << -inf; |
| 37 |
out << std::showpos; |
| 38 |
out << ' ' << inf << ' ' << -inf; |
| 39 |
VERIFY( out.str() == " inf -inf INF -INF INF -INF +INF -INF" ); |
| 40 |
} |
| 41 |
|
| 42 |
int main() |
| 43 |
{ |
| 44 |
test_nan(); |
| 45 |
test_inf(); |
| 46 |
} |