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 char* widen(const char* low, const char* high, charT* to) const;
15
16// I doubt this test is portable
17
18#include <locale>
19#include <string>
20#include <vector>
21#include <cassert>
22
23#include "platform_support.h" // locale name macros
24
25int main()
26{
27    {
28        std::locale l(LOCALE_en_US_UTF_8);
29        {
30            typedef std::ctype<wchar_t> F;
31            const F& f = std::use_facet<F>(l);
32            std::string in(" A\x07.a1\x85");
33            std::vector<wchar_t> v(in.size());
34
35            assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
36            assert(v[0] == L' ');
37            assert(v[1] == L'A');
38            assert(v[2] == L'\x07');
39            assert(v[3] == L'.');
40            assert(v[4] == L'a');
41            assert(v[5] == L'1');
42            assert(v[6] == wchar_t(-1));
43        }
44    }
45    {
46        std::locale l("C");
47        {
48            typedef std::ctype<wchar_t> F;
49            const F& f = std::use_facet<F>(l);
50            std::string in(" A\x07.a1\x85");
51            std::vector<wchar_t> v(in.size());
52
53            assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
54            assert(v[0] == L' ');
55            assert(v[1] == L'A');
56            assert(v[2] == L'\x07');
57            assert(v[3] == L'.');
58            assert(v[4] == L'a');
59            assert(v[5] == L'1');
60            assert(v[6] == wchar_t(133));
61        }
62    }
63}
64