blob: 320e08db26e0fb6285e711a1c91f32f526cba2f1 [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// charT widen(char c) const;
15
16// I doubt this test is portable
17
Eric Fiselierf5236932014-08-21 02:03:01 +000018// XFAIL: linux
19
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000020#include <locale>
21#include <cassert>
22#include <limits.h>
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<wchar_t> F;
32 const F& f = std::use_facet<F>(l);
Howard Hinnant22a74dc2010-08-22 00:39:25 +000033
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000034 assert(f.widen(' ') == L' ');
35 assert(f.widen('A') == L'A');
36 assert(f.widen('\x07') == L'\x07');
37 assert(f.widen('.') == L'.');
38 assert(f.widen('a') == L'a');
39 assert(f.widen('1') == L'1');
40 assert(f.widen(char(-5)) == wchar_t(-1));
41 }
42 }
43 {
44 std::locale l("C");
45 {
46 typedef std::ctype<wchar_t> F;
47 const F& f = std::use_facet<F>(l);
Howard Hinnant22a74dc2010-08-22 00:39:25 +000048
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000049 assert(f.widen(' ') == L' ');
50 assert(f.widen('A') == L'A');
51 assert(f.widen('\x07') == L'\x07');
52 assert(f.widen('.') == L'.');
53 assert(f.widen('a') == L'a');
54 assert(f.widen('1') == L'1');
55 assert(f.widen(char(-5)) == wchar_t(251));
56 }
57 }
58}