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