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 // REQUIRES: locale.zh_CN.UTF-8
11 
12 // <locale>
13 
14 // class money_get<charT, InputIterator>
15 
16 // iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
17 //               ios_base::iostate& err, long double& v) const;
18 
19 // TODO For zh_CN GLIBC puts the negative sign after the currency symbol.
20 // XFAIL: linux-gnu
21 
22 #include <locale>
23 #include <ios>
24 #include <streambuf>
25 #include <cassert>
26 #include "test_iterators.h"
27 
28 #include "platform_support.h" // locale name macros
29 
30 typedef std::money_get<char, input_iterator<const char*> > Fn;
31 
32 class my_facet
33     : public Fn
34 {
35 public:
my_facet(std::size_t refs=0)36     explicit my_facet(std::size_t refs = 0)
37         : Fn(refs) {}
38 };
39 
40 typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
41 
42 class my_facetw
43     : public Fw
44 {
45 public:
my_facetw(std::size_t refs=0)46     explicit my_facetw(std::size_t refs = 0)
47         : Fw(refs) {}
48 };
49 
main()50 int main()
51 {
52     std::ios ios(0);
53     std::string loc_name(LOCALE_zh_CN_UTF_8);
54     ios.imbue(std::locale(ios.getloc(),
55                           new std::moneypunct_byname<char, false>(loc_name)));
56     ios.imbue(std::locale(ios.getloc(),
57                           new std::moneypunct_byname<char, true>(loc_name)));
58     ios.imbue(std::locale(ios.getloc(),
59                           new std::moneypunct_byname<wchar_t, false>(loc_name)));
60     ios.imbue(std::locale(ios.getloc(),
61                           new std::moneypunct_byname<wchar_t, true>(loc_name)));
62     {
63         const my_facet f(1);
64         // char, national
65         {   // zero
66             std::string v = "0.00";
67             typedef input_iterator<const char*> I;
68             long double ex;
69             std::ios_base::iostate err = std::ios_base::goodbit;
70             I iter = f.get(I(v.data()), I(v.data() + v.size()),
71                                                 false, ios, err, ex);
72             assert(iter.base() == v.data() + v.size());
73             assert(err == std::ios_base::eofbit);
74             assert(ex == 0);
75         }
76         {   // negative one
77             std::string v = "-0.01";
78             typedef input_iterator<const char*> I;
79             long double ex;
80             std::ios_base::iostate err = std::ios_base::goodbit;
81             I iter = f.get(I(v.data()), I(v.data() + v.size()),
82                                                 false, ios, err, ex);
83             assert(iter.base() == v.data() + v.size());
84             assert(err == std::ios_base::eofbit);
85             assert(ex == -1);
86         }
87         {   // positive
88             std::string v = "1,234,567.89";
89             typedef input_iterator<const char*> I;
90             long double ex;
91             std::ios_base::iostate err = std::ios_base::goodbit;
92             I iter = f.get(I(v.data()), I(v.data() + v.size()),
93                                                 false, ios, err, ex);
94             assert(iter.base() == v.data() + v.size());
95             assert(err == std::ios_base::eofbit);
96             assert(ex == 123456789);
97         }
98         {   // negative
99             std::string v = "-1,234,567.89";
100             typedef input_iterator<const char*> I;
101             long double ex;
102             std::ios_base::iostate err = std::ios_base::goodbit;
103             I iter = f.get(I(v.data()), I(v.data() + v.size()),
104                                                 false, ios, err, ex);
105             assert(iter.base() == v.data() + v.size());
106             assert(err == std::ios_base::eofbit);
107             assert(ex == -123456789);
108         }
109         {   // negative
110             std::string v = "-1234567.89";
111             typedef input_iterator<const char*> I;
112             long double ex;
113             std::ios_base::iostate err = std::ios_base::goodbit;
114             I iter = f.get(I(v.data()), I(v.data() + v.size()),
115                                                 false, ios, err, ex);
116             assert(iter.base() == v.data() + v.size());
117             assert(err == std::ios_base::eofbit);
118             assert(ex == -123456789);
119         }
120         {   // zero, showbase
121             std::string v = "\xEF\xBF\xA5""0.00";
122             typedef input_iterator<const char*> I;
123             long double ex;
124             std::ios_base::iostate err = std::ios_base::goodbit;
125             I iter = f.get(I(v.data()), I(v.data() + v.size()),
126                                                 false, ios, err, ex);
127             assert(iter.base() == v.data() + v.size());
128             assert(err == std::ios_base::eofbit);
129             assert(ex == 0);
130         }
131         {   // zero, showbase
132             std::string v = "\xEF\xBF\xA5""0.00";
133             showbase(ios);
134             typedef input_iterator<const char*> I;
135             long double ex;
136             std::ios_base::iostate err = std::ios_base::goodbit;
137             I iter = f.get(I(v.data()), I(v.data() + v.size()),
138                                                 false, ios, err, ex);
139             assert(iter.base() == v.data() + v.size());
140             assert(err == std::ios_base::eofbit);
141             assert(ex == 0);
142             noshowbase(ios);
143         }
144         {   // negative one, showbase
145             std::string v = "\xEF\xBF\xA5""-0.01";
146             typedef input_iterator<const char*> I;
147             long double ex;
148             std::ios_base::iostate err = std::ios_base::goodbit;
149             I iter = f.get(I(v.data()), I(v.data() + v.size()),
150                                                 false, ios, err, ex);
151             assert(iter.base() == v.data() + v.size());
152             assert(err == std::ios_base::eofbit);
153             assert(ex == -1);
154         }
155         {   // negative one, showbase
156             std::string v = "\xEF\xBF\xA5""-0.01";
157             showbase(ios);
158             typedef input_iterator<const char*> I;
159             long double ex;
160             std::ios_base::iostate err = std::ios_base::goodbit;
161             I iter = f.get(I(v.data()), I(v.data() + v.size()),
162                                                 false, ios, err, ex);
163             assert(iter.base() == v.data() + v.size());
164             assert(err == std::ios_base::eofbit);
165             assert(ex == -1);
166             noshowbase(ios);
167         }
168         {   // positive, showbase
169             std::string v = "\xEF\xBF\xA5""1,234,567.89";
170             typedef input_iterator<const char*> I;
171             long double ex;
172             std::ios_base::iostate err = std::ios_base::goodbit;
173             I iter = f.get(I(v.data()), I(v.data() + v.size()),
174                                                 false, ios, err, ex);
175             assert(iter.base() == v.data() + v.size());
176             assert(err == std::ios_base::eofbit);
177             assert(ex == 123456789);
178         }
179         {   // positive, showbase
180             std::string v = "\xEF\xBF\xA5""1,234,567.89";
181             showbase(ios);
182             typedef input_iterator<const char*> I;
183             long double ex;
184             std::ios_base::iostate err = std::ios_base::goodbit;
185             I iter = f.get(I(v.data()), I(v.data() + v.size()),
186                                                 false, ios, err, ex);
187             assert(iter.base() == v.data() + v.size());
188             assert(err == std::ios_base::eofbit);
189             assert(ex == 123456789);
190             noshowbase(ios);
191         }
192         {   // negative, showbase
193             std::string v = "\xEF\xBF\xA5""-1,234,567.89";
194             showbase(ios);
195             typedef input_iterator<const char*> I;
196             long double ex;
197             std::ios_base::iostate err = std::ios_base::goodbit;
198             I iter = f.get(I(v.data()), I(v.data() + v.size()),
199                                                 false, ios, err, ex);
200             assert(iter.base() == v.data() + v.size());
201             assert(err == std::ios_base::eofbit);
202             assert(ex == -123456789);
203             noshowbase(ios);
204         }
205         {   // negative, showbase
206             std::string v = "CNY -1,234,567.89";
207             showbase(ios);
208             typedef input_iterator<const char*> I;
209             long double ex;
210             std::ios_base::iostate err = std::ios_base::goodbit;
211             I iter = f.get(I(v.data()), I(v.data() + v.size()),
212                                                 false, ios, err, ex);
213             assert(iter.base() == v.data() + 0);
214             assert(err == std::ios_base::failbit);
215             noshowbase(ios);
216         }
217         {   // negative, showbase
218             std::string v = "CNY -1,234,567.89";
219             typedef input_iterator<const char*> I;
220             long double ex;
221             std::ios_base::iostate err = std::ios_base::goodbit;
222             I iter = f.get(I(v.data()), I(v.data() + v.size()),
223                                                 false, ios, err, ex);
224             assert(iter.base() == v.data() + 0);
225             assert(err == std::ios_base::failbit);
226         }
227     }
228     {
229         const my_facet f(1);
230         // char, international
231         {   // zero
232             std::string v = "0.00";
233             typedef input_iterator<const char*> I;
234             long double ex;
235             std::ios_base::iostate err = std::ios_base::goodbit;
236             I iter = f.get(I(v.data()), I(v.data() + v.size()),
237                                                 true, ios, err, ex);
238             assert(iter.base() == v.data() + v.size());
239             assert(err == std::ios_base::eofbit);
240             assert(ex == 0);
241         }
242         {   // negative one
243             std::string v = "-0.01";
244             typedef input_iterator<const char*> I;
245             long double ex;
246             std::ios_base::iostate err = std::ios_base::goodbit;
247             I iter = f.get(I(v.data()), I(v.data() + v.size()),
248                                                 true, ios, err, ex);
249             assert(iter.base() == v.data() + v.size());
250             assert(err == std::ios_base::eofbit);
251             assert(ex == -1);
252         }
253         {   // positive
254             std::string v = "1,234,567.89";
255             typedef input_iterator<const char*> I;
256             long double ex;
257             std::ios_base::iostate err = std::ios_base::goodbit;
258             I iter = f.get(I(v.data()), I(v.data() + v.size()),
259                                                 true, ios, err, ex);
260             assert(iter.base() == v.data() + v.size());
261             assert(err == std::ios_base::eofbit);
262             assert(ex == 123456789);
263         }
264         {   // negative
265             std::string v = "-1,234,567.89";
266             typedef input_iterator<const char*> I;
267             long double ex;
268             std::ios_base::iostate err = std::ios_base::goodbit;
269             I iter = f.get(I(v.data()), I(v.data() + v.size()),
270                                                 true, ios, err, ex);
271             assert(iter.base() == v.data() + v.size());
272             assert(err == std::ios_base::eofbit);
273             assert(ex == -123456789);
274         }
275         {   // negative
276             std::string v = "-1234567.89";
277             typedef input_iterator<const char*> I;
278             long double ex;
279             std::ios_base::iostate err = std::ios_base::goodbit;
280             I iter = f.get(I(v.data()), I(v.data() + v.size()),
281                                                 true, ios, err, ex);
282             assert(iter.base() == v.data() + v.size());
283             assert(err == std::ios_base::eofbit);
284             assert(ex == -123456789);
285         }
286         {   // zero, showbase
287             std::string v = "CNY 0.00";
288             typedef input_iterator<const char*> I;
289             long double ex;
290             std::ios_base::iostate err = std::ios_base::goodbit;
291             I iter = f.get(I(v.data()), I(v.data() + v.size()),
292                                                 true, ios, err, ex);
293             assert(iter.base() == v.data() + v.size());
294             assert(err == std::ios_base::eofbit);
295             assert(ex == 0);
296         }
297         {   // zero, showbase
298             std::string v = "CNY 0.00";
299             showbase(ios);
300             typedef input_iterator<const char*> I;
301             long double ex;
302             std::ios_base::iostate err = std::ios_base::goodbit;
303             I iter = f.get(I(v.data()), I(v.data() + v.size()),
304                                                 true, ios, err, ex);
305             assert(iter.base() == v.data() + v.size());
306             assert(err == std::ios_base::eofbit);
307             assert(ex == 0);
308             noshowbase(ios);
309         }
310         {   // negative one, showbase
311             std::string v = "CNY -0.01";
312             typedef input_iterator<const char*> I;
313             long double ex;
314             std::ios_base::iostate err = std::ios_base::goodbit;
315             I iter = f.get(I(v.data()), I(v.data() + v.size()),
316                                                 true, ios, err, ex);
317             assert(iter.base() == v.data() + v.size());
318             assert(err == std::ios_base::eofbit);
319             assert(ex == -1);
320         }
321         {   // negative one, showbase
322             std::string v = "CNY -0.01";
323             showbase(ios);
324             typedef input_iterator<const char*> I;
325             long double ex;
326             std::ios_base::iostate err = std::ios_base::goodbit;
327             I iter = f.get(I(v.data()), I(v.data() + v.size()),
328                                                 true, ios, err, ex);
329             assert(iter.base() == v.data() + v.size());
330             assert(err == std::ios_base::eofbit);
331             assert(ex == -1);
332             noshowbase(ios);
333         }
334         {   // positive, showbase
335             std::string v = "CNY 1,234,567.89";
336             typedef input_iterator<const char*> I;
337             long double ex;
338             std::ios_base::iostate err = std::ios_base::goodbit;
339             I iter = f.get(I(v.data()), I(v.data() + v.size()),
340                                                 true, ios, err, ex);
341             assert(iter.base() == v.data() + v.size());
342             assert(err == std::ios_base::eofbit);
343             assert(ex == 123456789);
344         }
345         {   // positive, showbase
346             std::string v = "CNY 1,234,567.89";
347             showbase(ios);
348             typedef input_iterator<const char*> I;
349             long double ex;
350             std::ios_base::iostate err = std::ios_base::goodbit;
351             I iter = f.get(I(v.data()), I(v.data() + v.size()),
352                                                 true, ios, err, ex);
353             assert(iter.base() == v.data() + v.size());
354             assert(err == std::ios_base::eofbit);
355             assert(ex == 123456789);
356             noshowbase(ios);
357         }
358         {   // negative, showbase
359             std::string v = "CNY -1,234,567.89";
360             showbase(ios);
361             typedef input_iterator<const char*> I;
362             long double ex;
363             std::ios_base::iostate err = std::ios_base::goodbit;
364             I iter = f.get(I(v.data()), I(v.data() + v.size()),
365                                                 true, ios, err, ex);
366             assert(iter.base() == v.data() + v.size());
367             assert(err == std::ios_base::eofbit);
368             assert(ex == -123456789);
369             noshowbase(ios);
370         }
371         {   // negative, showbase
372             std::string v = "\xEF\xBF\xA5""-1,234,567.89";
373             showbase(ios);
374             typedef input_iterator<const char*> I;
375             long double ex;
376             std::ios_base::iostate err = std::ios_base::goodbit;
377             I iter = f.get(I(v.data()), I(v.data() + v.size()),
378                                                 true, ios, err, ex);
379             assert(iter.base() == v.data() + 0);
380             assert(err == std::ios_base::failbit);
381             noshowbase(ios);
382         }
383         {   // negative, showbase
384             std::string v = "\xEF\xBF\xA5""-1,234,567.89";
385             typedef input_iterator<const char*> I;
386             long double ex;
387             std::ios_base::iostate err = std::ios_base::goodbit;
388             I iter = f.get(I(v.data()), I(v.data() + v.size()),
389                                                 true, ios, err, ex);
390             assert(iter.base() == v.data() + 0);
391             assert(err == std::ios_base::failbit);
392         }
393     }
394     {
395         const my_facetw f(1);
396         // wchar_t, national
397         {   // zero
398             std::wstring v = L"0.00";
399             typedef input_iterator<const wchar_t*> I;
400             long double ex;
401             std::ios_base::iostate err = std::ios_base::goodbit;
402             I iter = f.get(I(v.data()), I(v.data() + v.size()),
403                                                 false, ios, err, ex);
404             assert(iter.base() == v.data() + v.size());
405             assert(err == std::ios_base::eofbit);
406             assert(ex == 0);
407         }
408         {   // negative one
409             std::wstring v = L"-0.01";
410             typedef input_iterator<const wchar_t*> I;
411             long double ex;
412             std::ios_base::iostate err = std::ios_base::goodbit;
413             I iter = f.get(I(v.data()), I(v.data() + v.size()),
414                                                 false, ios, err, ex);
415             assert(iter.base() == v.data() + v.size());
416             assert(err == std::ios_base::eofbit);
417             assert(ex == -1);
418         }
419         {   // positive
420             std::wstring v = L"1,234,567.89";
421             typedef input_iterator<const wchar_t*> I;
422             long double ex;
423             std::ios_base::iostate err = std::ios_base::goodbit;
424             I iter = f.get(I(v.data()), I(v.data() + v.size()),
425                                                 false, ios, err, ex);
426             assert(iter.base() == v.data() + v.size());
427             assert(err == std::ios_base::eofbit);
428             assert(ex == 123456789);
429         }
430         {   // negative
431             std::wstring v = L"-1,234,567.89";
432             typedef input_iterator<const wchar_t*> I;
433             long double ex;
434             std::ios_base::iostate err = std::ios_base::goodbit;
435             I iter = f.get(I(v.data()), I(v.data() + v.size()),
436                                                 false, ios, err, ex);
437             assert(iter.base() == v.data() + v.size());
438             assert(err == std::ios_base::eofbit);
439             assert(ex == -123456789);
440         }
441         {   // negative
442             std::wstring v = L"-1234567.89";
443             typedef input_iterator<const wchar_t*> I;
444             long double ex;
445             std::ios_base::iostate err = std::ios_base::goodbit;
446             I iter = f.get(I(v.data()), I(v.data() + v.size()),
447                                                 false, ios, err, ex);
448             assert(iter.base() == v.data() + v.size());
449             assert(err == std::ios_base::eofbit);
450             assert(ex == -123456789);
451         }
452         {   // zero, showbase
453             std::wstring v = L"\xFFE5""0.00";
454             typedef input_iterator<const wchar_t*> I;
455             long double ex;
456             std::ios_base::iostate err = std::ios_base::goodbit;
457             I iter = f.get(I(v.data()), I(v.data() + v.size()),
458                                                 false, ios, err, ex);
459             assert(iter.base() == v.data() + v.size());
460             assert(err == std::ios_base::eofbit);
461             assert(ex == 0);
462         }
463         {   // zero, showbase
464             std::wstring v = L"\xFFE5""0.00";
465             showbase(ios);
466             typedef input_iterator<const wchar_t*> I;
467             long double ex;
468             std::ios_base::iostate err = std::ios_base::goodbit;
469             I iter = f.get(I(v.data()), I(v.data() + v.size()),
470                                                 false, ios, err, ex);
471             assert(iter.base() == v.data() + v.size());
472             assert(err == std::ios_base::eofbit);
473             assert(ex == 0);
474             noshowbase(ios);
475         }
476         {   // negative one, showbase
477             std::wstring v = L"\xFFE5""-0.01";
478             typedef input_iterator<const wchar_t*> I;
479             long double ex;
480             std::ios_base::iostate err = std::ios_base::goodbit;
481             I iter = f.get(I(v.data()), I(v.data() + v.size()),
482                                                 false, ios, err, ex);
483             assert(iter.base() == v.data() + v.size());
484             assert(err == std::ios_base::eofbit);
485             assert(ex == -1);
486         }
487         {   // negative one, showbase
488             std::wstring v = L"\xFFE5""-0.01";
489             showbase(ios);
490             typedef input_iterator<const wchar_t*> I;
491             long double ex;
492             std::ios_base::iostate err = std::ios_base::goodbit;
493             I iter = f.get(I(v.data()), I(v.data() + v.size()),
494                                                 false, ios, err, ex);
495             assert(iter.base() == v.data() + v.size());
496             assert(err == std::ios_base::eofbit);
497             assert(ex == -1);
498             noshowbase(ios);
499         }
500         {   // positive, showbase
501             std::wstring v = L"\xFFE5""1,234,567.89";
502             typedef input_iterator<const wchar_t*> I;
503             long double ex;
504             std::ios_base::iostate err = std::ios_base::goodbit;
505             I iter = f.get(I(v.data()), I(v.data() + v.size()),
506                                                 false, ios, err, ex);
507             assert(iter.base() == v.data() + v.size());
508             assert(err == std::ios_base::eofbit);
509             assert(ex == 123456789);
510         }
511         {   // positive, showbase
512             std::wstring v = L"\xFFE5""1,234,567.89";
513             showbase(ios);
514             typedef input_iterator<const wchar_t*> I;
515             long double ex;
516             std::ios_base::iostate err = std::ios_base::goodbit;
517             I iter = f.get(I(v.data()), I(v.data() + v.size()),
518                                                 false, ios, err, ex);
519             assert(iter.base() == v.data() + v.size());
520             assert(err == std::ios_base::eofbit);
521             assert(ex == 123456789);
522             noshowbase(ios);
523         }
524         {   // negative, showbase
525             std::wstring v = L"\xFFE5""-1,234,567.89";
526             showbase(ios);
527             typedef input_iterator<const wchar_t*> I;
528             long double ex;
529             std::ios_base::iostate err = std::ios_base::goodbit;
530             I iter = f.get(I(v.data()), I(v.data() + v.size()),
531                                                 false, ios, err, ex);
532             assert(iter.base() == v.data() + v.size());
533             assert(err == std::ios_base::eofbit);
534             assert(ex == -123456789);
535             noshowbase(ios);
536         }
537         {   // negative, showbase
538             std::wstring v = L"CNY -1,234,567.89";
539             showbase(ios);
540             typedef input_iterator<const wchar_t*> I;
541             long double ex;
542             std::ios_base::iostate err = std::ios_base::goodbit;
543             I iter = f.get(I(v.data()), I(v.data() + v.size()),
544                                                 false, ios, err, ex);
545             assert(iter.base() == v.data() + 0);
546             assert(err == std::ios_base::failbit);
547             noshowbase(ios);
548         }
549         {   // negative, showbase
550             std::wstring v = L"CNY -1,234,567.89";
551             typedef input_iterator<const wchar_t*> I;
552             long double ex;
553             std::ios_base::iostate err = std::ios_base::goodbit;
554             I iter = f.get(I(v.data()), I(v.data() + v.size()),
555                                                 false, ios, err, ex);
556             assert(iter.base() == v.data() + 0);
557             assert(err == std::ios_base::failbit);
558         }
559     }
560     {
561         const my_facetw f(1);
562         // wchar_t, international
563         {   // zero
564             std::wstring v = L"0.00";
565             typedef input_iterator<const wchar_t*> I;
566             long double ex;
567             std::ios_base::iostate err = std::ios_base::goodbit;
568             I iter = f.get(I(v.data()), I(v.data() + v.size()),
569                                                 true, ios, err, ex);
570             assert(iter.base() == v.data() + v.size());
571             assert(err == std::ios_base::eofbit);
572             assert(ex == 0);
573         }
574         {   // negative one
575             std::wstring v = L"-0.01";
576             typedef input_iterator<const wchar_t*> I;
577             long double ex;
578             std::ios_base::iostate err = std::ios_base::goodbit;
579             I iter = f.get(I(v.data()), I(v.data() + v.size()),
580                                                 true, ios, err, ex);
581             assert(iter.base() == v.data() + v.size());
582             assert(err == std::ios_base::eofbit);
583             assert(ex == -1);
584         }
585         {   // positive
586             std::wstring v = L"1,234,567.89";
587             typedef input_iterator<const wchar_t*> I;
588             long double ex;
589             std::ios_base::iostate err = std::ios_base::goodbit;
590             I iter = f.get(I(v.data()), I(v.data() + v.size()),
591                                                 true, ios, err, ex);
592             assert(iter.base() == v.data() + v.size());
593             assert(err == std::ios_base::eofbit);
594             assert(ex == 123456789);
595         }
596         {   // negative
597             std::wstring v = L"-1,234,567.89";
598             typedef input_iterator<const wchar_t*> I;
599             long double ex;
600             std::ios_base::iostate err = std::ios_base::goodbit;
601             I iter = f.get(I(v.data()), I(v.data() + v.size()),
602                                                 true, ios, err, ex);
603             assert(iter.base() == v.data() + v.size());
604             assert(err == std::ios_base::eofbit);
605             assert(ex == -123456789);
606         }
607         {   // negative
608             std::wstring v = L"-1234567.89";
609             typedef input_iterator<const wchar_t*> I;
610             long double ex;
611             std::ios_base::iostate err = std::ios_base::goodbit;
612             I iter = f.get(I(v.data()), I(v.data() + v.size()),
613                                                 true, ios, err, ex);
614             assert(iter.base() == v.data() + v.size());
615             assert(err == std::ios_base::eofbit);
616             assert(ex == -123456789);
617         }
618         {   // zero, showbase
619             std::wstring v = L"CNY 0.00";
620             typedef input_iterator<const wchar_t*> I;
621             long double ex;
622             std::ios_base::iostate err = std::ios_base::goodbit;
623             I iter = f.get(I(v.data()), I(v.data() + v.size()),
624                                                 true, ios, err, ex);
625             assert(iter.base() == v.data() + v.size());
626             assert(err == std::ios_base::eofbit);
627             assert(ex == 0);
628         }
629         {   // zero, showbase
630             std::wstring v = L"CNY 0.00";
631             showbase(ios);
632             typedef input_iterator<const wchar_t*> I;
633             long double ex;
634             std::ios_base::iostate err = std::ios_base::goodbit;
635             I iter = f.get(I(v.data()), I(v.data() + v.size()),
636                                                 true, ios, err, ex);
637             assert(iter.base() == v.data() + v.size());
638             assert(err == std::ios_base::eofbit);
639             assert(ex == 0);
640             noshowbase(ios);
641         }
642         {   // negative one, showbase
643             std::wstring v = L"CNY -0.01";
644             typedef input_iterator<const wchar_t*> I;
645             long double ex;
646             std::ios_base::iostate err = std::ios_base::goodbit;
647             I iter = f.get(I(v.data()), I(v.data() + v.size()),
648                                                 true, ios, err, ex);
649             assert(iter.base() == v.data() + v.size());
650             assert(err == std::ios_base::eofbit);
651             assert(ex == -1);
652         }
653         {   // negative one, showbase
654             std::wstring v = L"CNY -0.01";
655             showbase(ios);
656             typedef input_iterator<const wchar_t*> I;
657             long double ex;
658             std::ios_base::iostate err = std::ios_base::goodbit;
659             I iter = f.get(I(v.data()), I(v.data() + v.size()),
660                                                 true, ios, err, ex);
661             assert(iter.base() == v.data() + v.size());
662             assert(err == std::ios_base::eofbit);
663             assert(ex == -1);
664             noshowbase(ios);
665         }
666         {   // positive, showbase
667             std::wstring v = L"CNY 1,234,567.89";
668             typedef input_iterator<const wchar_t*> I;
669             long double ex;
670             std::ios_base::iostate err = std::ios_base::goodbit;
671             I iter = f.get(I(v.data()), I(v.data() + v.size()),
672                                                 true, ios, err, ex);
673             assert(iter.base() == v.data() + v.size());
674             assert(err == std::ios_base::eofbit);
675             assert(ex == 123456789);
676         }
677         {   // positive, showbase
678             std::wstring v = L"CNY 1,234,567.89";
679             showbase(ios);
680             typedef input_iterator<const wchar_t*> I;
681             long double ex;
682             std::ios_base::iostate err = std::ios_base::goodbit;
683             I iter = f.get(I(v.data()), I(v.data() + v.size()),
684                                                 true, ios, err, ex);
685             assert(iter.base() == v.data() + v.size());
686             assert(err == std::ios_base::eofbit);
687             assert(ex == 123456789);
688             noshowbase(ios);
689         }
690         {   // negative, showbase
691             std::wstring v = L"CNY -1,234,567.89";
692             showbase(ios);
693             typedef input_iterator<const wchar_t*> I;
694             long double ex;
695             std::ios_base::iostate err = std::ios_base::goodbit;
696             I iter = f.get(I(v.data()), I(v.data() + v.size()),
697                                                 true, ios, err, ex);
698             assert(iter.base() == v.data() + v.size());
699             assert(err == std::ios_base::eofbit);
700             assert(ex == -123456789);
701             noshowbase(ios);
702         }
703         {   // negative, showbase
704             std::wstring v = L"\xFFE5""-1,234,567.89";
705             showbase(ios);
706             typedef input_iterator<const wchar_t*> I;
707             long double ex;
708             std::ios_base::iostate err = std::ios_base::goodbit;
709             I iter = f.get(I(v.data()), I(v.data() + v.size()),
710                                                 true, ios, err, ex);
711             assert(iter.base() == v.data() + 0);
712             assert(err == std::ios_base::failbit);
713             noshowbase(ios);
714         }
715         {   // negative, showbase
716             std::wstring v = L"\xFFE5""-1,234,567.89";
717             typedef input_iterator<const wchar_t*> I;
718             long double ex;
719             std::ios_base::iostate err = std::ios_base::goodbit;
720             I iter = f.get(I(v.data()), I(v.data() + v.size()),
721                                                 true, ios, err, ex);
722             assert(iter.base() == v.data() + 0);
723             assert(err == std::ios_base::failbit);
724         }
725     }
726 }
727