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