1*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
2*0a6a1f1dSLionel Sambuc //
3*0a6a1f1dSLionel Sambuc //                     The LLVM Compiler Infrastructure
4*0a6a1f1dSLionel Sambuc //
5*0a6a1f1dSLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open
6*0a6a1f1dSLionel Sambuc // Source Licenses. See LICENSE.TXT for details.
7*0a6a1f1dSLionel Sambuc //
8*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
9*0a6a1f1dSLionel Sambuc 
10*0a6a1f1dSLionel Sambuc // REQUIRES: locale.zh_CN.UTF-8
11*0a6a1f1dSLionel Sambuc 
12*0a6a1f1dSLionel Sambuc // <locale>
13*0a6a1f1dSLionel Sambuc 
14*0a6a1f1dSLionel Sambuc // class money_put<charT, OutputIterator>
15*0a6a1f1dSLionel Sambuc 
16*0a6a1f1dSLionel Sambuc // iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
17*0a6a1f1dSLionel Sambuc //               long double units) const;
18*0a6a1f1dSLionel Sambuc 
19*0a6a1f1dSLionel Sambuc // TODO For zh_CN GLIBC puts the negative sign after the currency symbol.
20*0a6a1f1dSLionel Sambuc // XFAIL: linux-gnu
21*0a6a1f1dSLionel Sambuc 
22*0a6a1f1dSLionel Sambuc #include <locale>
23*0a6a1f1dSLionel Sambuc #include <ios>
24*0a6a1f1dSLionel Sambuc #include <streambuf>
25*0a6a1f1dSLionel Sambuc #include <cassert>
26*0a6a1f1dSLionel Sambuc #include "test_iterators.h"
27*0a6a1f1dSLionel Sambuc 
28*0a6a1f1dSLionel Sambuc #include "platform_support.h" // locale name macros
29*0a6a1f1dSLionel Sambuc 
30*0a6a1f1dSLionel Sambuc typedef std::money_put<char, output_iterator<char*> > Fn;
31*0a6a1f1dSLionel Sambuc 
32*0a6a1f1dSLionel Sambuc class my_facet
33*0a6a1f1dSLionel Sambuc     : public Fn
34*0a6a1f1dSLionel Sambuc {
35*0a6a1f1dSLionel Sambuc public:
my_facet(std::size_t refs=0)36*0a6a1f1dSLionel Sambuc     explicit my_facet(std::size_t refs = 0)
37*0a6a1f1dSLionel Sambuc         : Fn(refs) {}
38*0a6a1f1dSLionel Sambuc };
39*0a6a1f1dSLionel Sambuc 
40*0a6a1f1dSLionel Sambuc typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
41*0a6a1f1dSLionel Sambuc 
42*0a6a1f1dSLionel Sambuc class my_facetw
43*0a6a1f1dSLionel Sambuc     : public Fw
44*0a6a1f1dSLionel Sambuc {
45*0a6a1f1dSLionel Sambuc public:
my_facetw(std::size_t refs=0)46*0a6a1f1dSLionel Sambuc     explicit my_facetw(std::size_t refs = 0)
47*0a6a1f1dSLionel Sambuc         : Fw(refs) {}
48*0a6a1f1dSLionel Sambuc };
49*0a6a1f1dSLionel Sambuc 
main()50*0a6a1f1dSLionel Sambuc int main()
51*0a6a1f1dSLionel Sambuc {
52*0a6a1f1dSLionel Sambuc     std::ios ios(0);
53*0a6a1f1dSLionel Sambuc     std::string loc_name(LOCALE_zh_CN_UTF_8);
54*0a6a1f1dSLionel Sambuc     ios.imbue(std::locale(ios.getloc(),
55*0a6a1f1dSLionel Sambuc                           new std::moneypunct_byname<char, false>(loc_name)));
56*0a6a1f1dSLionel Sambuc     ios.imbue(std::locale(ios.getloc(),
57*0a6a1f1dSLionel Sambuc                           new std::moneypunct_byname<char, true>(loc_name)));
58*0a6a1f1dSLionel Sambuc     ios.imbue(std::locale(ios.getloc(),
59*0a6a1f1dSLionel Sambuc                           new std::moneypunct_byname<wchar_t, false>(loc_name)));
60*0a6a1f1dSLionel Sambuc     ios.imbue(std::locale(ios.getloc(),
61*0a6a1f1dSLionel Sambuc                           new std::moneypunct_byname<wchar_t, true>(loc_name)));
62*0a6a1f1dSLionel Sambuc {
63*0a6a1f1dSLionel Sambuc     const my_facet f(1);
64*0a6a1f1dSLionel Sambuc     // char, national
65*0a6a1f1dSLionel Sambuc     {   // zero
66*0a6a1f1dSLionel Sambuc         long double v = 0;
67*0a6a1f1dSLionel Sambuc         char str[100];
68*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
69*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
70*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
71*0a6a1f1dSLionel Sambuc         assert(ex == "0.00");
72*0a6a1f1dSLionel Sambuc     }
73*0a6a1f1dSLionel Sambuc     {   // negative one
74*0a6a1f1dSLionel Sambuc         long double v = -1;
75*0a6a1f1dSLionel Sambuc         char str[100];
76*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
77*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
78*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
79*0a6a1f1dSLionel Sambuc         assert(ex == "-0.01");
80*0a6a1f1dSLionel Sambuc     }
81*0a6a1f1dSLionel Sambuc     {   // positive
82*0a6a1f1dSLionel Sambuc         long double v = 123456789;
83*0a6a1f1dSLionel Sambuc         char str[100];
84*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
85*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
86*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
87*0a6a1f1dSLionel Sambuc         assert(ex == "1,234,567.89");
88*0a6a1f1dSLionel Sambuc     }
89*0a6a1f1dSLionel Sambuc     {   // negative
90*0a6a1f1dSLionel Sambuc         long double v = -123456789;
91*0a6a1f1dSLionel Sambuc         char str[100];
92*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
93*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
94*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
95*0a6a1f1dSLionel Sambuc         assert(ex == "-1,234,567.89");
96*0a6a1f1dSLionel Sambuc     }
97*0a6a1f1dSLionel Sambuc     {   // zero, showbase
98*0a6a1f1dSLionel Sambuc         long double v = 0;
99*0a6a1f1dSLionel Sambuc         showbase(ios);
100*0a6a1f1dSLionel Sambuc         char str[100];
101*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
102*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
103*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
104*0a6a1f1dSLionel Sambuc         assert(ex == "\xEF\xBF\xA5""0.00");
105*0a6a1f1dSLionel Sambuc     }
106*0a6a1f1dSLionel Sambuc     {   // negative one, showbase
107*0a6a1f1dSLionel Sambuc         long double v = -1;
108*0a6a1f1dSLionel Sambuc         showbase(ios);
109*0a6a1f1dSLionel Sambuc         char str[100];
110*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
111*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
112*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
113*0a6a1f1dSLionel Sambuc         assert(ex == "\xEF\xBF\xA5""-0.01");
114*0a6a1f1dSLionel Sambuc     }
115*0a6a1f1dSLionel Sambuc     {   // positive, showbase
116*0a6a1f1dSLionel Sambuc         long double v = 123456789;
117*0a6a1f1dSLionel Sambuc         showbase(ios);
118*0a6a1f1dSLionel Sambuc         char str[100];
119*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
120*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
121*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
122*0a6a1f1dSLionel Sambuc         assert(ex == "\xEF\xBF\xA5""1,234,567.89");
123*0a6a1f1dSLionel Sambuc     }
124*0a6a1f1dSLionel Sambuc     {   // negative, showbase
125*0a6a1f1dSLionel Sambuc         long double v = -123456789;
126*0a6a1f1dSLionel Sambuc         showbase(ios);
127*0a6a1f1dSLionel Sambuc         char str[100];
128*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
129*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
130*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
131*0a6a1f1dSLionel Sambuc         assert(ex == "\xEF\xBF\xA5""-1,234,567.89");
132*0a6a1f1dSLionel Sambuc     }
133*0a6a1f1dSLionel Sambuc     {   // negative, showbase, left
134*0a6a1f1dSLionel Sambuc         long double v = -123456789;
135*0a6a1f1dSLionel Sambuc         showbase(ios);
136*0a6a1f1dSLionel Sambuc         ios.width(20);
137*0a6a1f1dSLionel Sambuc         left(ios);
138*0a6a1f1dSLionel Sambuc         char str[100];
139*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
140*0a6a1f1dSLionel Sambuc                                             false, ios, ' ', v);
141*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
142*0a6a1f1dSLionel Sambuc         assert(ex == "\xEF\xBF\xA5""-1,234,567.89    ");
143*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
144*0a6a1f1dSLionel Sambuc     }
145*0a6a1f1dSLionel Sambuc     {   // negative, showbase, internal
146*0a6a1f1dSLionel Sambuc         long double v = -123456789;
147*0a6a1f1dSLionel Sambuc         showbase(ios);
148*0a6a1f1dSLionel Sambuc         ios.width(20);
149*0a6a1f1dSLionel Sambuc         internal(ios);
150*0a6a1f1dSLionel Sambuc         char str[100];
151*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
152*0a6a1f1dSLionel Sambuc                                             false, ios, ' ', v);
153*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
154*0a6a1f1dSLionel Sambuc         assert(ex == "\xEF\xBF\xA5""-    1,234,567.89");
155*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
156*0a6a1f1dSLionel Sambuc     }
157*0a6a1f1dSLionel Sambuc     {   // negative, showbase, right
158*0a6a1f1dSLionel Sambuc         long double v = -123456789;
159*0a6a1f1dSLionel Sambuc         showbase(ios);
160*0a6a1f1dSLionel Sambuc         ios.width(20);
161*0a6a1f1dSLionel Sambuc         right(ios);
162*0a6a1f1dSLionel Sambuc         char str[100];
163*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
164*0a6a1f1dSLionel Sambuc                                             false, ios, ' ', v);
165*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
166*0a6a1f1dSLionel Sambuc         assert(ex == "    \xEF\xBF\xA5""-1,234,567.89");
167*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
168*0a6a1f1dSLionel Sambuc     }
169*0a6a1f1dSLionel Sambuc 
170*0a6a1f1dSLionel Sambuc     // char, international
171*0a6a1f1dSLionel Sambuc     noshowbase(ios);
172*0a6a1f1dSLionel Sambuc     ios.unsetf(std::ios_base::adjustfield);
173*0a6a1f1dSLionel Sambuc     {   // zero
174*0a6a1f1dSLionel Sambuc         long double v = 0;
175*0a6a1f1dSLionel Sambuc         char str[100];
176*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
177*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
178*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
179*0a6a1f1dSLionel Sambuc         assert(ex == "0.00");
180*0a6a1f1dSLionel Sambuc     }
181*0a6a1f1dSLionel Sambuc     {   // negative one
182*0a6a1f1dSLionel Sambuc         long double v = -1;
183*0a6a1f1dSLionel Sambuc         char str[100];
184*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
185*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
186*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
187*0a6a1f1dSLionel Sambuc         assert(ex == "-0.01");
188*0a6a1f1dSLionel Sambuc     }
189*0a6a1f1dSLionel Sambuc     {   // positive
190*0a6a1f1dSLionel Sambuc         long double v = 123456789;
191*0a6a1f1dSLionel Sambuc         char str[100];
192*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
193*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
194*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
195*0a6a1f1dSLionel Sambuc         assert(ex == "1,234,567.89");
196*0a6a1f1dSLionel Sambuc     }
197*0a6a1f1dSLionel Sambuc     {   // negative
198*0a6a1f1dSLionel Sambuc         long double v = -123456789;
199*0a6a1f1dSLionel Sambuc         char str[100];
200*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
201*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
202*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
203*0a6a1f1dSLionel Sambuc         assert(ex == "-1,234,567.89");
204*0a6a1f1dSLionel Sambuc     }
205*0a6a1f1dSLionel Sambuc     {   // zero, showbase
206*0a6a1f1dSLionel Sambuc         long double v = 0;
207*0a6a1f1dSLionel Sambuc         showbase(ios);
208*0a6a1f1dSLionel Sambuc         char str[100];
209*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
210*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
211*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
212*0a6a1f1dSLionel Sambuc         assert(ex == "CNY 0.00");
213*0a6a1f1dSLionel Sambuc     }
214*0a6a1f1dSLionel Sambuc     {   // negative one, showbase
215*0a6a1f1dSLionel Sambuc         long double v = -1;
216*0a6a1f1dSLionel Sambuc         showbase(ios);
217*0a6a1f1dSLionel Sambuc         char str[100];
218*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
219*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
220*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
221*0a6a1f1dSLionel Sambuc         assert(ex == "CNY -0.01");
222*0a6a1f1dSLionel Sambuc     }
223*0a6a1f1dSLionel Sambuc     {   // positive, showbase
224*0a6a1f1dSLionel Sambuc         long double v = 123456789;
225*0a6a1f1dSLionel Sambuc         showbase(ios);
226*0a6a1f1dSLionel Sambuc         char str[100];
227*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
228*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
229*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
230*0a6a1f1dSLionel Sambuc         assert(ex == "CNY 1,234,567.89");
231*0a6a1f1dSLionel Sambuc     }
232*0a6a1f1dSLionel Sambuc     {   // negative, showbase
233*0a6a1f1dSLionel Sambuc         long double v = -123456789;
234*0a6a1f1dSLionel Sambuc         showbase(ios);
235*0a6a1f1dSLionel Sambuc         char str[100];
236*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
237*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
238*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
239*0a6a1f1dSLionel Sambuc         assert(ex == "CNY -1,234,567.89");
240*0a6a1f1dSLionel Sambuc     }
241*0a6a1f1dSLionel Sambuc     {   // negative, showbase, left
242*0a6a1f1dSLionel Sambuc         long double v = -123456789;
243*0a6a1f1dSLionel Sambuc         showbase(ios);
244*0a6a1f1dSLionel Sambuc         ios.width(20);
245*0a6a1f1dSLionel Sambuc         left(ios);
246*0a6a1f1dSLionel Sambuc         char str[100];
247*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
248*0a6a1f1dSLionel Sambuc                                             true, ios, ' ', v);
249*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
250*0a6a1f1dSLionel Sambuc         assert(ex == "CNY -1,234,567.89   ");
251*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
252*0a6a1f1dSLionel Sambuc     }
253*0a6a1f1dSLionel Sambuc     {   // negative, showbase, internal
254*0a6a1f1dSLionel Sambuc         long double v = -123456789;
255*0a6a1f1dSLionel Sambuc         showbase(ios);
256*0a6a1f1dSLionel Sambuc         ios.width(20);
257*0a6a1f1dSLionel Sambuc         internal(ios);
258*0a6a1f1dSLionel Sambuc         char str[100];
259*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
260*0a6a1f1dSLionel Sambuc                                             true, ios, ' ', v);
261*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
262*0a6a1f1dSLionel Sambuc         assert(ex == "CNY -   1,234,567.89");
263*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
264*0a6a1f1dSLionel Sambuc     }
265*0a6a1f1dSLionel Sambuc     {   // negative, showbase, right
266*0a6a1f1dSLionel Sambuc         long double v = -123456789;
267*0a6a1f1dSLionel Sambuc         showbase(ios);
268*0a6a1f1dSLionel Sambuc         ios.width(20);
269*0a6a1f1dSLionel Sambuc         right(ios);
270*0a6a1f1dSLionel Sambuc         char str[100];
271*0a6a1f1dSLionel Sambuc         output_iterator<char*> iter = f.put(output_iterator<char*>(str),
272*0a6a1f1dSLionel Sambuc                                             true, ios, ' ', v);
273*0a6a1f1dSLionel Sambuc         std::string ex(str, iter.base());
274*0a6a1f1dSLionel Sambuc         assert(ex == "   CNY -1,234,567.89");
275*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
276*0a6a1f1dSLionel Sambuc     }
277*0a6a1f1dSLionel Sambuc }
278*0a6a1f1dSLionel Sambuc {
279*0a6a1f1dSLionel Sambuc     const my_facetw f(1);
280*0a6a1f1dSLionel Sambuc     // wchar_t, national
281*0a6a1f1dSLionel Sambuc     noshowbase(ios);
282*0a6a1f1dSLionel Sambuc     ios.unsetf(std::ios_base::adjustfield);
283*0a6a1f1dSLionel Sambuc     {   // zero
284*0a6a1f1dSLionel Sambuc         long double v = 0;
285*0a6a1f1dSLionel Sambuc         wchar_t str[100];
286*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
287*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
288*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
289*0a6a1f1dSLionel Sambuc         assert(ex == L"0.00");
290*0a6a1f1dSLionel Sambuc     }
291*0a6a1f1dSLionel Sambuc     {   // negative one
292*0a6a1f1dSLionel Sambuc         long double v = -1;
293*0a6a1f1dSLionel Sambuc         wchar_t str[100];
294*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
295*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
296*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
297*0a6a1f1dSLionel Sambuc         assert(ex == L"-0.01");
298*0a6a1f1dSLionel Sambuc     }
299*0a6a1f1dSLionel Sambuc     {   // positive
300*0a6a1f1dSLionel Sambuc         long double v = 123456789;
301*0a6a1f1dSLionel Sambuc         wchar_t str[100];
302*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
303*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
304*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
305*0a6a1f1dSLionel Sambuc         assert(ex == L"1,234,567.89");
306*0a6a1f1dSLionel Sambuc     }
307*0a6a1f1dSLionel Sambuc     {   // negative
308*0a6a1f1dSLionel Sambuc         long double v = -123456789;
309*0a6a1f1dSLionel Sambuc         wchar_t str[100];
310*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
311*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
312*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
313*0a6a1f1dSLionel Sambuc         assert(ex == L"-1,234,567.89");
314*0a6a1f1dSLionel Sambuc     }
315*0a6a1f1dSLionel Sambuc     {   // zero, showbase
316*0a6a1f1dSLionel Sambuc         long double v = 0;
317*0a6a1f1dSLionel Sambuc         showbase(ios);
318*0a6a1f1dSLionel Sambuc         wchar_t str[100];
319*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
320*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
321*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
322*0a6a1f1dSLionel Sambuc         assert(ex == L"\xFFE5""0.00");
323*0a6a1f1dSLionel Sambuc     }
324*0a6a1f1dSLionel Sambuc     {   // negative one, showbase
325*0a6a1f1dSLionel Sambuc         long double v = -1;
326*0a6a1f1dSLionel Sambuc         showbase(ios);
327*0a6a1f1dSLionel Sambuc         wchar_t str[100];
328*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
329*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
330*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
331*0a6a1f1dSLionel Sambuc         assert(ex == L"\xFFE5""-0.01");
332*0a6a1f1dSLionel Sambuc     }
333*0a6a1f1dSLionel Sambuc     {   // positive, showbase
334*0a6a1f1dSLionel Sambuc         long double v = 123456789;
335*0a6a1f1dSLionel Sambuc         showbase(ios);
336*0a6a1f1dSLionel Sambuc         wchar_t str[100];
337*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
338*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
339*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
340*0a6a1f1dSLionel Sambuc         assert(ex == L"\xFFE5""1,234,567.89");
341*0a6a1f1dSLionel Sambuc     }
342*0a6a1f1dSLionel Sambuc     {   // negative, showbase
343*0a6a1f1dSLionel Sambuc         long double v = -123456789;
344*0a6a1f1dSLionel Sambuc         showbase(ios);
345*0a6a1f1dSLionel Sambuc         wchar_t str[100];
346*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
347*0a6a1f1dSLionel Sambuc                                             false, ios, '*', v);
348*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
349*0a6a1f1dSLionel Sambuc         assert(ex == L"\xFFE5""-1,234,567.89");
350*0a6a1f1dSLionel Sambuc     }
351*0a6a1f1dSLionel Sambuc     {   // negative, showbase, left
352*0a6a1f1dSLionel Sambuc         long double v = -123456789;
353*0a6a1f1dSLionel Sambuc         showbase(ios);
354*0a6a1f1dSLionel Sambuc         ios.width(20);
355*0a6a1f1dSLionel Sambuc         left(ios);
356*0a6a1f1dSLionel Sambuc         wchar_t str[100];
357*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
358*0a6a1f1dSLionel Sambuc                                             false, ios, ' ', v);
359*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
360*0a6a1f1dSLionel Sambuc         assert(ex == L"\xFFE5""-1,234,567.89      ");
361*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
362*0a6a1f1dSLionel Sambuc     }
363*0a6a1f1dSLionel Sambuc     {   // negative, showbase, internal
364*0a6a1f1dSLionel Sambuc         long double v = -123456789;
365*0a6a1f1dSLionel Sambuc         showbase(ios);
366*0a6a1f1dSLionel Sambuc         ios.width(20);
367*0a6a1f1dSLionel Sambuc         internal(ios);
368*0a6a1f1dSLionel Sambuc         wchar_t str[100];
369*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
370*0a6a1f1dSLionel Sambuc                                             false, ios, ' ', v);
371*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
372*0a6a1f1dSLionel Sambuc         assert(ex == L"\xFFE5""-      1,234,567.89");
373*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
374*0a6a1f1dSLionel Sambuc     }
375*0a6a1f1dSLionel Sambuc     {   // negative, showbase, right
376*0a6a1f1dSLionel Sambuc         long double v = -123456789;
377*0a6a1f1dSLionel Sambuc         showbase(ios);
378*0a6a1f1dSLionel Sambuc         ios.width(20);
379*0a6a1f1dSLionel Sambuc         right(ios);
380*0a6a1f1dSLionel Sambuc         wchar_t str[100];
381*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
382*0a6a1f1dSLionel Sambuc                                             false, ios, ' ', v);
383*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
384*0a6a1f1dSLionel Sambuc         assert(ex == L"      \xFFE5""-1,234,567.89");
385*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
386*0a6a1f1dSLionel Sambuc     }
387*0a6a1f1dSLionel Sambuc 
388*0a6a1f1dSLionel Sambuc     // wchar_t, international
389*0a6a1f1dSLionel Sambuc     noshowbase(ios);
390*0a6a1f1dSLionel Sambuc     ios.unsetf(std::ios_base::adjustfield);
391*0a6a1f1dSLionel Sambuc     {   // zero
392*0a6a1f1dSLionel Sambuc         long double v = 0;
393*0a6a1f1dSLionel Sambuc         wchar_t str[100];
394*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
395*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
396*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
397*0a6a1f1dSLionel Sambuc         assert(ex == L"0.00");
398*0a6a1f1dSLionel Sambuc     }
399*0a6a1f1dSLionel Sambuc     {   // negative one
400*0a6a1f1dSLionel Sambuc         long double v = -1;
401*0a6a1f1dSLionel Sambuc         wchar_t str[100];
402*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
403*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
404*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
405*0a6a1f1dSLionel Sambuc         assert(ex == L"-0.01");
406*0a6a1f1dSLionel Sambuc     }
407*0a6a1f1dSLionel Sambuc     {   // positive
408*0a6a1f1dSLionel Sambuc         long double v = 123456789;
409*0a6a1f1dSLionel Sambuc         wchar_t str[100];
410*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
411*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
412*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
413*0a6a1f1dSLionel Sambuc         assert(ex == L"1,234,567.89");
414*0a6a1f1dSLionel Sambuc     }
415*0a6a1f1dSLionel Sambuc     {   // negative
416*0a6a1f1dSLionel Sambuc         long double v = -123456789;
417*0a6a1f1dSLionel Sambuc         wchar_t str[100];
418*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
419*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
420*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
421*0a6a1f1dSLionel Sambuc         assert(ex == L"-1,234,567.89");
422*0a6a1f1dSLionel Sambuc     }
423*0a6a1f1dSLionel Sambuc     {   // zero, showbase
424*0a6a1f1dSLionel Sambuc         long double v = 0;
425*0a6a1f1dSLionel Sambuc         showbase(ios);
426*0a6a1f1dSLionel Sambuc         wchar_t str[100];
427*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
428*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
429*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
430*0a6a1f1dSLionel Sambuc         assert(ex == L"CNY 0.00");
431*0a6a1f1dSLionel Sambuc     }
432*0a6a1f1dSLionel Sambuc     {   // negative one, showbase
433*0a6a1f1dSLionel Sambuc         long double v = -1;
434*0a6a1f1dSLionel Sambuc         showbase(ios);
435*0a6a1f1dSLionel Sambuc         wchar_t str[100];
436*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
437*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
438*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
439*0a6a1f1dSLionel Sambuc         assert(ex == L"CNY -0.01");
440*0a6a1f1dSLionel Sambuc     }
441*0a6a1f1dSLionel Sambuc     {   // positive, showbase
442*0a6a1f1dSLionel Sambuc         long double v = 123456789;
443*0a6a1f1dSLionel Sambuc         showbase(ios);
444*0a6a1f1dSLionel Sambuc         wchar_t str[100];
445*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
446*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
447*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
448*0a6a1f1dSLionel Sambuc         assert(ex == L"CNY 1,234,567.89");
449*0a6a1f1dSLionel Sambuc     }
450*0a6a1f1dSLionel Sambuc     {   // negative, showbase
451*0a6a1f1dSLionel Sambuc         long double v = -123456789;
452*0a6a1f1dSLionel Sambuc         showbase(ios);
453*0a6a1f1dSLionel Sambuc         wchar_t str[100];
454*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
455*0a6a1f1dSLionel Sambuc                                             true, ios, '*', v);
456*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
457*0a6a1f1dSLionel Sambuc         assert(ex == L"CNY -1,234,567.89");
458*0a6a1f1dSLionel Sambuc     }
459*0a6a1f1dSLionel Sambuc     {   // negative, showbase, left
460*0a6a1f1dSLionel Sambuc         long double v = -123456789;
461*0a6a1f1dSLionel Sambuc         showbase(ios);
462*0a6a1f1dSLionel Sambuc         ios.width(20);
463*0a6a1f1dSLionel Sambuc         left(ios);
464*0a6a1f1dSLionel Sambuc         wchar_t str[100];
465*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
466*0a6a1f1dSLionel Sambuc                                             true, ios, ' ', v);
467*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
468*0a6a1f1dSLionel Sambuc         assert(ex == L"CNY -1,234,567.89   ");
469*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
470*0a6a1f1dSLionel Sambuc     }
471*0a6a1f1dSLionel Sambuc     {   // negative, showbase, internal
472*0a6a1f1dSLionel Sambuc         long double v = -123456789;
473*0a6a1f1dSLionel Sambuc         showbase(ios);
474*0a6a1f1dSLionel Sambuc         ios.width(20);
475*0a6a1f1dSLionel Sambuc         internal(ios);
476*0a6a1f1dSLionel Sambuc         wchar_t str[100];
477*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
478*0a6a1f1dSLionel Sambuc                                             true, ios, ' ', v);
479*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
480*0a6a1f1dSLionel Sambuc         assert(ex == L"CNY -   1,234,567.89");
481*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
482*0a6a1f1dSLionel Sambuc     }
483*0a6a1f1dSLionel Sambuc     {   // negative, showbase, right
484*0a6a1f1dSLionel Sambuc         long double v = -123456789;
485*0a6a1f1dSLionel Sambuc         showbase(ios);
486*0a6a1f1dSLionel Sambuc         ios.width(20);
487*0a6a1f1dSLionel Sambuc         right(ios);
488*0a6a1f1dSLionel Sambuc         wchar_t str[100];
489*0a6a1f1dSLionel Sambuc         output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
490*0a6a1f1dSLionel Sambuc                                             true, ios, ' ', v);
491*0a6a1f1dSLionel Sambuc         std::wstring ex(str, iter.base());
492*0a6a1f1dSLionel Sambuc         assert(ex == L"   CNY -1,234,567.89");
493*0a6a1f1dSLionel Sambuc         assert(ios.width() == 0);
494*0a6a1f1dSLionel Sambuc     }
495*0a6a1f1dSLionel Sambuc }
496*0a6a1f1dSLionel Sambuc }
497