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 // <locale> 11 12 // template <class charT> class ctype_byname; 13 14 // const char* widen(const char* low, const char* high, charT* to) const; 15 16 // I doubt this test is portable 17 18 // XFAIL: linux 19 20 #include <locale> 21 #include <string> 22 #include <vector> 23 #include <cassert> 24 25 #include "platform_support.h" // locale name macros 26 main()27int main() 28 { 29 { 30 std::locale l(LOCALE_en_US_UTF_8); 31 { 32 typedef std::ctype<wchar_t> F; 33 const F& f = std::use_facet<F>(l); 34 std::string in(" A\x07.a1\x85"); 35 std::vector<wchar_t> v(in.size()); 36 37 assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size()); 38 assert(v[0] == L' '); 39 assert(v[1] == L'A'); 40 assert(v[2] == L'\x07'); 41 assert(v[3] == L'.'); 42 assert(v[4] == L'a'); 43 assert(v[5] == L'1'); 44 assert(v[6] == wchar_t(-1)); 45 } 46 } 47 { 48 std::locale l("C"); 49 { 50 typedef std::ctype<wchar_t> F; 51 const F& f = std::use_facet<F>(l); 52 std::string in(" A\x07.a1\x85"); 53 std::vector<wchar_t> v(in.size()); 54 55 assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size()); 56 assert(v[0] == L' '); 57 assert(v[1] == L'A'); 58 assert(v[2] == L'\x07'); 59 assert(v[3] == L'.'); 60 assert(v[4] == L'a'); 61 assert(v[5] == L'1'); 62 assert(v[6] == wchar_t(133)); 63 } 64 } 65 } 66