-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
- Loading branch information
1 parent
649a4f2
commit e0b8a11
Showing
4 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
RUNALL_INCLUDE ..\usual_matrix.lst |
104 changes: 104 additions & 0 deletions
104
tests/std/tests/LWG4084_iostream_uppercase_inf_nan/test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include <cassert> | ||
#include <cstddef> | ||
#include <limits> | ||
#include <sstream> | ||
#include <type_traits> | ||
|
||
using namespace std; | ||
|
||
template <class CharT, size_t N, enable_if_t<is_same_v<CharT, char>, int> = 0> | ||
constexpr const auto& choose_literal(const char (&s)[N], const wchar_t (&)[N]) noexcept { | ||
return s; | ||
} | ||
template <class CharT, size_t N, enable_if_t<is_same_v<CharT, wchar_t>, int> = 0> | ||
constexpr const auto& choose_literal(const char (&)[N], const wchar_t (&ws)[N]) noexcept { | ||
return ws; | ||
} | ||
|
||
#define STATICALLY_WIDEN(CharT, S) ::choose_literal<CharT>(S, L##S) | ||
|
||
template <class CharT, class F> | ||
void test() { | ||
// LWG-4084 "std::fixed ignores std::uppercase" | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << fixed << uppercase << numeric_limits<F>::infinity()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "INF")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << fixed << uppercase << numeric_limits<F>::quiet_NaN()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "NAN")); | ||
} | ||
// also test other combinations | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << fixed << numeric_limits<F>::infinity()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "inf")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << fixed << numeric_limits<F>::quiet_NaN()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "nan")); | ||
} | ||
|
||
{ | ||
auto s = (basic_ostringstream<CharT>{} << uppercase << numeric_limits<F>::infinity()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "INF")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << uppercase << numeric_limits<F>::quiet_NaN()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "NAN")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << numeric_limits<F>::infinity()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "inf")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << numeric_limits<F>::quiet_NaN()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "nan")); | ||
} | ||
|
||
{ | ||
auto s = (basic_ostringstream<CharT>{} << scientific << uppercase << numeric_limits<F>::infinity()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "INF")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << scientific << uppercase << numeric_limits<F>::quiet_NaN()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "NAN")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << scientific << numeric_limits<F>::infinity()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "inf")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << scientific << numeric_limits<F>::quiet_NaN()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "nan")); | ||
} | ||
|
||
{ | ||
auto s = (basic_ostringstream<CharT>{} << hexfloat << uppercase << numeric_limits<F>::infinity()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "INF")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << hexfloat << uppercase << numeric_limits<F>::quiet_NaN()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "NAN")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << hexfloat << numeric_limits<F>::infinity()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "inf")); | ||
} | ||
{ | ||
auto s = (basic_ostringstream<CharT>{} << hexfloat << numeric_limits<F>::quiet_NaN()).str(); | ||
assert(s == STATICALLY_WIDEN(CharT, "nan")); | ||
} | ||
} | ||
|
||
int main() { | ||
test<char, float>(); | ||
test<char, double>(); | ||
test<char, long double>(); | ||
|
||
test<wchar_t, float>(); | ||
test<wchar_t, double>(); | ||
test<wchar_t, long double>(); | ||
} |