[libcxx-commits] [libcxx] d49c0ba - [libc++][test] Use the Japanese locale.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 8 11:00:39 PDT 2022


Author: Mark de Wever
Date: 2022-04-08T20:00:34+02:00
New Revision: d49c0ba5abdeb8f6ebe081d96e0fdf44de46e7f8

URL: https://github.com/llvm/llvm-project/commit/d49c0ba5abdeb8f6ebe081d96e0fdf44de46e7f8
DIFF: https://github.com/llvm/llvm-project/commit/d49c0ba5abdeb8f6ebe081d96e0fdf44de46e7f8.diff

LOG: [libc++][test] Use the Japanese locale.

This change is done to see whether all platforms have a CI with the
Japanese locale installed.

This wires in the locale in the tests and uses it in one test. This is
a preparation for the tests of the chrono formatters.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122738

Added: 
    

Modified: 
    libcxx/test/std/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp
    libcxx/test/support/platform_support.h
    libcxx/utils/libcxx/test/features.py

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp b/libcxx/test/std/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp
index 4e18d4186ddf0..58f86fb165fbe 100644
--- a/libcxx/test/std/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp
@@ -11,6 +11,7 @@
 
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ja_JP.UTF-8
 
 // <locale>
 
@@ -75,6 +76,18 @@ int main(int, char**)
                (ex == "Today is samedi which is abbreviated 'sam'." )||
                (ex == "Today is samedi which is abbreviated 'sam.'."));
     }
-
+    {
+        const my_facet f(LOCALE_ja_JP_UTF_8, 1);
+        std::string pat("Today is %A which is the %uth day or alternatively %Ou.");
+        cpp17_output_iterator<char*> iter =
+            f.put(cpp17_output_iterator<char*>(str), ios, '*', &t, pat.data(), pat.data() + pat.size());
+        std::string ex(str, base(iter));
+#if defined(_WIN32) ||  defined(__APPLE__)
+		// These platforms have no alternative
+        assert(ex == "Today is \xE5\x9C\x9F\xE6\x9B\x9C\xE6\x97\xA5 which is the 6th day or alternatively 6.");
+#else
+        assert(ex == "Today is \xE5\x9C\x9F\xE6\x9B\x9C\xE6\x97\xA5 which is the 6th day or alternatively \xE5\x85\xAD.");
+#endif
+    }
   return 0;
 }

diff  --git a/libcxx/test/support/platform_support.h b/libcxx/test/support/platform_support.h
index 7cfb21f794944..e18c3114c7561 100644
--- a/libcxx/test/support/platform_support.h
+++ b/libcxx/test/support/platform_support.h
@@ -28,6 +28,7 @@
 #    define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO8859-1"
 #    define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO8859-2"
 #endif
+#define LOCALE_ja_JP_UTF_8     "ja_JP.UTF-8"
 #define LOCALE_ru_RU_UTF_8     "ru_RU.UTF-8"
 #define LOCALE_zh_CN_UTF_8     "zh_CN.UTF-8"
 

diff  --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 99e5f7fb48bee..8b2b2180ffb02 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -193,6 +193,7 @@ def _hasSuitableClangTidy(cfg):
 locales = {
   'en_US.UTF-8':     ['en_US.UTF-8', 'en_US.utf8', 'English_United States.1252'],
   'fr_FR.UTF-8':     ['fr_FR.UTF-8', 'fr_FR.utf8', 'French_France.1252'],
+  'ja_JP.UTF-8':     ['ja_JP.UTF-8', 'ja_JP.utf8', 'Japanese_Japan.923'],
   'ru_RU.UTF-8':     ['ru_RU.UTF-8', 'ru_RU.utf8', 'Russian_Russia.1251'],
   'zh_CN.UTF-8':     ['zh_CN.UTF-8', 'zh_CN.utf8', 'Chinese_China.936'],
   'fr_CA.ISO8859-1': ['fr_CA.ISO8859-1', 'French_Canada.1252'],


        


More information about the libcxx-commits mailing list