[libcxx] r290746 - Get ctype_byname tests passing on Linux.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 30 01:28:58 PST 2016


Author: ericwf
Date: Fri Dec 30 03:28:58 2016
New Revision: 290746

URL: http://llvm.org/viewvc/llvm-project?rev=290746&view=rev
Log:
Get ctype_byname tests passing on Linux.

Modified:
    libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
    libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
    libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
    libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
    libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
    libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp

Modified: libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp?rev=290746&r1=290745&r2=290746&view=diff
==============================================================================
--- libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp (original)
+++ libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp Fri Dec 30 03:28:58 2016
@@ -17,7 +17,6 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
 
 #include <locale>
 #include <cassert>
@@ -27,10 +26,11 @@
 int main()
 {
     {
-        std::locale l(LOCALE_en_US_UTF_8);
+        std::locale l;
         {
-            typedef std::ctype<char> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<char> F;
+            std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+            const F& f = std::use_facet<F>(ll);
 
             assert(f.tolower(' ') == ' ');
             assert(f.tolower('A') == 'a');
@@ -38,15 +38,15 @@ int main()
             assert(f.tolower('.') == '.');
             assert(f.tolower('a') == 'a');
             assert(f.tolower('1') == '1');
-            assert(f.tolower('\xDA') == '\xFA');
             assert(f.tolower('\xFA') == '\xFA');
         }
     }
     {
-        std::locale l("C");
+        std::locale l;
         {
-            typedef std::ctype<char> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<char> F;
+            std::locale ll(l, new F("C"));
+            const F& f = std::use_facet<F>(ll);
 
             assert(f.tolower(' ') == ' ');
             assert(f.tolower('A') == 'a');
@@ -59,10 +59,11 @@ int main()
         }
     }
     {
-        std::locale l(LOCALE_en_US_UTF_8);
+        std::locale l;
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+            const F& f = std::use_facet<F>(ll);
 
             assert(f.tolower(L' ') == L' ');
             assert(f.tolower(L'A') == L'a');
@@ -75,10 +76,11 @@ int main()
         }
     }
     {
-        std::locale l("C");
+        std::locale l;
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F("C"));
+            const F& f = std::use_facet<F>(ll);
 
             assert(f.tolower(L' ') == L' ');
             assert(f.tolower(L'A') == L'a');

Modified: libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp?rev=290746&r1=290745&r2=290746&view=diff
==============================================================================
--- libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp (original)
+++ libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp Fri Dec 30 03:28:58 2016
@@ -17,7 +17,6 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
 
 #include <locale>
 #include <string>
@@ -28,14 +27,15 @@
 int main()
 {
     {
-        std::locale l(LOCALE_en_US_UTF_8);
+        std::locale l;
         {
-            typedef std::ctype<char> F;
-            const F& f = std::use_facet<F>(l);
-            std::string in("\xDA A\x07.a1");
+            typedef std::ctype_byname<char> F;
+            std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+            const F& f = std::use_facet<F>(ll);
+            std::string in("c A\x07.a1");
 
             assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
-            assert(in[0] == '\xFA');
+            assert(in[0] == 'c');
             assert(in[1] == ' ');
             assert(in[2] == 'a');
             assert(in[3] == '\x07');
@@ -45,10 +45,11 @@ int main()
         }
     }
     {
-        std::locale l("C");
+        std::locale l;
         {
-            typedef std::ctype<char> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<char> F;
+            std::locale ll(l, new F("C"));
+            const F& f = std::use_facet<F>(ll);
             std::string in("\xDA A\x07.a1");
 
             assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
@@ -62,10 +63,11 @@ int main()
         }
     }
     {
-        std::locale l(LOCALE_en_US_UTF_8);
+        std::locale l;
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+            const F& f = std::use_facet<F>(ll);
             std::wstring in(L"\xDA A\x07.a1");
 
             assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
@@ -79,10 +81,11 @@ int main()
         }
     }
     {
-        std::locale l("C");
+        std::locale l;
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F("C"));
+            const F& f = std::use_facet<F>(ll);
             std::wstring in(L"\xDA A\x07.a1");
 
             assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());

Modified: libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp?rev=290746&r1=290745&r2=290746&view=diff
==============================================================================
--- libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp (original)
+++ libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp Fri Dec 30 03:28:58 2016
@@ -17,7 +17,7 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
+
 
 #include <locale>
 #include <cassert>
@@ -27,10 +27,11 @@
 int main()
 {
     {
-        std::locale l(LOCALE_en_US_UTF_8);
+        std::locale l;
         {
-            typedef std::ctype<char> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<char> F;
+            std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+            const F& f = std::use_facet<F>(ll);
 
             assert(f.toupper(' ') == ' ');
             assert(f.toupper('A') == 'A');
@@ -39,14 +40,15 @@ int main()
             assert(f.toupper('a') == 'A');
             assert(f.toupper('1') == '1');
             assert(f.toupper('\xDA') == '\xDA');
-            assert(f.toupper('\xFA') == '\xDA');
+            assert(f.toupper('c') == 'C');
         }
     }
     {
-        std::locale l("C");
+        std::locale l;
         {
-            typedef std::ctype<char> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<char> F;
+            std::locale ll(l, new F("C"));
+            const F& f = std::use_facet<F>(ll);
 
             assert(f.toupper(' ') == ' ');
             assert(f.toupper('A') == 'A');
@@ -59,10 +61,11 @@ int main()
         }
     }
     {
-        std::locale l(LOCALE_en_US_UTF_8);
+        std::locale l;
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+            const F& f = std::use_facet<F>(ll);
 
             assert(f.toupper(L' ') == L' ');
             assert(f.toupper(L'A') == L'A');
@@ -75,10 +78,11 @@ int main()
         }
     }
     {
-        std::locale l("C");
+        std::locale l;
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F("C"));
+            const F& f = std::use_facet<F>(ll);
 
             assert(f.toupper(L' ') == L' ');
             assert(f.toupper(L'A') == L'A');

