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// REQUIRES: locale.en_US.UTF-8 11 12// <locale> 13 14// template <class charT> class ctype_byname; 15 16// charT widen(char c) const; 17 18// I doubt this test is portable 19 20 21#include <locale> 22#include <cassert> 23#include <limits.h> 24 25#include "platform_support.h" // locale name macros 26 27int main() 28{ 29 { 30 std::locale l; 31 { 32 typedef std::ctype_byname<wchar_t> F; 33 std::locale ll(l, new F(LOCALE_en_US_UTF_8)); 34 const F& f = std::use_facet<F>(ll); 35 36 assert(f.widen(' ') == L' '); 37 assert(f.widen('A') == L'A'); 38 assert(f.widen('\x07') == L'\x07'); 39 assert(f.widen('.') == L'.'); 40 assert(f.widen('a') == L'a'); 41 assert(f.widen('1') == L'1'); 42 assert(f.widen(char(-5)) == wchar_t(-1)); 43 } 44 } 45 { 46 std::locale l; 47 { 48 typedef std::ctype_byname<wchar_t> F; 49 std::locale ll(l, new F("C")); 50 const F& f = std::use_facet<F>(ll); 51 52 assert(f.widen(' ') == L' '); 53 assert(f.widen('A') == L'A'); 54 assert(f.widen('\x07') == L'\x07'); 55 assert(f.widen('.') == L'.'); 56 assert(f.widen('a') == L'a'); 57 assert(f.widen('1') == L'1'); 58#ifdef __APPLE__ 59 assert(f.widen(char(-5)) == L'\u00fb'); 60#else 61 assert(f.widen(char(-5)) == wchar_t(-1)); 62#endif 63 } 64 } 65} 66