[libcxx-commits] [libcxx] 0289c90 - [NFC][libc++] Fixes some tests on Linux.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 26 08:50:34 PDT 2022
Author: Mark de Wever
Date: 2022-04-26T17:50:17+02:00
New Revision: 0289c90d70fbf97f802f9f471a0530fc6afb836a
URL: https://github.com/llvm/llvm-project/commit/0289c90d70fbf97f802f9f471a0530fc6afb836a
DIFF: https://github.com/llvm/llvm-project/commit/0289c90d70fbf97f802f9f471a0530fc6afb836a.diff
LOG: [NFC][libc++] Fixes some tests on Linux.
The tests are adapted to the output produced on Linux.
Reviewed By: #libc, philnik, ldionne
Differential Revision: https://reviews.llvm.org/D124331
Added:
Modified:
libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
index a189696c1bec6..c3c419851bad6 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
@@ -20,9 +20,6 @@
// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
// ios_base::iostate& err, long double& v) const;
-// TODO For zh_CN GLIBC puts the negative sign after the currency symbol.
-// XFAIL: target={{.*}}-linux-gnu{{.*}}
-
#include <locale>
#include <ios>
#include <streambuf>
@@ -324,7 +321,11 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative one, showbase
+#ifdef TEST_HAS_GLIBC
+ std::string v = "-" + currency_name + "0.01";
+#else
std::string v = currency_name + "-0.01";
+#endif
typedef cpp17_input_iterator<const char*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -335,7 +336,11 @@ int main(int, char**)
assert(ex == -1);
}
{ // negative one, showbase
+#ifdef TEST_HAS_GLIBC
+ std::string v = "-" + currency_name + "0.01";
+#else
std::string v = currency_name + "-0.01";
+#endif
std::showbase(ios);
typedef cpp17_input_iterator<const char*> I;
long double ex;
@@ -372,7 +377,11 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
+#ifdef TEST_HAS_GLIBC
+ std::string v = "-" + currency_name + "1,234,567.89";
+#else
std::string v = currency_name + "-1,234,567.89";
+#endif
std::showbase(ios);
typedef cpp17_input_iterator<const char*> I;
long double ex;
@@ -663,7 +672,11 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative one, showbase
+#ifdef TEST_HAS_GLIBC
+ std::wstring v = L"-" + w_currency_name + L"0.01";
+#else
std::wstring v = w_currency_name + L"-0.01";
+#endif
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -674,7 +687,11 @@ int main(int, char**)
assert(ex == -1);
}
{ // negative one, showbase
+#ifdef TEST_HAS_GLIBC
+ std::wstring v = L"-" + w_currency_name + L"0.01";
+#else
std::wstring v = w_currency_name + L"-0.01";
+#endif
std::showbase(ios);
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
@@ -711,7 +728,11 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
+#ifdef TEST_HAS_GLIBC
+ std::wstring v = L"-" + w_currency_name + L"1,234,567.89";
+#else
std::wstring v = w_currency_name + L"-1,234,567.89";
+#endif
std::showbase(ios);
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
index e9b459e127c84..446657bb31560 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
@@ -20,9 +20,6 @@
// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
// long double units) const;
-// TODO For zh_CN GLIBC puts the negative sign after the currency symbol.
-// XFAIL: target={{.*}}-linux-gnu{{.*}}
-
#include <locale>
#include <ios>
#include <streambuf>
@@ -219,7 +216,11 @@ int main(int, char**)
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), true, ios, '*', v);
std::string ex(str, base(iter));
+#ifdef TEST_HAS_GLIBC
+ assert(ex == "-" + currency_name + "0.01");
+#else
assert(ex == currency_name + "-0.01");
+#endif
}
{ // positive, showbase
long double v = 123456789;
@@ -235,7 +236,11 @@ int main(int, char**)
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), true, ios, '*', v);
std::string ex(str, base(iter));
+#ifdef TEST_HAS_GLIBC
+ assert(ex == "-" + currency_name + "1,234,567.89");
+#else
assert(ex == currency_name + "-1,234,567.89");
+#endif
}
{ // negative, showbase, left
long double v = -123456789;
@@ -245,7 +250,11 @@ int main(int, char**)
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), true, ios, ' ', v);
std::string ex(str, base(iter));
+#ifdef TEST_HAS_GLIBC
+ assert(ex == "-" + currency_name + "1,234,567.89" + currency_name_padding);
+#else
assert(ex == currency_name + "-1,234,567.89" + currency_name_padding);
+#endif
assert(ios.width() == 0);
}
{ // negative, showbase, internal
@@ -256,7 +265,11 @@ int main(int, char**)
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), true, ios, ' ', v);
std::string ex(str, base(iter));
+#ifdef TEST_HAS_GLIBC
+ assert(ex == "-" + currency_name + currency_name_padding + "1,234,567.89");
+#else
assert(ex == currency_name + "-" + currency_name_padding + "1,234,567.89");
+#endif
assert(ios.width() == 0);
}
{ // negative, showbase, right
@@ -267,7 +280,11 @@ int main(int, char**)
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), true, ios, ' ', v);
std::string ex(str, base(iter));
+#ifdef TEST_HAS_GLIBC
+ assert(ex == currency_name_padding + "-" + currency_name + "1,234,567.89");
+#else
assert(ex == currency_name_padding + currency_name + "-1,234,567.89");
+#endif
assert(ios.width() == 0);
}
}
@@ -423,7 +440,11 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, '*', v);
std::wstring ex(str, base(iter));
+#ifdef TEST_HAS_GLIBC
+ assert(ex == L"-" + currency_name + L"0.01");
+#else
assert(ex == currency_name + L"-0.01");
+#endif
}
{ // positive, showbase
long double v = 123456789;
@@ -439,7 +460,11 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, '*', v);
std::wstring ex(str, base(iter));
+#ifdef TEST_HAS_GLIBC
+ assert(ex == L"-" + currency_name + L"1,234,567.89");
+#else
assert(ex == currency_name + L"-1,234,567.89");
+#endif
}
{ // negative, showbase, left
long double v = -123456789;
@@ -449,7 +474,11 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, ' ', v);
std::wstring ex(str, base(iter));
+#ifdef TEST_HAS_GLIBC
+ assert(ex == L"-" + currency_name + L"1,234,567.89" + currency_name_padding);
+#else
assert(ex == currency_name + L"-1,234,567.89" + currency_name_padding);
+#endif
assert(ios.width() == 0);
}
{ // negative, showbase, internal
@@ -460,7 +489,11 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, ' ', v);
std::wstring ex(str, base(iter));
+#ifdef TEST_HAS_GLIBC
+ assert(ex == L"-" + currency_name + currency_name_padding + L"1,234,567.89");
+#else
assert(ex == currency_name + L"-" + currency_name_padding + L"1,234,567.89");
+#endif
assert(ios.width() == 0);
}
{ // negative, showbase, right
@@ -471,7 +504,11 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, ' ', v);
std::wstring ex(str, base(iter));
+#ifdef TEST_HAS_GLIBC
+ assert(ex == currency_name_padding + L"-" + currency_name + L"1,234,567.89");
+#else
assert(ex == currency_name_padding + currency_name + L"-1,234,567.89");
+#endif
assert(ios.width() == 0);
}
}
diff --git a/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp b/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
index 33d7ce0d900ec..79bcf1b6017ff 100644
--- a/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
@@ -15,9 +15,6 @@
// REQUIRES: locale.ru_RU.UTF-8
// REQUIRES: locale.zh_CN.UTF-8
-// GLIBC fails on the zh_CN test.
-// XFAIL: linux
-
// <locale>
// class time_get_byname<charT, InputIterator>
@@ -90,10 +87,14 @@ int main(int, char**)
assert(t.tm_year == 109);
assert(err == std::ios_base::eofbit);
}
-
{
const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+#ifdef TEST_HAS_GLIBC
+ // There's no separator between month and day.
+ const char in[] = "2009\u5e740610";
+#else
const char in[] = "2009/06/10";
+#endif
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
@@ -103,6 +104,5 @@ int main(int, char**)
assert(t.tm_year == 109);
assert(err == std::ios_base::eofbit);
}
-
return 0;
}
diff --git a/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp b/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
index 3b89de9a78119..2691bb42c58d7 100644
--- a/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
@@ -17,9 +17,6 @@
// REQUIRES: locale.ru_RU.UTF-8
// REQUIRES: locale.zh_CN.UTF-8
-// GLIBC fails on the zh_CN test.
-// XFAIL: linux
-
// <locale>
// class time_get_byname<charT, InputIterator>
@@ -94,7 +91,12 @@ int main(int, char**)
}
{
const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+#ifdef TEST_HAS_GLIBC
+ // There's no separator between month and day.
+ const wchar_t in[] = L"2009\u5e740610";
+#else
const wchar_t in[] = L"2009/06/10";
+#endif
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
@@ -104,6 +106,5 @@ int main(int, char**)
assert(t.tm_year == 109);
assert(err == std::ios_base::eofbit);
}
-
return 0;
}
diff --git a/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp b/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
index dcbef8d2aebf3..bdc4653ad0d28 100644
--- a/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
@@ -21,9 +21,6 @@
// get_weekday(iter_type s, iter_type end, ios_base& str,
// ios_base::iostate& err, tm* t) const;
-// TODO: investigation needed
-// XFAIL: target={{.*}}-linux-gnu{{.*}}
-
#include <locale>
#include <cassert>
#include "test_macros.h"
@@ -70,7 +67,11 @@ int main(int, char**)
}
{
const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+#if defined(TEST_HAS_GLIBC)
+ const wchar_t in[] = L"\x41F\x43E\x43D\x435\x434\x435\x43B\x44C\x43D\x438\x43A";
+#else
const wchar_t in[] = L"\x43F\x43E\x43D\x435\x434\x435\x43B\x44C\x43D\x438\x43A";
+#endif
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
More information about the libcxx-commits
mailing list