widen_1.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
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// charT widen(char c) const;
15
16// I doubt this test is portable
17
18#include <locale>
19#include <cassert>
20#include <limits.h>
21
22int main()
23{
24    {
25        std::locale l("en_US");
26        {
27            typedef std::ctype<wchar_t> F;
28            const F& f = std::use_facet<F>(l);
29
30            assert(f.widen(' ') == L' ');
31            assert(f.widen('A') == L'A');
32            assert(f.widen('\x07') == L'\x07');
33            assert(f.widen('.') == L'.');
34            assert(f.widen('a') == L'a');
35            assert(f.widen('1') == L'1');
36            assert(f.widen(char(-5)) == wchar_t(-1));
37        }
38    }
39    {
40        std::locale l("C");
41        {
42            typedef std::ctype<wchar_t> F;
43            const F& f = std::use_facet<F>(l);
44
45            assert(f.widen(' ') == L' ');
46            assert(f.widen('A') == L'A');
47            assert(f.widen('\x07') == L'\x07');
48            assert(f.widen('.') == L'.');
49            assert(f.widen('a') == L'a');
50            assert(f.widen('1') == L'1');
51            assert(f.widen(char(-5)) == wchar_t(251));
52        }
53    }
54}
55