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