From ece0f70664af27f38f3538587903096a5cb1e3d9 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Tue, 8 Feb 2022 18:32:08 +0100 Subject: [PATCH] [libc++] Enables put_long_double test for glibc. Glibc adds a +-sign for NaN-values when showpos fmtflags are set. [tab:ios.fmtflags] showpos generates a + sign in non-negative generated numeric output Since NaNs aren't negative this behaviour seems correct. Enable the test for glibc and add ifdefs to make sure the existing tests still pass. This was noticed while working on D118971. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D119260 --- .../facet.num.put.members/put_long_double.pass.cpp | 131 ++++++++++++++++++++- 1 file changed, 128 insertions(+), 3 deletions(-) diff --git a/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp b/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp index f90d7e4..b46a339 100644 --- a/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp +++ b/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp @@ -12,9 +12,6 @@ // iter_type put(iter_type s, ios_base& iob, char_type fill, long double v) const; -// TODO GLIBC uses a different string for positive and negative NAN numbers. -// XFAIL: target={{.*}}-linux-gnu{{.*}} - // XFAIL: LIBCXX-WINDOWS-FIXME // XFAIL: LIBCXX-AIX-FIXME @@ -10884,7 +10881,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+nan"); +#else assert(ex == "nan"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -10892,7 +10893,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+nan*********************"); +#else assert(ex == "nan**********************"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -10900,7 +10905,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "*********************+nan"); +#else assert(ex == "**********************nan"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -10908,7 +10917,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+*********************nan"); +#else assert(ex == "**********************nan"); +#endif assert(ios.width() == 0); } } @@ -10918,7 +10931,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+nan"); +#else assert(ex == "nan"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -10926,7 +10943,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+nan*********************"); +#else assert(ex == "nan**********************"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -10934,7 +10955,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "*********************+nan"); +#else assert(ex == "**********************nan"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -10942,7 +10967,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+*********************nan"); +#else assert(ex == "**********************nan"); +#endif assert(ios.width() == 0); } } @@ -10955,7 +10984,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+nan"); +#else assert(ex == "nan"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -10963,7 +10996,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+nan*********************"); +#else assert(ex == "nan**********************"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -10971,7 +11008,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "*********************+nan"); +#else assert(ex == "**********************nan"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -10979,7 +11020,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+*********************nan"); +#else assert(ex == "**********************nan"); +#endif assert(ios.width() == 0); } } @@ -10989,7 +11034,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+nan"); +#else assert(ex == "nan"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -10997,7 +11046,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+nan*********************"); +#else assert(ex == "nan**********************"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11005,7 +11058,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "*********************+nan"); +#else assert(ex == "**********************nan"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11013,7 +11070,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+*********************nan"); +#else assert(ex == "**********************nan"); +#endif assert(ios.width() == 0); } } @@ -11177,7 +11238,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+NAN"); +#else assert(ex == "NAN"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11185,7 +11250,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+NAN*********************"); +#else assert(ex == "NAN**********************"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11193,7 +11262,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "*********************+NAN"); +#else assert(ex == "**********************NAN"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11201,7 +11274,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+*********************NAN"); +#else assert(ex == "**********************NAN"); +#endif assert(ios.width() == 0); } } @@ -11211,7 +11288,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+NAN"); +#else assert(ex == "NAN"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11219,7 +11300,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+NAN*********************"); +#else assert(ex == "NAN**********************"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11227,7 +11312,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "*********************+NAN"); +#else assert(ex == "**********************NAN"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11235,7 +11324,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+*********************NAN"); +#else assert(ex == "**********************NAN"); +#endif assert(ios.width() == 0); } } @@ -11248,7 +11341,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+NAN"); +#else assert(ex == "NAN"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11256,7 +11353,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+NAN*********************"); +#else assert(ex == "NAN**********************"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11264,7 +11365,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "*********************+NAN"); +#else assert(ex == "**********************NAN"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11272,7 +11377,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+*********************NAN"); +#else assert(ex == "**********************NAN"); +#endif assert(ios.width() == 0); } } @@ -11282,7 +11391,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+NAN"); +#else assert(ex == "NAN"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11290,7 +11403,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+NAN*********************"); +#else assert(ex == "NAN**********************"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11298,7 +11415,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "*********************+NAN"); +#else assert(ex == "**********************NAN"); +#endif assert(ios.width() == 0); } ios.width(25); @@ -11306,7 +11427,11 @@ void test5() { cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), ios, '*', v); std::string ex(str, iter.base()); +#if defined(TEST_HAS_GLIBC) + assert(ex == "+*********************NAN"); +#else assert(ex == "**********************NAN"); +#endif assert(ios.width() == 0); } } -- 2.7.4