tolower_many.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
1//===----------------------------------------------------------------------===// 2// 3// ��������������������The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <locale> 11 12// template <class charT> class ctype_byname; 13 14// const charT* tolower(charT* low, const charT* high) const; 15 16#include <locale> 17#include <string> 18#include <cassert> 19 20int main() 21{ 22 { 23 std::locale l("en_US"); 24 { 25 typedef std::ctype<char> F; 26 const F& f = std::use_facet<F>(l); 27 std::string in("\xDA A\x07.a1"); 28 29 assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size()); 30 assert(in[0] == '\xDA'); 31 assert(in[1] == ' '); 32 assert(in[2] == 'a'); 33 assert(in[3] == '\x07'); 34 assert(in[4] == '.'); 35 assert(in[5] == 'a'); 36 assert(in[6] == '1'); 37 } 38 } 39 { 40 std::locale l("C"); 41 { 42 typedef std::ctype<char> F; 43 const F& f = std::use_facet<F>(l); 44 std::string in("\xDA A\x07.a1"); 45 46 assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size()); 47 assert(in[0] == '\xDA'); 48 assert(in[1] == ' '); 49 assert(in[2] == 'a'); 50 assert(in[3] == '\x07'); 51 assert(in[4] == '.'); 52 assert(in[5] == 'a'); 53 assert(in[6] == '1'); 54 } 55 } 56 { 57 std::locale l("en_US"); 58 { 59 typedef std::ctype<wchar_t> F; 60 const F& f = std::use_facet<F>(l); 61 std::wstring in(L"\xDA A\x07.a1"); 62 63 assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size()); 64 assert(in[0] == L'\xFA'); 65 assert(in[1] == L' '); 66 assert(in[2] == L'a'); 67 assert(in[3] == L'\x07'); 68 assert(in[4] == L'.'); 69 assert(in[5] == L'a'); 70 assert(in[6] == L'1'); 71 } 72 } 73 { 74 std::locale l("C"); 75 { 76 typedef std::ctype<wchar_t> F; 77 const F& f = std::use_facet<F>(l); 78 std::wstring in(L"\xDA A\x07.a1"); 79 80 assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size()); 81 assert(in[0] == L'\xDA'); 82 assert(in[1] == L' '); 83 assert(in[2] == L'a'); 84 assert(in[3] == L'\x07'); 85 assert(in[4] == L'.'); 86 assert(in[5] == L'a'); 87 assert(in[6] == L'1'); 88 } 89 } 90} 91