curr_symbol.pass.cpp revision 558ae17391455e18d3cc63ead57ba0b8aba49a3f
190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)//===----------------------------------------------------------------------===// 290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// 390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// The LLVM Compiler Infrastructure 490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// 590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// This file is dual licensed under the MIT and the University of Illinois Open 690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Source Licenses. See LICENSE.TXT for details. 790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// 890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)//===----------------------------------------------------------------------===// 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// <locale> 1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// class moneypunct_byname<charT, International> 1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// string_type curr_symbol() const; 1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <locale> 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <limits> 1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <cassert> 1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "../../../../platform_support.h" // locale name macros 2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class Fnf 2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) : public std::moneypunct_byname<char, false> 2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles){ 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)public: 2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) explicit Fnf(const std::string& nm, std::size_t refs = 0) 2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) : std::moneypunct_byname<char, false>(nm, refs) {} 2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}; 2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class Fnt 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) : public std::moneypunct_byname<char, true> 3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles){ 3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)public: 3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) explicit Fnt(const std::string& nm, std::size_t refs = 0) 3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) : std::moneypunct_byname<char, true>(nm, refs) {} 3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}; 37 38class Fwf 39 : public std::moneypunct_byname<wchar_t, false> 40{ 41public: 42 explicit Fwf(const std::string& nm, std::size_t refs = 0) 43 : std::moneypunct_byname<wchar_t, false>(nm, refs) {} 44}; 45 46class Fwt 47 : public std::moneypunct_byname<wchar_t, true> 48{ 49public: 50 explicit Fwt(const std::string& nm, std::size_t refs = 0) 51 : std::moneypunct_byname<wchar_t, true>(nm, refs) {} 52}; 53 54int main() 55{ 56 { 57 Fnf f("C", 1); 58 assert(f.curr_symbol() == std::string()); 59 } 60 { 61 Fnt f("C", 1); 62 assert(f.curr_symbol() == std::string()); 63 } 64 { 65 Fwf f("C", 1); 66 assert(f.curr_symbol() == std::wstring()); 67 } 68 { 69 Fwt f("C", 1); 70 assert(f.curr_symbol() == std::wstring()); 71 } 72 73 { 74 Fnf f(LOCALE_en_US_UTF_8, 1); 75 assert(f.curr_symbol() == "$"); 76 } 77 { 78 Fnt f(LOCALE_en_US_UTF_8, 1); 79 assert(f.curr_symbol() == "USD "); 80 } 81 { 82 Fwf f(LOCALE_en_US_UTF_8, 1); 83 assert(f.curr_symbol() == L"$"); 84 } 85 { 86 Fwt f(LOCALE_en_US_UTF_8, 1); 87 assert(f.curr_symbol() == L"USD "); 88 } 89 90 { 91 Fnf f(LOCALE_fr_FR_UTF_8, 1); 92 assert(f.curr_symbol() == " \u20ac"); 93 } 94 { 95 Fnt f(LOCALE_fr_FR_UTF_8, 1); 96 assert(f.curr_symbol() == " EUR"); 97 } 98 { 99 Fwf f(LOCALE_fr_FR_UTF_8, 1); 100 assert(f.curr_symbol() == L" \u20ac"); 101 } 102 { 103 Fwt f(LOCALE_fr_FR_UTF_8, 1); 104 assert(f.curr_symbol() == L" EUR"); 105 } 106 107 { 108 Fnf f(LOCALE_ru_RU_UTF_8, 1); 109 assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1"); 110 } 111 { 112 Fnt f(LOCALE_ru_RU_UTF_8, 1); 113 assert(f.curr_symbol() == " RUB"); 114 } 115 { 116 Fwf f(LOCALE_ru_RU_UTF_8, 1); 117 assert(f.curr_symbol() == L" \x440\x443\x431"); 118 } 119 { 120 Fwt f(LOCALE_ru_RU_UTF_8, 1); 121 assert(f.curr_symbol() == L" RUB"); 122 } 123 124 { 125 Fnf f(LOCALE_zh_CN_UTF_8, 1); 126 assert(f.curr_symbol() == "\xEF\xBF\xA5"); 127 } 128 { 129 Fnt f(LOCALE_zh_CN_UTF_8, 1); 130 assert(f.curr_symbol() == "CNY "); 131 } 132 { 133 Fwf f(LOCALE_zh_CN_UTF_8, 1); 134 assert(f.curr_symbol() == L"\xFFE5"); 135 } 136 { 137 Fwt f(LOCALE_zh_CN_UTF_8, 1); 138 assert(f.curr_symbol() == L"CNY "); 139 } 140} 141