aboutsummaryrefslogtreecommitdiffstats
path: root/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
blob: d23a29273e2bade9983d58b629ef47db2cdf3808 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <locale>

// template <class charT> class ctype_byname;

// const charT* toupper(charT* low, const charT* high) const;

// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// XFAIL: linux

#include <locale>
#include <string>
#include <cassert>

#include "platform_support.h" // locale name macros

int main()
{
    {
        std::locale l(LOCALE_en_US_UTF_8);
        {
            typedef std::ctype<char> F;
            const F& f = std::use_facet<F>(l);
            std::string in("\xFA A\x07.a1");

            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
            assert(in[0] == '\xDA');
            assert(in[1] == ' ');
            assert(in[2] == 'A');
            assert(in[3] == '\x07');
            assert(in[4] == '.');
            assert(in[5] == 'A');
            assert(in[6] == '1');
        }
    }
    {
        std::locale l("C");
        {
            typedef std::ctype<char> F;
            const F& f = std::use_facet<F>(l);
            std::string in("\xFA A\x07.a1");

            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
            assert(in[0] == '\xFA');
            assert(in[1] == ' ');
            assert(in[2] == 'A');
            assert(in[3] == '\x07');
            assert(in[4] == '.');
            assert(in[5] == 'A');
            assert(in[6] == '1');
        }
    }
    {
        std::locale l(LOCALE_en_US_UTF_8);
        {
            typedef std::ctype<wchar_t> F;
            const F& f = std::use_facet<F>(l);
            std::wstring in(L"\xFA A\x07.a1");

            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
            assert(in[0] == L'\xDA');
            assert(in[1] == L' ');
            assert(in[2] == L'A');
            assert(in[3] == L'\x07');
            assert(in[4] == L'.');
            assert(in[5] == L'A');
            assert(in[6] == L'1');
        }
    }
    {
        std::locale l("C");
        {
            typedef std::ctype<wchar_t> F;
            const F& f = std::use_facet<F>(l);
            std::wstring in(L"\xFA A\x07.a1");

            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
            assert(in[0] == L'\xFA');
            assert(in[1] == L' ');
            assert(in[2] == L'A');
            assert(in[3] == L'\x07');
            assert(in[4] == L'.');
            assert(in[5] == L'A');
            assert(in[6] == L'1');
        }
    }
}