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// XFAIL: apple-darwin 11 12// <locale> 13 14// class moneypunct_byname<charT, International> 15 16// string_type curr_symbol() const; 17 18#include <locale> 19#include <limits> 20#include <cassert> 21 22#include "platform_support.h" // locale name macros 23 24class Fnf 25 : public std::moneypunct_byname<char, false> 26{ 27public: 28 explicit Fnf(const std::string& nm, std::size_t refs = 0) 29 : std::moneypunct_byname<char, false>(nm, refs) {} 30}; 31 32class Fnt 33 : public std::moneypunct_byname<char, true> 34{ 35public: 36 explicit Fnt(const std::string& nm, std::size_t refs = 0) 37 : std::moneypunct_byname<char, true>(nm, refs) {} 38}; 39 40class Fwf 41 : public std::moneypunct_byname<wchar_t, false> 42{ 43public: 44 explicit Fwf(const std::string& nm, std::size_t refs = 0) 45 : std::moneypunct_byname<wchar_t, false>(nm, refs) {} 46}; 47 48class Fwt 49 : public std::moneypunct_byname<wchar_t, true> 50{ 51public: 52 explicit Fwt(const std::string& nm, std::size_t refs = 0) 53 : std::moneypunct_byname<wchar_t, true>(nm, refs) {} 54}; 55 56int main() 57{ 58 { 59 Fnf f("C", 1); 60 assert(f.curr_symbol() == std::string()); 61 } 62 { 63 Fnt f("C", 1); 64 assert(f.curr_symbol() == std::string()); 65 } 66 { 67 Fwf f("C", 1); 68 assert(f.curr_symbol() == std::wstring()); 69 } 70 { 71 Fwt f("C", 1); 72 assert(f.curr_symbol() == std::wstring()); 73 } 74 75 { 76 Fnf f(LOCALE_en_US_UTF_8, 1); 77 assert(f.curr_symbol() == "$"); 78 } 79 { 80 Fnt f(LOCALE_en_US_UTF_8, 1); 81 assert(f.curr_symbol() == "USD "); 82 } 83 { 84 Fwf f(LOCALE_en_US_UTF_8, 1); 85 assert(f.curr_symbol() == L"$"); 86 } 87 { 88 Fwt f(LOCALE_en_US_UTF_8, 1); 89 assert(f.curr_symbol() == L"USD "); 90 } 91 92 { 93 Fnf f(LOCALE_fr_FR_UTF_8, 1); 94 assert(f.curr_symbol() == " \u20ac"); 95 } 96 { 97 Fnt f(LOCALE_fr_FR_UTF_8, 1); 98 assert(f.curr_symbol() == " EUR"); 99 } 100 { 101 Fwf f(LOCALE_fr_FR_UTF_8, 1); 102 assert(f.curr_symbol() == L" \u20ac"); 103 } 104 { 105 Fwt f(LOCALE_fr_FR_UTF_8, 1); 106 assert(f.curr_symbol() == L" EUR"); 107 } 108 109 { 110 Fnf f(LOCALE_ru_RU_UTF_8, 1); 111 assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1"); 112 } 113 { 114 Fnt f(LOCALE_ru_RU_UTF_8, 1); 115 assert(f.curr_symbol() == " RUB"); 116 } 117 { 118 Fwf f(LOCALE_ru_RU_UTF_8, 1); 119 assert(f.curr_symbol() == L" \x440\x443\x431"); 120 } 121 { 122 Fwt f(LOCALE_ru_RU_UTF_8, 1); 123 assert(f.curr_symbol() == L" RUB"); 124 } 125 126 { 127 Fnf f(LOCALE_zh_CN_UTF_8, 1); 128 assert(f.curr_symbol() == "\xEF\xBF\xA5"); 129 } 130 { 131 Fnt f(LOCALE_zh_CN_UTF_8, 1); 132 assert(f.curr_symbol() == "CNY "); 133 } 134 { 135 Fwf f(LOCALE_zh_CN_UTF_8, 1); 136 assert(f.curr_symbol() == L"\xFFE5"); 137 } 138 { 139 Fwt f(LOCALE_zh_CN_UTF_8, 1); 140 assert(f.curr_symbol() == L"CNY "); 141 } 142} 143