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