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