1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // REQUIRES: locale.en_US.UTF-8 11 12 // <locale> 13 14 // template <class charT> class ctype_byname; 15 16 // const char* widen(const char* low, const char* high, charT* to) const; 17 18 // I doubt this test is portable 19 20 // XFAIL: linux 21 22 #include <locale> 23 #include <string> 24 #include <vector> 25 #include <cassert> 26 27 #include "platform_support.h" // locale name macros 28 29 int main() 30 { 31 { 32 std::locale l(LOCALE_en_US_UTF_8); 33 { 34 typedef std::ctype<wchar_t> F; 35 const F& f = std::use_facet<F>(l); 36 std::string in(" A\x07.a1\x85"); 37 std::vector<wchar_t> v(in.size()); 38 39 assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size()); 40 assert(v[0] == L' '); 41 assert(v[1] == L'A'); 42 assert(v[2] == L'\x07'); 43 assert(v[3] == L'.'); 44 assert(v[4] == L'a'); 45 assert(v[5] == L'1'); 46 assert(v[6] == wchar_t(-1)); 47 } 48 } 49 { 50 std::locale l("C"); 51 { 52 typedef std::ctype<wchar_t> F; 53 const F& f = std::use_facet<F>(l); 54 std::string in(" A\x07.a1\x85"); 55 std::vector<wchar_t> v(in.size()); 56 57 assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size()); 58 assert(v[0] == L' '); 59 assert(v[1] == L'A'); 60 assert(v[2] == L'\x07'); 61 assert(v[3] == L'.'); 62 assert(v[4] == L'a'); 63 assert(v[5] == L'1'); 64 assert(v[6] == wchar_t(133)); 65 } 66 } 67 } 68