1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This test is passing in an uncontrolled manner in some Apple environment.
10 // UNSUPPORTED: apple-darwin
11 //
12 // NetBSD does not support LC_MONETARY at the moment
13 // XFAIL: netbsd
14 
15 // Failure related to GLIBC's use of U00A0 as mon_thousands_sep
16 // and U002E as mon_decimal_point.
17 // TODO: U00A0 should be investigated.
18 // Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
19 // XFAIL: linux
20 
21 // REQUIRES: locale.ru_RU.UTF-8
22 
23 // <locale>
24 
25 // class money_get<charT, InputIterator>
26 
27 // iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
28 //               ios_base::iostate& err, long double& v) const;
29 
30 #include <locale>
31 #include <ios>
32 #include <streambuf>
33 #include <cassert>
34 #include "test_macros.h"
35 #include "test_iterators.h"
36 
37 #include "platform_support.h" // locale name macros
38 
39 typedef std::money_get<char, input_iterator<const char*> > Fn;
40 
41 class my_facet
42     : public Fn
43 {
44 public:
my_facet(std::size_t refs=0)45     explicit my_facet(std::size_t refs = 0)
46         : Fn(refs) {}
47 };
48 
49 typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
50 
51 class my_facetw
52     : public Fw
53 {
54 public:
my_facetw(std::size_t refs=0)55     explicit my_facetw(std::size_t refs = 0)
56         : Fw(refs) {}
57 };
58 
main(int,char **)59 int main(int, char**)
60 {
61     std::ios ios(0);
62     std::string loc_name(LOCALE_ru_RU_UTF_8);
63     ios.imbue(std::locale(ios.getloc(),
64                           new std::moneypunct_byname<char, false>(loc_name)));
65     ios.imbue(std::locale(ios.getloc(),
66                           new std::moneypunct_byname<char, true>(loc_name)));
67     ios.imbue(std::locale(ios.getloc(),
68                           new std::moneypunct_byname<wchar_t, false>(loc_name)));
69     ios.imbue(std::locale(ios.getloc(),
70                           new std::moneypunct_byname<wchar_t, true>(loc_name)));
71     {
72         const my_facet f(1);
73         // char, national
74         {   // zero
75             std::string v = "0,00 ";
76             typedef input_iterator<const char*> I;
77             long double ex;
78             std::ios_base::iostate err = std::ios_base::goodbit;
79             I iter = f.get(I(v.data()), I(v.data() + v.size()),
80                                                 false, ios, err, ex);
81             assert(iter.base() == v.data() + v.size());
82             assert(err == std::ios_base::eofbit);
83             assert(ex == 0);
84         }
85         {   // negative one
86             std::string v = "-0,01 ";
87             typedef input_iterator<const char*> I;
88             long double ex;
89             std::ios_base::iostate err = std::ios_base::goodbit;
90             I iter = f.get(I(v.data()), I(v.data() + v.size()),
91                                                 false, ios, err, ex);
92             assert(iter.base() == v.data() + v.size());
93             assert(err == std::ios_base::eofbit);
94             assert(ex == -1);
95         }
96         {   // positive
97             std::string v = "1 234 567,89 ";
98             typedef input_iterator<const char*> I;
99             long double ex;
100             std::ios_base::iostate err = std::ios_base::goodbit;
101             I iter = f.get(I(v.data()), I(v.data() + v.size()),
102                                                 false, ios, err, ex);
103             assert(iter.base() == v.data() + v.size());
104             assert(err == std::ios_base::eofbit);
105             assert(ex == 123456789);
106         }
107         {   // negative
108             std::string v = "-1 234 567,89 ";
109             typedef input_iterator<const char*> I;
110             long double ex;
111             std::ios_base::iostate err = std::ios_base::goodbit;
112             I iter = f.get(I(v.data()), I(v.data() + v.size()),
113                                                 false, ios, err, ex);
114             assert(iter.base() == v.data() + v.size());
115             assert(err == std::ios_base::eofbit);
116             assert(ex == -123456789);
117         }
118         {   // negative
119             std::string v = "-1234567,89 ";
120             typedef input_iterator<const char*> I;
121             long double ex;
122             std::ios_base::iostate err = std::ios_base::goodbit;
123             I iter = f.get(I(v.data()), I(v.data() + v.size()),
124                                                 false, ios, err, ex);
125             assert(iter.base() == v.data() + v.size());
126             assert(err == std::ios_base::eofbit);
127             assert(ex == -123456789);
128         }
129         {   // zero, showbase
130             std::string v = "0,00 \xD1\x80\xD1\x83\xD0\xB1"".";
131             typedef input_iterator<const char*> I;
132             long double ex;
133             std::ios_base::iostate err = std::ios_base::goodbit;
134             I iter = f.get(I(v.data()), I(v.data() + v.size()),
135                                                 false, ios, err, ex);
136             assert(iter.base() == v.data() + 5);
137             assert(err == std::ios_base::goodbit);
138             assert(ex == 0);
139         }
140         {   // zero, showbase
141             std::string v = "0,00 \xD1\x80\xD1\x83\xD0\xB1"".";
142             showbase(ios);
143             typedef input_iterator<const char*> I;
144             long double ex;
145             std::ios_base::iostate err = std::ios_base::goodbit;
146             I iter = f.get(I(v.data()), I(v.data() + v.size()),
147                                                 false, ios, err, ex);
148             assert(iter.base() == v.data() + v.size());
149             assert(err == std::ios_base::eofbit);
150             assert(ex == 0);
151             noshowbase(ios);
152         }
153         {   // negative one, showbase
154             std::string v = "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".";
155             typedef input_iterator<const char*> I;
156             long double ex;
157             std::ios_base::iostate err = std::ios_base::goodbit;
158             I iter = f.get(I(v.data()), I(v.data() + v.size()),
159                                                 false, ios, err, ex);
160             assert(iter.base() == v.data() + 6);
161             assert(err == std::ios_base::goodbit);
162             assert(ex == -1);
163         }
164         {   // negative one, showbase
165             std::string v = "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".";
166             showbase(ios);
167             typedef input_iterator<const char*> I;
168             long double ex;
169             std::ios_base::iostate err = std::ios_base::goodbit;
170             I iter = f.get(I(v.data()), I(v.data() + v.size()),
171                                                 false, ios, err, ex);
172             assert(iter.base() == v.data() + v.size());
173             assert(err == std::ios_base::eofbit);
174             assert(ex == -1);
175             noshowbase(ios);
176         }
177         {   // positive, showbase
178             std::string v = "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
179             typedef input_iterator<const char*> I;
180             long double ex;
181             std::ios_base::iostate err = std::ios_base::goodbit;
182             I iter = f.get(I(v.data()), I(v.data() + v.size()),
183                                                 false, ios, err, ex);
184             assert(iter.base() == v.data() + 13);
185             assert(err == std::ios_base::goodbit);
186             assert(ex == 123456789);
187         }
188         {   // positive, showbase
189             std::string v = "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
190             showbase(ios);
191             typedef input_iterator<const char*> I;
192             long double ex;
193             std::ios_base::iostate err = std::ios_base::goodbit;
194             I iter = f.get(I(v.data()), I(v.data() + v.size()),
195                                                 false, ios, err, ex);
196             assert(iter.base() == v.data() + v.size());
197             assert(err == std::ios_base::eofbit);
198             assert(ex == 123456789);
199             noshowbase(ios);
200         }
201         {   // negative, showbase
202             std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
203             showbase(ios);
204             typedef input_iterator<const char*> I;
205             long double ex;
206             std::ios_base::iostate err = std::ios_base::goodbit;
207             I iter = f.get(I(v.data()), I(v.data() + v.size()),
208                                                 false, ios, err, ex);
209             assert(iter.base() == v.data() + v.size());
210             assert(err == std::ios_base::eofbit);
211             assert(ex == -123456789);
212             noshowbase(ios);
213         }
214         {   // negative, showbase
215             std::string v = "-1 234 567,89 RUB ";
216             showbase(ios);
217             typedef input_iterator<const char*> I;
218             long double ex;
219             std::ios_base::iostate err = std::ios_base::goodbit;
220             I iter = f.get(I(v.data()), I(v.data() + v.size()),
221                                                 false, ios, err, ex);
222             assert(iter.base() == v.data() + 14);
223             assert(err == std::ios_base::failbit);
224             noshowbase(ios);
225         }
226         {   // negative, showbase
227             std::string v = "-1 234 567,89 RUB ";
228             typedef input_iterator<const char*> I;
229             long double ex;
230             std::ios_base::iostate err = std::ios_base::goodbit;
231             I iter = f.get(I(v.data()), I(v.data() + v.size()),
232                                                 false, ios, err, ex);
233             assert(iter.base() == v.data() + 14);
234             assert(err == std::ios_base::goodbit);
235             assert(ex == -123456789);
236         }
237     }
238     {
239         const my_facet f(1);
240         // char, international
241         {   // zero
242             std::string v = "0,00";
243             typedef input_iterator<const char*> I;
244             long double ex;
245             std::ios_base::iostate err = std::ios_base::goodbit;
246             I iter = f.get(I(v.data()), I(v.data() + v.size()),
247                                                 true, ios, err, ex);
248             assert(iter.base() == v.data() + v.size());
249             assert(err == std::ios_base::eofbit);
250             assert(ex == 0);
251         }
252         {   // negative one
253             std::string v = "-0,01 ";
254             typedef input_iterator<const char*> I;
255             long double ex;
256             std::ios_base::iostate err = std::ios_base::goodbit;
257             I iter = f.get(I(v.data()), I(v.data() + v.size()),
258                                                 true, ios, err, ex);
259             assert(iter.base() == v.data() + v.size());
260             assert(err == std::ios_base::eofbit);
261             assert(ex == -1);
262         }
263         {   // positive
264             std::string v = "1 234 567,89 ";
265             typedef input_iterator<const char*> I;
266             long double ex;
267             std::ios_base::iostate err = std::ios_base::goodbit;
268             I iter = f.get(I(v.data()), I(v.data() + v.size()),
269                                                 true, ios, err, ex);
270             assert(iter.base() == v.data() + v.size());
271             assert(err == std::ios_base::eofbit);
272             assert(ex == 123456789);
273         }
274         {   // negative
275             std::string v = "-1 234 567,89 ";
276             typedef input_iterator<const char*> I;
277             long double ex;
278             std::ios_base::iostate err = std::ios_base::goodbit;
279             I iter = f.get(I(v.data()), I(v.data() + v.size()),
280                                                 true, ios, err, ex);
281             assert(iter.base() == v.data() + v.size());
282             assert(err == std::ios_base::eofbit);
283             assert(ex == -123456789);
284         }
285         {   // negative
286             std::string v = "-1234567,89 ";
287             typedef input_iterator<const char*> I;
288             long double ex;
289             std::ios_base::iostate err = std::ios_base::goodbit;
290             I iter = f.get(I(v.data()), I(v.data() + v.size()),
291                                                 true, ios, err, ex);
292             assert(iter.base() == v.data() + v.size());
293             assert(err == std::ios_base::eofbit);
294             assert(ex == -123456789);
295         }
296         {   // zero, showbase
297             std::string v = "0,00 RUB ";
298             typedef input_iterator<const char*> I;
299             long double ex;
300             std::ios_base::iostate err = std::ios_base::goodbit;
301             I iter = f.get(I(v.data()), I(v.data() + v.size()),
302                                                 true, ios, err, ex);
303             assert(iter.base() == v.data() + 5);
304             assert(err == std::ios_base::goodbit);
305             assert(ex == 0);
306         }
307         {   // zero, showbase
308             std::string v = "0,00 RUB ";
309             showbase(ios);
310             typedef input_iterator<const char*> I;
311             long double ex;
312             std::ios_base::iostate err = std::ios_base::goodbit;
313             I iter = f.get(I(v.data()), I(v.data() + v.size()),
314                                                 true, ios, err, ex);
315             assert(iter.base() == v.data() + v.size());
316             assert(err == std::ios_base::eofbit);
317             assert(ex == 0);
318             noshowbase(ios);
319         }
320         {   // negative one, showbase
321             std::string v = "-0,01 RUB ";
322             typedef input_iterator<const char*> I;
323             long double ex;
324             std::ios_base::iostate err = std::ios_base::goodbit;
325             I iter = f.get(I(v.data()), I(v.data() + v.size()),
326                                                 true, ios, err, ex);
327             assert(iter.base() == v.data() + 6);
328             assert(err == std::ios_base::goodbit);
329             assert(ex == -1);
330         }
331         {   // negative one, showbase
332             std::string v = "-0,01 RUB ";
333             showbase(ios);
334             typedef input_iterator<const char*> I;
335             long double ex;
336             std::ios_base::iostate err = std::ios_base::goodbit;
337             I iter = f.get(I(v.data()), I(v.data() + v.size()),
338                                                 true, ios, err, ex);
339             assert(iter.base() == v.data() + v.size());
340             assert(err == std::ios_base::eofbit);
341             assert(ex == -1);
342             noshowbase(ios);
343         }
344         {   // positive, showbase
345             std::string v = "1 234 567,89 RUB ";
346             typedef input_iterator<const char*> I;
347             long double ex;
348             std::ios_base::iostate err = std::ios_base::goodbit;
349             I iter = f.get(I(v.data()), I(v.data() + v.size()),
350                                                 true, ios, err, ex);
351             assert(iter.base() == v.data() + 13);
352             assert(err == std::ios_base::goodbit);
353             assert(ex == 123456789);
354         }
355         {   // positive, showbase
356             std::string v = "1 234 567,89 RUB ";
357             showbase(ios);
358             typedef input_iterator<const char*> I;
359             long double 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 RUB ";
370             showbase(ios);
371             typedef input_iterator<const char*> I;
372             long double 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() + v.size());
377             assert(err == std::ios_base::eofbit);
378             assert(ex == -123456789);
379             noshowbase(ios);
380         }
381         {   // negative, showbase
382             std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
383             showbase(ios);
384             typedef input_iterator<const char*> I;
385             long double ex;
386             std::ios_base::iostate err = std::ios_base::goodbit;
387             I iter = f.get(I(v.data()), I(v.data() + v.size()),
388                                                 true, ios, err, ex);
389             assert(iter.base() == v.data() + 14);
390             assert(err == std::ios_base::failbit);
391             noshowbase(ios);
392         }
393         {   // negative, showbase
394             std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
395             typedef input_iterator<const char*> I;
396             long double ex;
397             std::ios_base::iostate err = std::ios_base::goodbit;
398             I iter = f.get(I(v.data()), I(v.data() + v.size()),
399                                                 true, ios, err, ex);
400             assert(iter.base() == v.data() + 14);
401             assert(err == std::ios_base::goodbit);
402             assert(ex == -123456789);
403         }
404     }
405     {
406         const my_facetw f(1);
407         // wchar_t, national
408         {   // zero
409             std::wstring v = L"0,00";
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 == 0);
418         }
419         {   // negative one
420             std::wstring v = L"-0,01 ";
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 == -1);
429         }
430         {   // positive
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"-1 234 567,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         {   // negative
453             std::wstring v = L"-1234567,89 ";
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 == -123456789);
462         }
463         {   // zero, showbase
464             std::wstring v = L"0,00 \x440\x443\x431"".";
465             typedef input_iterator<const wchar_t*> I;
466             long double 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() + 5);
471             assert(err == std::ios_base::goodbit);
472             assert(ex == 0);
473         }
474         {   // zero, showbase
475             std::wstring v = L"0,00 \x440\x443\x431"".";
476             showbase(ios);
477             typedef input_iterator<const wchar_t*> I;
478             long double 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 == 0);
485             noshowbase(ios);
486         }
487         {   // negative one, showbase
488             std::wstring v = L"-0,01 \x440\x443\x431"".";
489             typedef input_iterator<const wchar_t*> I;
490             long double 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() + 6);
495             assert(err == std::ios_base::goodbit);
496             assert(ex == -1);
497         }
498         {   // negative one, showbase
499             std::wstring v = L"-0,01 \x440\x443\x431"".";
500             showbase(ios);
501             typedef input_iterator<const wchar_t*> I;
502             long double 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 == -1);
509             noshowbase(ios);
510         }
511         {   // positive, showbase
512             std::wstring v = L"1 234 567,89 \x440\x443\x431"".";
513             typedef input_iterator<const wchar_t*> I;
514             long double 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() + 13);
519             assert(err == std::ios_base::goodbit);
520             assert(ex == 123456789);
521         }
522         {   // positive, showbase
523             std::wstring v = L"1 234 567,89 \x440\x443\x431"".";
524             showbase(ios);
525             typedef input_iterator<const wchar_t*> I;
526             long double ex;
527             std::ios_base::iostate err = std::ios_base::goodbit;
528             I iter = f.get(I(v.data()), I(v.data() + v.size()),
529                                                 false, ios, err, ex);
530             assert(iter.base() == v.data() + v.size());
531             assert(err == std::ios_base::eofbit);
532             assert(ex == 123456789);
533             noshowbase(ios);
534         }
535         {   // negative, showbase
536             std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
537             showbase(ios);
538             typedef input_iterator<const wchar_t*> I;
539             long double ex;
540             std::ios_base::iostate err = std::ios_base::goodbit;
541             I iter = f.get(I(v.data()), I(v.data() + v.size()),
542                                                 false, ios, err, ex);
543             assert(iter.base() == v.data() + v.size());
544             assert(err == std::ios_base::eofbit);
545             assert(ex == -123456789);
546             noshowbase(ios);
547         }
548         {   // negative, showbase
549             std::wstring v = L"-1 234 567,89 RUB ";
550             showbase(ios);
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() + 14);
557             assert(err == std::ios_base::failbit);
558             noshowbase(ios);
559         }
560         {   // negative, showbase
561             std::wstring v = L"-1 234 567,89 RUB ";
562             typedef input_iterator<const wchar_t*> I;
563             long double ex;
564             std::ios_base::iostate err = std::ios_base::goodbit;
565             I iter = f.get(I(v.data()), I(v.data() + v.size()),
566                                                 false, ios, err, ex);
567             assert(iter.base() == v.data() + 14);
568             assert(err == std::ios_base::goodbit);
569             assert(ex == -123456789);
570         }
571     }
572     {
573         const my_facetw f(1);
574         // wchar_t, international
575         {   // zero
576             std::wstring v = L"0,00";
577             typedef input_iterator<const wchar_t*> I;
578             long double 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 == 0);
585         }
586         {   // negative one
587             std::wstring v = L"-0,01 ";
588             typedef input_iterator<const wchar_t*> I;
589             long double 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 == -1);
596         }
597         {   // positive
598             std::wstring v = L"1 234 567,89 ";
599             typedef input_iterator<const wchar_t*> I;
600             long double 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 == 123456789);
607         }
608         {   // negative
609             std::wstring v = L"-1 234 567,89 ";
610             typedef input_iterator<const wchar_t*> I;
611             long double 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 == -123456789);
618         }
619         {   // negative
620             std::wstring v = L"-1234567,89 ";
621             typedef input_iterator<const wchar_t*> I;
622             long double 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 == -123456789);
629         }
630         {   // zero, showbase
631             std::wstring v = L"0,00 RUB ";
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() + 5);
638             assert(err == std::ios_base::goodbit);
639             assert(ex == 0);
640         }
641         {   // zero, showbase
642             std::wstring v = L"0,00 RUB ";
643             showbase(ios);
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 == 0);
652             noshowbase(ios);
653         }
654         {   // negative one, showbase
655             std::wstring v = L"-0,01 RUB ";
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() + 6);
662             assert(err == std::ios_base::goodbit);
663             assert(ex == -1);
664         }
665         {   // negative one, showbase
666             std::wstring v = L"-0,01 RUB ";
667             showbase(ios);
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 == -1);
676             noshowbase(ios);
677         }
678         {   // positive, showbase
679             std::wstring v = L"1 234 567,89 RUB ";
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() + 13);
686             assert(err == std::ios_base::goodbit);
687             assert(ex == 123456789);
688         }
689         {   // positive, showbase
690             std::wstring v = L"1 234 567,89 RUB ";
691             showbase(ios);
692             typedef input_iterator<const wchar_t*> I;
693             long double ex;
694             std::ios_base::iostate err = std::ios_base::goodbit;
695             I iter = f.get(I(v.data()), I(v.data() + v.size()),
696                                                 true, ios, err, ex);
697             assert(iter.base() == v.data() + v.size());
698             assert(err == std::ios_base::eofbit);
699             assert(ex == 123456789);
700             noshowbase(ios);
701         }
702         {   // negative, showbase
703             std::wstring v = L"-1 234 567,89 RUB ";
704             showbase(ios);
705             typedef input_iterator<const wchar_t*> I;
706             long double ex;
707             std::ios_base::iostate err = std::ios_base::goodbit;
708             I iter = f.get(I(v.data()), I(v.data() + v.size()),
709                                                 true, ios, err, ex);
710             assert(iter.base() == v.data() + v.size());
711             assert(err == std::ios_base::eofbit);
712             assert(ex == -123456789);
713             noshowbase(ios);
714         }
715         {   // negative, showbase
716             std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
717             showbase(ios);
718             typedef input_iterator<const wchar_t*> I;
719             long double ex;
720             std::ios_base::iostate err = std::ios_base::goodbit;
721             I iter = f.get(I(v.data()), I(v.data() + v.size()),
722                                                 true, ios, err, ex);
723             assert(iter.base() == v.data() + 14);
724             assert(err == std::ios_base::failbit);
725             noshowbase(ios);
726         }
727         {   // negative, showbase
728             std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
729             typedef input_iterator<const wchar_t*> I;
730             long double ex;
731             std::ios_base::iostate err = std::ios_base::goodbit;
732             I iter = f.get(I(v.data()), I(v.data() + v.size()),
733                                                 true, ios, err, ex);
734             assert(iter.base() == v.data() + 14);
735             assert(err == std::ios_base::goodbit);
736             assert(ex == -123456789);
737         }
738     }
739 
740   return 0;
741 }
742