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