blob: d23a29273e2bade9983d58b629ef47db2cdf3808 [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// const charT* toupper(charT* low, const charT* high) 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 <string>
22#include <cassert>
23
Marshall Clow83e2c4d2013-01-05 03:21:01 +000024#include "platform_support.h" // locale name macros
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000025
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000026int main()
27{
28 {
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000029 std::locale l(LOCALE_en_US_UTF_8);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000030 {
31 typedef std::ctype<char> F;
32 const F& f = std::use_facet<F>(l);
33 std::string in("\xFA A\x07.a1");
Howard Hinnant22a74dc2010-08-22 00:39:25 +000034
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000035 assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
Joerg Sonnenberger63d8f7e2013-05-02 19:17:48 +000036 assert(in[0] == '\xDA');
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000037 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("\xFA A\x07.a1");
Howard Hinnant22a74dc2010-08-22 00:39:25 +000051
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000052 assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
53 assert(in[0] == '\xFA');
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 {
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000063 std::locale l(LOCALE_en_US_UTF_8);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000064 {
65 typedef std::ctype<wchar_t> F;
66 const F& f = std::use_facet<F>(l);
67 std::wstring in(L"\xFA A\x07.a1");
Howard Hinnant22a74dc2010-08-22 00:39:25 +000068
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000069 assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
70 assert(in[0] == L'\xDA');
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"\xFA A\x07.a1");
Howard Hinnant22a74dc2010-08-22 00:39:25 +000085
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000086 assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
87 assert(in[0] == L'\xFA');
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}