Modified: libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp?rev=290746&r1=290745&r2=290746&view=diff
==============================================================================
--- libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp (original)
+++ libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp Fri Dec 30 03:28:58 2016
@@ -17,7 +17,6 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
 
 #include <locale>
 #include <string>
@@ -28,14 +27,15 @@
 int main()
 {
     {
-        std::locale l(LOCALE_en_US_UTF_8);
+        std::locale l;
         {
-            typedef std::ctype<char> F;
-            const F& f = std::use_facet<F>(l);
-            std::string in("\xFA A\x07.a1");
+            typedef std::ctype_byname<char> F;
+            std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+            const F& f = std::use_facet<F>(ll);
+            std::string in("c A\x07.a1");
 
             assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
-            assert(in[0] == '\xDA');
+            assert(in[0] == 'C');
             assert(in[1] == ' ');
             assert(in[2] == 'A');
             assert(in[3] == '\x07');
@@ -45,10 +45,11 @@ int main()
         }
     }
     {
-        std::locale l("C");
+        std::locale l;
         {
-            typedef std::ctype<char> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<char> F;
+            std::locale ll(l, new F("C"));
+            const F& f = std::use_facet<F>(ll);
             std::string in("\xFA A\x07.a1");
 
             assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
@@ -62,10 +63,11 @@ int main()
         }
     }
     {
-        std::locale l(LOCALE_en_US_UTF_8);
+        std::locale l;
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+            const F& f = std::use_facet<F>(ll);
             std::wstring in(L"\xFA A\x07.a1");
 
             assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
@@ -79,14 +81,15 @@ int main()
         }
     }
     {
-        std::locale l("C");
+        std::locale l;
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
-            std::wstring in(L"\xFA A\x07.a1");
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F("C"));
+            const F& f = std::use_facet<F>(ll);
+            std::wstring in(L"\u00FA A\x07.a1");
 
             assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
-            assert(in[0] == L'\xFA');
+            assert(in[0] == L'\u00FA');
             assert(in[1] == L' ');
             assert(in[2] == L'A');
             assert(in[3] == L'\x07');

Modified: libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp?rev=290746&r1=290745&r2=290746&view=diff
==============================================================================
--- libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp (original)
+++ libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp Fri Dec 30 03:28:58 2016
@@ -17,7 +17,6 @@
 
 // I doubt this test is portable
 
-// XFAIL: linux
 
 #include <locale>
 #include <cassert>
@@ -28,10 +27,11 @@
 int main()
 {
     {
-        std::locale l(LOCALE_en_US_UTF_8);
+        std::locale l;
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+            const F& f = std::use_facet<F>(ll);
 
             assert(f.widen(' ') == L' ');
             assert(f.widen('A') == L'A');
@@ -43,10 +43,11 @@ int main()
         }
     }
     {
-        std::locale l("C");
+        std::locale l;
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F("C"));
+            const F& f = std::use_facet<F>(ll);
 
             assert(f.widen(' ') == L' ');
             assert(f.widen('A') == L'A');
@@ -54,7 +55,11 @@ int main()
             assert(f.widen('.') == L'.');
             assert(f.widen('a') == L'a');
             assert(f.widen('1') == L'1');
-            assert(f.widen(char(-5)) == wchar_t(251));
+#ifdef __APPLE__
+            assert(f.widen(char(-5)) == L'\u00fb');
+#else
+            assert(f.widen(char(-5)) == wchar_t(-1));
+#endif
         }
     }
 }

Modified: libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp?rev=290746&r1=290745&r2=290746&view=diff
==============================================================================
--- libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp (original)
+++ libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp Fri Dec 30 03:28:58 2016
@@ -17,8 +17,6 @@
 
 // I doubt this test is portable
 
-// XFAIL: linux
-
 #include <locale>
 #include <string>
 #include <vector>
@@ -31,8 +29,9 @@ int main()
     {
         std::locale l(LOCALE_en_US_UTF_8);
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+            F const& f = std::use_facet<F>(ll);
             std::string in(" A\x07.a1\x85");
             std::vector<wchar_t> v(in.size());
 
@@ -49,8 +48,9 @@ int main()
     {
         std::locale l("C");
         {
-            typedef std::ctype<wchar_t> F;
-            const F& f = std::use_facet<F>(l);
+            typedef std::ctype_byname<wchar_t> F;
+            std::locale ll(l, new F("C"));
+            const F& f = std::use_facet<F>(ll);
             std::string in(" A\x07.a1\x85");
             std::vector<wchar_t> v(in.size());
 
@@ -61,7 +61,11 @@ int main()
             assert(v[3] == L'.');
             assert(v[4] == L'a');
             assert(v[5] == L'1');
-            assert(v[6] == wchar_t(133));
+#ifdef __APPLE__
+            assert(v[6] == L'\x85');
+#else
+            assert(v[6] == wchar_t(-1));
+#endif
         }
     }
 }




More information about the cfe-commits mailing list