blob: c2eeea820ba00ffc5a83cd355940e048a282599d [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <locale>
11
12// template <class charT> class ctype_byname;
13
14// charT tolower(charT) const;
15
Jonathan Roelofs33459612015-01-14 23:38:12 +000016// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
17// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
Eric Fiselierf5236932014-08-21 02:03:01 +000018// XFAIL: linux
Howard Hinnantdd854b22013-05-07 17:37:19 +000019
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000020#include <locale>
21#include <cassert>
22
Marshall Clow83e2c4d2013-01-05 03:21:01 +000023#include "platform_support.h" // locale name macros
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000024
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000025int main()
26{
27 {
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000028 std::locale l(LOCALE_en_US_UTF_8);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000029 {
30 typedef std::ctype<char> F;
31 const F& f = std::use_facet<F>(l);
Howard Hinnant22a74dc2010-08-22 00:39:25 +000032
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000033 assert(f.tolower(' ') == ' ');
34 assert(f.tolower('A') == 'a');
35 assert(f.tolower('\x07') == '\x07');
36 assert(f.tolower('.') == '.');
37 assert(f.tolower('a') == 'a');
38 assert(f.tolower('1') == '1');
Joerg Sonnenberger63d8f7e2013-05-02 19:17:48 +000039 assert(f.tolower('\xDA') == '\xFA');
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000040 assert(f.tolower('\xFA') == '\xFA');
41 }
42 }
43 {
44 std::locale l("C");
45 {
46 typedef std::ctype<char> F;
47 const F& f = std::use_facet<F>(l);
Howard Hinnant22a74dc2010-08-22 00:39:25 +000048
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000049 assert(f.tolower(' ') == ' ');
50 assert(f.tolower('A') == 'a');
51 assert(f.tolower('\x07') == '\x07');
52 assert(f.tolower('.') == '.');
53 assert(f.tolower('a') == 'a');
54 assert(f.tolower('1') == '1');
55 assert(f.tolower('\xDA') == '\xDA');
56 assert(f.tolower('\xFA') == '\xFA');
57 }
58 }
59 {
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000060 std::locale l(LOCALE_en_US_UTF_8);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000061 {
62 typedef std::ctype<wchar_t> F;
63 const F& f = std::use_facet<F>(l);
Howard Hinnant22a74dc2010-08-22 00:39:25 +000064
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000065 assert(f.tolower(L' ') == L' ');
66 assert(f.tolower(L'A') == L'a');
67 assert(f.tolower(L'\x07') == L'\x07');
68 assert(f.tolower(L'.') == L'.');
69 assert(f.tolower(L'a') == L'a');
70 assert(f.tolower(L'1') == L'1');
71 assert(f.tolower(L'\xDA') == L'\xFA');
72 assert(f.tolower(L'\xFA') == L'\xFA');
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);
Howard Hinnant22a74dc2010-08-22 00:39:25 +000080
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000081 assert(f.tolower(L' ') == L' ');
82 assert(f.tolower(L'A') == L'a');
83 assert(f.tolower(L'\x07') == L'\x07');
84 assert(f.tolower(L'.') == L'.');
85 assert(f.tolower(L'a') == L'a');
86 assert(f.tolower(L'1') == L'1');
87 assert(f.tolower(L'\xDA') == L'\xDA');
88 assert(f.tolower(L'\xFA') == L'\xFA');
89 }
90 }
91}