[libcxx-commits] [libcxx] [libcxx] Handle changing of fr_FR locale thousand sep in Windows libcxx tests (PR #83967)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 4 23:51:13 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 46f65e45e0f5ce4cc0edabceebee681231d24687 176e572de7db8db34ad3b4536d07f6f8f7674e65 -- libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp libcxx/test/std/time/time.duration/time.duration.nonmember/ostream.pass.cpp libcxx/test/support/locale_helpers.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
index 856598a5c4..2968b967a0 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
@@ -30,7 +30,7 @@
 #include "platform_support.h" // locale name macros
 
 #if defined(_WIN32) && !defined(TEST_HAS_NO_WIDE_CHARACTERS)
-#include "locale_helpers.h"
+#  include "locale_helpers.h"
 #endif
 
 class Fnf
diff --git a/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp b/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
index 0c0b04ab71..ed77dcbfe5 100644
--- a/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
@@ -29,7 +29,7 @@
 #include "platform_support.h" // locale name macros
 
 #if defined(_WIN32) && !defined(TEST_HAS_NO_WIDE_CHARACTERS)
-#include "locale_helpers.h"
+#  include "locale_helpers.h"
 #endif
 
 int main(int, char**)
@@ -82,11 +82,11 @@ int main(int, char**)
 #if defined(_CS_GNU_LIBC_VERSION)
             const wchar_t wsep = glibc_version_less_than("2.27") ? L' ' : L'\u202f';
 #elif defined(_WIN32)
-            // Windows has changed it's fr thousands sep between releases.
-            // Fetch the host's separator in order to know what to expect from the test results.
-            const std::wstring wsep_s = LocaleHelpers::get_locale_mon_thousands_sep(LOCALE_fr_FR_UTF_8);
-            assert(wsep_s.size() == 1);
-            const wchar_t wsep = wsep_s[0];
+          // Windows has changed it's fr thousands sep between releases.
+          // Fetch the host's separator in order to know what to expect from the test results.
+          const std::wstring wsep_s = LocaleHelpers::get_locale_mon_thousands_sep(LOCALE_fr_FR_UTF_8);
+          assert(wsep_s.size() == 1);
+          const wchar_t wsep = wsep_s[0];
 #else
             const wchar_t wsep = L',';
 #endif
diff --git a/libcxx/test/std/time/time.duration/time.duration.nonmember/ostream.pass.cpp b/libcxx/test/std/time/time.duration/time.duration.nonmember/ostream.pass.cpp
index db318e3db4..671fde8e15 100644
--- a/libcxx/test/std/time/time.duration/time.duration.nonmember/ostream.pass.cpp
+++ b/libcxx/test/std/time/time.duration/time.duration.nonmember/ostream.pass.cpp
@@ -37,7 +37,7 @@
 #include "test_macros.h"
 
 #if defined(_WIN32) && !defined(TEST_HAS_NO_WIDE_CHARACTERS)
-#include "locale_helpers.h"
+#  include "locale_helpers.h"
 #endif
 
 #define SV(S) MAKE_STRING_VIEW(CharT, S)
@@ -95,10 +95,14 @@ static void test_values() {
 #ifdef _WIN32
     std::wstring expected_sep = LocaleHelpers::get_locale_thousands_sep(LOCALE_fr_FR_UTF_8);
     assert(expected_sep.size() == 1);
-    assert(stream_fr_FR_locale<CharT>(-1'000'000s) == LocaleHelpers::convert_thousands_sep(L"-1 000 000s", expected_sep[0]));
-    assert(stream_fr_FR_locale<CharT>(1'000'000s) == LocaleHelpers::convert_thousands_sep(L"1 000 000s", expected_sep[0]));
-    assert(stream_fr_FR_locale<CharT>(-1'000.123456s) == LocaleHelpers::convert_thousands_sep(L"-1 000,1235s", expected_sep[0]));
-    assert(stream_fr_FR_locale<CharT>(1'000.123456s) == LocaleHelpers::convert_thousands_sep(L"1 000,1235s", expected_sep[0]));
+    assert(stream_fr_FR_locale<CharT>(-1'000'000s) ==
+           LocaleHelpers::convert_thousands_sep(L"-1 000 000s", expected_sep[0]));
+    assert(stream_fr_FR_locale<CharT>(1'000'000s) ==
+           LocaleHelpers::convert_thousands_sep(L"1 000 000s", expected_sep[0]));
+    assert(stream_fr_FR_locale<CharT>(-1'000.123456s) ==
+           LocaleHelpers::convert_thousands_sep(L"-1 000,1235s", expected_sep[0]));
+    assert(stream_fr_FR_locale<CharT>(1'000.123456s) ==
+           LocaleHelpers::convert_thousands_sep(L"1 000,1235s", expected_sep[0]));
 #elif defined(__APPLE__)
     assert(stream_fr_FR_locale<CharT>(-1'000'000s) == SV("-1000000s"));
     assert(stream_fr_FR_locale<CharT>(1'000'000s) == SV("1000000s"));
diff --git a/libcxx/test/support/locale_helpers.h b/libcxx/test/support/locale_helpers.h
index 9b18acc13c..03c91c5a24 100644
--- a/libcxx/test/support/locale_helpers.h
+++ b/libcxx/test/support/locale_helpers.h
@@ -41,7 +41,7 @@ std::wstring convert_thousands_sep(std::wstring const& in, wchar_t sep) {
   return out;
 }
 
-#if defined(_WIN32)
+#  if defined(_WIN32)
 // This implementation is similar to the locale_guard in the private libcxx implementation headers
 // but exists here for usability from the libcxx/test/std conformance test suites.
 class LocaleGuard {
@@ -118,14 +118,14 @@ std::wstring get_locale_mon_thousands_sep(const char* locale) {
 std::wstring get_locale_thousands_sep(const char* locale) {
   return get_locale_lconv_cstr_member(locale, &lconv::thousands_sep);
 }
-#endif // _WIN32
+#  endif // _WIN32
 
 // GLIBC 2.27 and newer use U+202F NARROW NO-BREAK SPACE as a thousands separator.
 // This function converts the spaces in string inputs to U+202F if need
 // be. FreeBSD's locale data also uses U+202F, since 2018.
 // Windows may use U+00A0 NO-BREAK SPACE or U+0202F NARROW NO-BREAK SPACE.
 std::wstring convert_mon_thousands_sep_fr_FR(std::wstring const& in) {
-#if defined(_CS_GNU_LIBC_VERSION)
+#  if defined(_CS_GNU_LIBC_VERSION)
   if (glibc_version_less_than("2.27"))
     return in;
   else

``````````

</details>


https://github.com/llvm/llvm-project/pull/83967


More information about the libcxx-commits mailing list