[libcxx-commits] [libcxx] [libcxx][test][AIX] address more platform differences in locale tests (PR #94826)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jun 7 18:36:24 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: David Tenty (daltenty)
<details>
<summary>Changes</summary>
This is a follow on to https://github.com/llvm/llvm-project/pull/92312, where we address some more locale platform differences. These are:
- for locale fr_FR AIX libc expects `U202F` as `LC_MONETARY` `thousands_sep`
- for locale zh_CN AIX libc `LC_MONETARY` has `n_sign_posn == 1`, indicating the `negative_sign` should come before the `currency_symbol` string
---
Patch is 29.32 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94826.diff
4 Files Affected:
- (modified) libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp (+21-16)
- (modified) libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp (+30-7)
- (modified) libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp (+21-16)
- (modified) libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp (+50-11)
``````````diff
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
index 3effa80e7d6f7..1ce64ee218738 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
@@ -11,8 +11,6 @@
// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd
-// XFAIL: LIBCXX-AIX-FIXME
-
// REQUIRES: locale.fr_FR.UTF-8
// <locale>
@@ -32,6 +30,13 @@
#include "platform_support.h" // locale name macros
#include "test_macros.h"
+#ifdef _AIX
+// the AIX libc expects U202F as LC_MONETARY thousands_sep
+#define THOUSANDS_SEP L"\u202F"
+#else
+#define THOUSANDS_SEP L" "
+#endif
+
typedef std::money_get<char, cpp17_input_iterator<const char*> > Fn;
class my_facet
@@ -432,7 +437,7 @@ int main(int, char**)
assert(ex == -1);
}
{ // positive
- std::wstring v = convert_thousands_sep(L"1 234 567,89 ");
+ std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 ");
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -443,7 +448,7 @@ int main(int, char**)
assert(ex == 123456789);
}
{ // negative
- std::wstring v = convert_thousands_sep(L"-1 234 567,89");
+ std::wstring v = convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89");
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -512,7 +517,7 @@ int main(int, char**)
assert(ex == -1);
}
{ // positive, showbase
- std::wstring v = convert_thousands_sep(L"1 234 567,89 \u20ac"); // EURO SIGN
+ std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac"); // EURO SIGN
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -523,7 +528,7 @@ int main(int, char**)
assert(ex == 123456789);
}
{ // positive, showbase
- std::wstring v = convert_thousands_sep(L"1 234 567,89 \u20ac"); // EURO SIGN
+ std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac"); // EURO SIGN
std::showbase(ios);
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
@@ -536,7 +541,7 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
- std::wstring v = convert_thousands_sep(L"-1 234 567,89 \u20ac"); // EURO SIGN
+ std::wstring v = convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac"); // EURO SIGN
std::showbase(ios);
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
@@ -549,7 +554,7 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
- std::wstring v = convert_thousands_sep(L"1 234 567,89 EUR -");
+ std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR -");
std::showbase(ios);
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
@@ -561,7 +566,7 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
- std::wstring v = convert_thousands_sep(L"1 234 567,89 EUR -");
+ std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR -");
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -598,7 +603,7 @@ int main(int, char**)
assert(ex == -1);
}
{ // positive
- std::wstring v = convert_thousands_sep(L"1 234 567,89 ");
+ std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 ");
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -609,7 +614,7 @@ int main(int, char**)
assert(ex == 123456789);
}
{ // negative
- std::wstring v = convert_thousands_sep(L"-1 234 567,89");
+ std::wstring v = convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89");
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -678,7 +683,7 @@ int main(int, char**)
assert(ex == -1);
}
{ // positive, showbase
- std::wstring v = convert_thousands_sep(L"1 234 567,89 EUR");
+ std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR");
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -689,7 +694,7 @@ int main(int, char**)
assert(ex == 123456789);
}
{ // positive, showbase
- std::wstring v = convert_thousands_sep(L"1 234 567,89 EUR");
+ std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR");
std::showbase(ios);
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
@@ -702,7 +707,7 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
- std::wstring v = convert_thousands_sep(L"-1 234 567,89 EUR");
+ std::wstring v = convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR");
std::showbase(ios);
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
@@ -715,7 +720,7 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
- std::wstring v = convert_thousands_sep(L"1 234 567,89 Eu-");
+ std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 Eu-");
std::showbase(ios);
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
@@ -727,7 +732,7 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
- std::wstring v = convert_thousands_sep(L"1 234 567,89 Eu-");
+ std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 Eu-");
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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 4cdb25728af7d..3db6370b911d4 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
@@ -9,7 +9,6 @@
// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd
-// XFAIL: LIBCXX-AIX-FIXME
// XFAIL: LIBCXX-FREEBSD-FIXME
// REQUIRES: locale.zh_CN.UTF-8
@@ -156,7 +155,11 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative one, showbase
+#ifdef _AIX
+ std::string v = "-" + currency_symbol + "0.01";
+#else
std::string v = currency_symbol + "-0.01";
+#endif
typedef cpp17_input_iterator<const char*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -167,7 +170,11 @@ int main(int, char**)
assert(ex == -1);
}
{ // negative one, showbase
+#ifdef _AIX
+ std::string v = "-" + currency_symbol + "0.01";
+#else
std::string v = currency_symbol + "-0.01";
+#endif
std::showbase(ios);
typedef cpp17_input_iterator<const char*> I;
long double ex;
@@ -204,7 +211,11 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
+#ifdef _AIX
+ std::string v = "-" + currency_symbol + "1,234,567.89";
+#else
std::string v = currency_symbol + "-1,234,567.89";
+#endif
std::showbase(ios);
typedef cpp17_input_iterator<const char*> I;
long double ex;
@@ -322,7 +333,7 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative one, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
std::string v = "-" + currency_name + "0.01";
#else
std::string v = currency_name + "-0.01";
@@ -337,7 +348,7 @@ int main(int, char**)
assert(ex == -1);
}
{ // negative one, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
std::string v = "-" + currency_name + "0.01";
#else
std::string v = currency_name + "-0.01";
@@ -378,7 +389,7 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
std::string v = "-" + currency_name + "1,234,567.89";
#else
std::string v = currency_name + "-1,234,567.89";
@@ -507,7 +518,11 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative one, showbase
+# ifdef _AIX
+ std::wstring v = L"-" + w_currency_symbol + L"0.01";
+# else
std::wstring v = w_currency_symbol + L"-0.01";
+# endif
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -518,7 +533,11 @@ int main(int, char**)
assert(ex == -1);
}
{ // negative one, showbase
+# ifdef _AIX
+ std::wstring v = L"-" + w_currency_symbol + L"0.01";
+# else
std::wstring v = w_currency_symbol + L"-0.01";
+# endif
std::showbase(ios);
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
@@ -555,7 +574,11 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
+# ifdef _AIX
+ std::wstring v = L"-" + w_currency_symbol + L"1,234,567.89";
+# else
std::wstring v = w_currency_symbol + L"-1,234,567.89";
+# endif
std::showbase(ios);
typedef cpp17_input_iterator<const wchar_t*> I;
long double ex;
@@ -673,7 +696,7 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative one, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
std::wstring v = L"-" + w_currency_name + L"0.01";
#else
std::wstring v = w_currency_name + L"-0.01";
@@ -688,7 +711,7 @@ int main(int, char**)
assert(ex == -1);
}
{ // negative one, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
std::wstring v = L"-" + w_currency_name + L"0.01";
#else
std::wstring v = w_currency_name + L"-0.01";
@@ -729,7 +752,7 @@ int main(int, char**)
std::noshowbase(ios);
}
{ // negative, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
std::wstring v = L"-" + w_currency_name + L"1,234,567.89";
#else
std::wstring v = w_currency_name + L"-1,234,567.89";
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
index 05b4ee474944a..e36e73f3e8695 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
@@ -11,8 +11,6 @@
// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd
-// XFAIL: LIBCXX-AIX-FIXME
-
// REQUIRES: locale.fr_FR.UTF-8
// <locale>
@@ -32,6 +30,13 @@
#include "platform_support.h" // locale name macros
#include "test_macros.h"
+#ifdef _AIX
+// the AIX libc expects U202F as LC_MONETARY thousands_sep
+#define THOUSANDS_SEP L"\u202F"
+#else
+#define THOUSANDS_SEP L" "
+#endif
+
typedef std::money_put<char, cpp17_output_iterator<char*> > Fn;
class my_facet
@@ -291,14 +296,14 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, '*', v);
std::wstring ex(str, base(iter));
- assert(ex == convert_thousands_sep(L"1 234 567,89"));
+ assert(ex == convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89"));
}
{ // negative
long double v = -123456789;
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, '*', v);
std::wstring ex(str, base(iter));
- assert(ex == convert_thousands_sep(L"-1 234 567,89"));
+ assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89"));
}
{ // zero, showbase
long double v = 0;
@@ -322,7 +327,7 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, '*', v);
std::wstring ex(str, base(iter));
- assert(ex == convert_thousands_sep(L"1 234 567,89 \u20ac"));
+ assert(ex == convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac"));
}
{ // negative, showbase
long double v = -123456789;
@@ -330,7 +335,7 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, '*', v);
std::wstring ex(str, base(iter));
- assert(ex == convert_thousands_sep(L"-1 234 567,89 \u20ac"));
+ assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac"));
}
{ // negative, showbase, left
long double v = -123456789;
@@ -340,7 +345,7 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, ' ', v);
std::wstring ex(str, base(iter));
- assert(ex == convert_thousands_sep(L"-1 234 567,89 \u20ac "));
+ assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac "));
assert(ios.width() == 0);
}
{ // negative, showbase, internal
@@ -351,7 +356,7 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, ' ', v);
std::wstring ex(str, base(iter));
- assert(ex == convert_thousands_sep(L"-1 234 567,89 \u20ac"));
+ assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac"));
assert(ios.width() == 0);
}
{ // negative, showbase, right
@@ -362,7 +367,7 @@ int main(int, char**)
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, ' ', v);
std::wstring ex(str, base(iter));
- assert(ex == convert_thousands_sep(L" -1 234 567,89 \u20ac"));
+ assert(ex == convert_thousands_sep(L" -1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac"));
assert(ios.width() == 0);
}
@@ -388,14 +393,14 @@ 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));
- assert(ex == convert_thousands_sep(L"1 234 567,89"));
+ assert(ex == convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89"));
}
{ // negative
long double v = -123456789;
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));
- assert(ex == convert_thousands_sep(L"-1 234 567,89"));
+ assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89"));
}
{ // zero, showbase
long double v = 0;
@@ -419,7 +424,7 @@ 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));
- assert(ex == convert_thousands_sep(L"1 234 567,89 EUR"));
+ assert(ex == convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR"));
}
{ // negative, showbase
long double v = -123456789;
@@ -427,7 +432,7 @@ 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));
- assert(ex == convert_thousands_sep(L"-1 234 567,89 EUR"));
+ assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR"));
}
{ // negative, showbase, left
long double v = -123456789;
@@ -437,7 +442,7 @@ 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));
- assert(ex == convert_thousands_sep(L"-1 234 567,89 EUR "));
+ assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR "));
assert(ios.width() == 0);
}
{ // negative, showbase, internal
@@ -448,7 +453,7 @@ 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));
- assert(ex == convert_thousands_sep(L"-1 234 567,89 EUR"));
+ assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR"));
assert(ios.width() == 0);
}
{ // negative, showbase, right
@@ -459,7 +464,7 @@ 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));
- assert(ex == convert_thousands_sep(L" -1 234 567,89 EUR"));
+ assert(ex == convert_thousands_sep(L" -1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR"));
assert(ios.width() == 0);
}
}
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...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/94826
More information about the libcxx-commits
mailing list