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 charT* tolower(charT* low, const charT* high) const; 17 18// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 19// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 20 21#include <locale> 22#include <string> 23#include <cassert> 24 25#include "platform_support.h" // locale name macros 26 27int main() 28{ 29 { 30 std::locale l; 31 { 32 typedef std::ctype_byname<char> F; 33 std::locale ll(l, new F(LOCALE_en_US_UTF_8)); 34 const F& f = std::use_facet<F>(ll); 35 std::string in("c A\x07.a1"); 36 37 assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size()); 38 assert(in[0] == 'c'); 39 assert(in[1] == ' '); 40 assert(in[2] == 'a'); 41 assert(in[3] == '\x07'); 42 assert(in[4] == '.'); 43 assert(in[5] == 'a'); 44 assert(in[6] == '1'); 45 } 46 } 47 { 48 std::locale l; 49 { 50 typedef std::ctype_byname<char> F; 51 std::locale ll(l, new F("C")); 52 const F& f = std::use_facet<F>(ll); 53 std::string in("\xDA A\x07.a1"); 54 55 assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size()); 56 assert(in[0] == '\xDA'); 57 assert(in[1] == ' '); 58 assert(in[2] == 'a'); 59 assert(in[3] == '\x07'); 60 assert(in[4] == '.'); 61 assert(in[5] == 'a'); 62 assert(in[6] == '1'); 63 } 64 } 65 { 66 std::locale l; 67 { 68 typedef std::ctype_byname<wchar_t> F; 69 std::locale ll(l, new F(LOCALE_en_US_UTF_8)); 70 const F& f = std::use_facet<F>(ll); 71 std::wstring in(L"\xDA A\x07.a1"); 72 73 assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size()); 74 assert(in[0] == L'\xFA'); 75 assert(in[1] == L' '); 76 assert(in[2] == L'a'); 77 assert(in[3] == L'\x07'); 78 assert(in[4] == L'.'); 79 assert(in[5] == L'a'); 80 assert(in[6] == L'1'); 81 } 82 } 83 { 84 std::locale l; 85 { 86 typedef std::ctype_byname<wchar_t> F; 87 std::locale ll(l, new F("C")); 88 const F& f = std::use_facet<F>(ll); 89 std::wstring in(L"\xDA A\x07.a1"); 90 91 assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size()); 92 assert(in[0] == L'\xDA'); 93 assert(in[1] == L' '); 94 assert(in[2] == L'a'); 95 assert(in[3] == L'\x07'); 96 assert(in[4] == L'.'); 97 assert(in[5] == L'a'); 98 assert(in[6] == L'1'); 99 } 100 } 101} 102