toupper_many.pass.cpp revision 22a74dcf50ff4338767607fa5a9d2916c2c85525
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. 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
20int main()
21{
22    {
23        std::locale l("en_US");
24        {
25            typedef std::ctype<char> F;
26            const F& f = std::use_facet<F>(l);
27            std::string in("\xFA A\x07.a1");
28
29            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
30            assert(in[0] == '\xFA');
31            assert(in[1] == ' ');
32            assert(in[2] == 'A');
33            assert(in[3] == '\x07');
34            assert(in[4] == '.');
35            assert(in[5] == 'A');
36            assert(in[6] == '1');
37        }
38    }
39    {
40        std::locale l("C");
41        {
42            typedef std::ctype<char> F;
43            const F& f = std::use_facet<F>(l);
44            std::string in("\xFA A\x07.a1");
45
46            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
47            assert(in[0] == '\xFA');
48            assert(in[1] == ' ');
49            assert(in[2] == 'A');
50            assert(in[3] == '\x07');
51            assert(in[4] == '.');
52            assert(in[5] == 'A');
53            assert(in[6] == '1');
54        }
55    }
56    {
57        std::locale l("en_US");
58        {
59            typedef std::ctype<wchar_t> F;
60            const F& f = std::use_facet<F>(l);
61            std::wstring in(L"\xFA A\x07.a1");
62
63            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
64            assert(in[0] == L'\xDA');
65            assert(in[1] == L' ');
66            assert(in[2] == L'A');
67            assert(in[3] == L'\x07');
68            assert(in[4] == L'.');
69            assert(in[5] == L'A');
70            assert(in[6] == L'1');
71        }
72    }
73    {
74        std::locale l("C");
75        {
76            typedef std::ctype<wchar_t> F;
77            const F& f = std::use_facet<F>(l);
78            std::wstring in(L"\xFA A\x07.a1");
79
80            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
81            assert(in[0] == L'\xFA');
82            assert(in[1] == L' ');
83            assert(in[2] == L'A');
84            assert(in[3] == L'\x07');
85            assert(in[4] == L'.');
86            assert(in[5] == L'A');
87            assert(in[6] == L'1');
88        }
89    }
90}
91