1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // XFAIL: apple-darwin
11
12 // <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 #include <locale>
20 #include <ios>
21 #include <streambuf>
22 #include <cassert>
23 #include "test_iterators.h"
24
25 #include "platform_support.h" // locale name macros
26
27 typedef std::money_get<char, input_iterator<const char*> > Fn;
28
29 class my_facet
30 : public Fn
31 {
32 public:
my_facet(std::size_t refs=0)33 explicit my_facet(std::size_t refs = 0)
34 : Fn(refs) {}
35 };
36
37 typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
38
39 class my_facetw
40 : public Fw
41 {
42 public:
my_facetw(std::size_t refs=0)43 explicit my_facetw(std::size_t refs = 0)
44 : Fw(refs) {}
45 };
46
main()47 int main()
48 {
49 std::ios ios(0);
50 std::string loc_name(LOCALE_fr_FR_UTF_8);
51 ios.imbue(std::locale(ios.getloc(),
52 new std::moneypunct_byname<char, false>(loc_name)));
53 ios.imbue(std::locale(ios.getloc(),
54 new std::moneypunct_byname<char, true>(loc_name)));
55 ios.imbue(std::locale(ios.getloc(),
56 new std::moneypunct_byname<wchar_t, false>(loc_name)));
57 ios.imbue(std::locale(ios.getloc(),
58 new std::moneypunct_byname<wchar_t, true>(loc_name)));
59 {
60 const my_facet f(1);
61 // char, national
62 { // zero
63 std::string v = "0,00";
64 typedef input_iterator<const char*> I;
65 long double ex;
66 std::ios_base::iostate err = std::ios_base::goodbit;
67 I iter = f.get(I(v.data()), I(v.data() + v.size()),
68 false, ios, err, ex);
69 assert(iter.base() == v.data() + v.size());
70 assert(err == std::ios_base::eofbit);
71 assert(ex == 0);
72 }
73 { // negative one
74 std::string v = "-0,01";
75 typedef input_iterator<const char*> I;
76 long double ex;
77 std::ios_base::iostate err = std::ios_base::goodbit;
78 I iter = f.get(I(v.data()), I(v.data() + v.size()),
79 false, ios, err, ex);
80 assert(iter.base() == v.data() + v.size());
81 assert(err == std::ios_base::eofbit);
82 assert(ex == -1);
83 }
84 { // positive
85 std::string v = "1 234 567,89 ";
86 typedef input_iterator<const char*> I;
87 long double ex;
88 std::ios_base::iostate err = std::ios_base::goodbit;
89 I iter = f.get(I(v.data()), I(v.data() + v.size()),
90 false, ios, err, ex);
91 assert(iter.base() == v.data() + v.size());
92 assert(err == std::ios_base::eofbit);
93 assert(ex == 123456789);
94 }
95 { // negative
96 std::string v = "-1 234 567,89";
97 typedef input_iterator<const char*> I;
98 long double ex;
99 std::ios_base::iostate err = std::ios_base::goodbit;
100 I iter = f.get(I(v.data()), I(v.data() + v.size()),
101 false, ios, err, ex);
102 assert(iter.base() == v.data() + v.size());
103 assert(err == std::ios_base::eofbit);
104 assert(ex == -123456789);
105 }
106 { // negative
107 std::string v = "-1234567,89";
108 typedef input_iterator<const char*> I;
109 long double ex;
110 std::ios_base::iostate err = std::ios_base::goodbit;
111 I iter = f.get(I(v.data()), I(v.data() + v.size()),
112 false, ios, err, ex);
113 assert(iter.base() == v.data() + v.size());
114 assert(err == std::ios_base::eofbit);
115 assert(ex == -123456789);
116 }
117 { // zero, showbase
118 std::string v = "0,00 \u20ac"; // €
119 showbase(ios);
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 == 0);
128 }
129 { // zero, showbase
130 std::string v = "0,00 \u20ac"; // €
131 showbase(ios);
132 typedef input_iterator<const char*> I;
133 long double ex;
134 std::ios_base::iostate err = std::ios_base::goodbit;
135 I iter = f.get(I(v.data()), I(v.data() + v.size()),
136 false, ios, err, ex);
137 assert(iter.base() == v.data() + v.size());
138 assert(err == std::ios_base::eofbit);
139 assert(ex == 0);
140 }
141 { // negative one, showbase
142 std::string v = "-0,01 \u20ac";
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 == -1);
151 }
152 { // negative one, showbase
153 std::string v = "-0,01 \u20ac";
154 showbase(ios);
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() + v.size());
161 assert(err == std::ios_base::eofbit);
162 assert(ex == -1);
163 }
164 { // positive, showbase
165 std::string v = "1 234 567,89 \u20ac";
166 typedef input_iterator<const char*> I;
167 long double ex;
168 std::ios_base::iostate err = std::ios_base::goodbit;
169 I iter = f.get(I(v.data()), I(v.data() + v.size()),
170 false, ios, err, ex);
171 assert(iter.base() == v.data() + v.size());
172 assert(err == std::ios_base::eofbit);
173 assert(ex == 123456789);
174 }
175 { // positive, showbase
176 std::string v = "1 234 567,89 \u20ac";
177 showbase(ios);
178 typedef input_iterator<const char*> I;
179 long double ex;
180 std::ios_base::iostate err = std::ios_base::goodbit;
181 I iter = f.get(I(v.data()), I(v.data() + v.size()),
182 false, ios, err, ex);
183 assert(iter.base() == v.data() + v.size());
184 assert(err == std::ios_base::eofbit);
185 assert(ex == 123456789);
186 noshowbase(ios);
187 }
188 { // negative, showbase
189 std::string v = "-1 234 567,89 \u20ac";
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 EUR -";
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() + 13);
210 assert(err == std::ios_base::failbit);
211 noshowbase(ios);
212 }
213 { // negative, showbase
214 std::string v = "1 234 567,89 EUR -";
215 typedef input_iterator<const char*> I;
216 long double 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() + 13);
221 assert(err == std::ios_base::goodbit);
222 assert(ex == 123456789);
223 }
224 noshowbase(ios);
225 }
226 {
227 const my_facet f(1);
228 // char, international
229 { // zero
230 std::string v = "0,00";
231 typedef input_iterator<const char*> I;
232 long double ex;
233 std::ios_base::iostate err = std::ios_base::goodbit;
234 I iter = f.get(I(v.data()), I(v.data() + v.size()),
235 true, ios, err, ex);
236 assert(iter.base() == v.data() + v.size());
237 assert(err == std::ios_base::eofbit);
238 assert(ex == 0);
239 }
240 { // negative one
241 std::string v = "-0,01";
242 typedef input_iterator<const char*> I;
243 long double ex;
244 std::ios_base::iostate err = std::ios_base::goodbit;
245 I iter = f.get(I(v.data()), I(v.data() + v.size()),
246 true, ios, err, ex);
247 assert(iter.base() == v.data() + v.size());
248 assert(err == std::ios_base::eofbit);
249 assert(ex == -1);
250 }
251 { // positive
252 std::string v = "1 234 567,89 ";
253 typedef input_iterator<const char*> I;
254 long double ex;
255 std::ios_base::iostate err = std::ios_base::goodbit;
256 I iter = f.get(I(v.data()), I(v.data() + v.size()),
257 true, ios, err, ex);
258 assert(iter.base() == v.data() + v.size());
259 assert(err == std::ios_base::eofbit);
260 assert(ex == 123456789);
261 }
262 { // negative
263 std::string v = "-1 234 567,89";
264 typedef input_iterator<const char*> I;
265 long double ex;
266 std::ios_base::iostate err = std::ios_base::goodbit;
267 I iter = f.get(I(v.data()), I(v.data() + v.size()),
268 true, ios, err, ex);
269 assert(iter.base() == v.data() + v.size());
270 assert(err == std::ios_base::eofbit);
271 assert(ex == -123456789);
272 }
273 { // negative
274 std::string v = "-1234567,89";
275 typedef input_iterator<const char*> I;
276 long double ex;
277 std::ios_base::iostate err = std::ios_base::goodbit;
278 I iter = f.get(I(v.data()), I(v.data() + v.size()),
279 true, ios, err, ex);
280 assert(iter.base() == v.data() + v.size());
281 assert(err == std::ios_base::eofbit);
282 assert(ex == -123456789);
283 }
284 { // zero, showbase
285 std::string v = "0,00 EUR";
286 showbase(ios);
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 == 0);
295 }
296 { // zero, showbase
297 std::string v = "0,00 EUR";
298 showbase(ios);
299 typedef input_iterator<const char*> I;
300 long double ex;
301 std::ios_base::iostate err = std::ios_base::goodbit;
302 I iter = f.get(I(v.data()), I(v.data() + v.size()),
303 true, ios, err, ex);
304 assert(iter.base() == v.data() + v.size());
305 assert(err == std::ios_base::eofbit);
306 assert(ex == 0);
307 }
308 { // negative one, showbase
309 std::string v = "-0,01 EUR";
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 == -1);
318 }
319 { // negative one, showbase
320 std::string v = "-0,01 EUR";
321 showbase(ios);
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() + v.size());
328 assert(err == std::ios_base::eofbit);
329 assert(ex == -1);
330 }
331 { // positive, showbase
332 std::string v = "1 234 567,89 EUR";
333 typedef input_iterator<const char*> I;
334 long double 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 = "1 234 567,89 EUR";
344 showbase(ios);
345 typedef input_iterator<const char*> I;
346 long double 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 = "-1 234 567,89 EUR";
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 Eu-";
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() + 14);
377 assert(err == std::ios_base::failbit);
378 noshowbase(ios);
379 }
380 { // negative, showbase
381 std::string v = "1 234 567,89 Eu-";
382 typedef input_iterator<const char*> I;
383 long double ex;
384 std::ios_base::iostate err = std::ios_base::goodbit;
385 I iter = f.get(I(v.data()), I(v.data() + v.size()),
386 true, ios, err, ex);
387 assert(iter.base() == v.data() + 13);
388 assert(err == std::ios_base::goodbit);
389 assert(ex == 123456789);
390 }
391 }
392 {
393 const my_facetw f(1);
394 // wchar_t, national
395 { // zero
396 std::wstring v = L"0,00";
397 typedef input_iterator<const wchar_t*> I;
398 long double ex;
399 std::ios_base::iostate err = std::ios_base::goodbit;
400 I iter = f.get(I(v.data()), I(v.data() + v.size()),
401 false, ios, err, ex);
402 assert(iter.base() == v.data() + v.size());
403 assert(err == std::ios_base::eofbit);
404 assert(ex == 0);
405 }
406 { // negative one
407 std::wstring v = L"-0,01";
408 typedef input_iterator<const wchar_t*> I;
409 long double ex;
410 std::ios_base::iostate err = std::ios_base::goodbit;
411 I iter = f.get(I(v.data()), I(v.data() + v.size()),
412 false, ios, err, ex);
413 assert(iter.base() == v.data() + v.size());
414 assert(err == std::ios_base::eofbit);
415 assert(ex == -1);
416 }
417 { // positive
418 std::wstring v = L"1 234 567,89 ";
419 typedef input_iterator<const wchar_t*> I;
420 long double ex;
421 std::ios_base::iostate err = std::ios_base::goodbit;
422 I iter = f.get(I(v.data()), I(v.data() + v.size()),
423 false, ios, err, ex);
424 assert(iter.base() == v.data() + v.size());
425 assert(err == std::ios_base::eofbit);
426 assert(ex == 123456789);
427 }
428 { // negative
429 std::wstring v = L"-1 234 567,89";
430 typedef input_iterator<const wchar_t*> I;
431 long double ex;
432 std::ios_base::iostate err = std::ios_base::goodbit;
433 I iter = f.get(I(v.data()), I(v.data() + v.size()),
434 false, ios, err, ex);
435 assert(iter.base() == v.data() + v.size());
436 assert(err == std::ios_base::eofbit);
437 assert(ex == -123456789);
438 }
439 { // negative
440 std::wstring v = L"-1234567,89";
441 typedef input_iterator<const wchar_t*> I;
442 long double ex;
443 std::ios_base::iostate err = std::ios_base::goodbit;
444 I iter = f.get(I(v.data()), I(v.data() + v.size()),
445 false, ios, err, ex);
446 assert(iter.base() == v.data() + v.size());
447 assert(err == std::ios_base::eofbit);
448 assert(ex == -123456789);
449 }
450 { // zero, showbase
451 std::wstring v = L"0,00 \u20ac";
452 showbase(ios);
453 typedef input_iterator<const wchar_t*> I;
454 long double 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 == 0);
461 }
462 { // zero, showbase
463 std::wstring v = L"0,00 \u20ac";
464 showbase(ios);
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() + v.size());
471 assert(err == std::ios_base::eofbit);
472 assert(ex == 0);
473 }
474 { // negative one, showbase
475 std::wstring v = L"-0,01 \u20ac";
476 typedef input_iterator<const wchar_t*> I;
477 long double ex;
478 std::ios_base::iostate err = std::ios_base::goodbit;
479 I iter = f.get(I(v.data()), I(v.data() + v.size()),
480 false, ios, err, ex);
481 assert(iter.base() == v.data() + v.size());
482 assert(err == std::ios_base::eofbit);
483 assert(ex == -1);
484 }
485 { // negative one, showbase
486 std::wstring v = L"-0,01 \u20ac";
487 showbase(ios);
488 typedef input_iterator<const wchar_t*> I;
489 long double ex;
490 std::ios_base::iostate err = std::ios_base::goodbit;
491 I iter = f.get(I(v.data()), I(v.data() + v.size()),
492 false, ios, err, ex);
493 assert(iter.base() == v.data() + v.size());
494 assert(err == std::ios_base::eofbit);
495 assert(ex == -1);
496 }
497 { // positive, showbase
498 std::wstring v = L"1 234 567,89 \u20ac";
499 typedef input_iterator<const wchar_t*> I;
500 long double ex;
501 std::ios_base::iostate err = std::ios_base::goodbit;
502 I iter = f.get(I(v.data()), I(v.data() + v.size()),
503 false, ios, err, ex);
504 assert(iter.base() == v.data() + v.size());
505 assert(err == std::ios_base::eofbit);
506 assert(ex == 123456789);
507 }
508 { // positive, showbase
509 std::wstring v = L"1 234 567,89 \u20ac";
510 showbase(ios);
511 typedef input_iterator<const wchar_t*> I;
512 long double ex;
513 std::ios_base::iostate err = std::ios_base::goodbit;
514 I iter = f.get(I(v.data()), I(v.data() + v.size()),
515 false, ios, err, ex);
516 assert(iter.base() == v.data() + v.size());
517 assert(err == std::ios_base::eofbit);
518 assert(ex == 123456789);
519 noshowbase(ios);
520 }
521 { // negative, showbase
522 std::wstring v = L"-1 234 567,89 \u20ac";
523 showbase(ios);
524 typedef input_iterator<const wchar_t*> I;
525 long double ex;
526 std::ios_base::iostate err = std::ios_base::goodbit;
527 I iter = f.get(I(v.data()), I(v.data() + v.size()),
528 false, ios, err, ex);
529 assert(iter.base() == v.data() + v.size());
530 assert(err == std::ios_base::eofbit);
531 assert(ex == -123456789);
532 noshowbase(ios);
533 }
534 { // negative, showbase
535 std::wstring v = L"1 234 567,89 EUR -";
536 showbase(ios);
537 typedef input_iterator<const wchar_t*> I;
538 long double ex;
539 std::ios_base::iostate err = std::ios_base::goodbit;
540 I iter = f.get(I(v.data()), I(v.data() + v.size()),
541 false, ios, err, ex);
542 assert(iter.base() == v.data() + 13);
543 assert(err == std::ios_base::failbit);
544 noshowbase(ios);
545 }
546 { // negative, showbase
547 std::wstring v = L"1 234 567,89 EUR -";
548 typedef input_iterator<const wchar_t*> I;
549 long double ex;
550 std::ios_base::iostate err = std::ios_base::goodbit;
551 I iter = f.get(I(v.data()), I(v.data() + v.size()),
552 false, ios, err, ex);
553 assert(iter.base() == v.data() + 13);
554 assert(err == std::ios_base::goodbit);
555 assert(ex == 123456789);
556 }
557 }
558 {
559 const my_facetw f(1);
560 // wchar_t, international
561 { // zero
562 std::wstring v = L"0,00";
563 typedef input_iterator<const wchar_t*> I;
564 long double ex;
565 std::ios_base::iostate err = std::ios_base::goodbit;
566 I iter = f.get(I(v.data()), I(v.data() + v.size()),
567 true, ios, err, ex);
568 assert(iter.base() == v.data() + v.size());
569 assert(err == std::ios_base::eofbit);
570 assert(ex == 0);
571 }
572 { // negative one
573 std::wstring v = L"-0,01";
574 typedef input_iterator<const wchar_t*> I;
575 long double ex;
576 std::ios_base::iostate err = std::ios_base::goodbit;
577 I iter = f.get(I(v.data()), I(v.data() + v.size()),
578 true, ios, err, ex);
579 assert(iter.base() == v.data() + v.size());
580 assert(err == std::ios_base::eofbit);
581 assert(ex == -1);
582 }
583 { // positive
584 std::wstring v = L"1 234 567,89 ";
585 typedef input_iterator<const wchar_t*> I;
586 long double ex;
587 std::ios_base::iostate err = std::ios_base::goodbit;
588 I iter = f.get(I(v.data()), I(v.data() + v.size()),
589 true, ios, err, ex);
590 assert(iter.base() == v.data() + v.size());
591 assert(err == std::ios_base::eofbit);
592 assert(ex == 123456789);
593 }
594 { // negative
595 std::wstring v = L"-1 234 567,89";
596 typedef input_iterator<const wchar_t*> I;
597 long double ex;
598 std::ios_base::iostate err = std::ios_base::goodbit;
599 I iter = f.get(I(v.data()), I(v.data() + v.size()),
600 true, ios, err, ex);
601 assert(iter.base() == v.data() + v.size());
602 assert(err == std::ios_base::eofbit);
603 assert(ex == -123456789);
604 }
605 { // negative
606 std::wstring v = L"-1234567,89";
607 typedef input_iterator<const wchar_t*> I;
608 long double ex;
609 std::ios_base::iostate err = std::ios_base::goodbit;
610 I iter = f.get(I(v.data()), I(v.data() + v.size()),
611 true, ios, err, ex);
612 assert(iter.base() == v.data() + v.size());
613 assert(err == std::ios_base::eofbit);
614 assert(ex == -123456789);
615 }
616 { // zero, showbase
617 std::wstring v = L"0,00 EUR";
618 showbase(ios);
619 typedef input_iterator<const wchar_t*> I;
620 long double ex;
621 std::ios_base::iostate err = std::ios_base::goodbit;
622 I iter = f.get(I(v.data()), I(v.data() + v.size()),
623 true, ios, err, ex);
624 assert(iter.base() == v.data() + v.size());
625 assert(err == std::ios_base::eofbit);
626 assert(ex == 0);
627 }
628 { // zero, showbase
629 std::wstring v = L"0,00 EUR";
630 showbase(ios);
631 typedef input_iterator<const wchar_t*> I;
632 long double ex;
633 std::ios_base::iostate err = std::ios_base::goodbit;
634 I iter = f.get(I(v.data()), I(v.data() + v.size()),
635 true, ios, err, ex);
636 assert(iter.base() == v.data() + v.size());
637 assert(err == std::ios_base::eofbit);
638 assert(ex == 0);
639 }
640 { // negative one, showbase
641 std::wstring v = L"-0,01 EUR";
642 typedef input_iterator<const wchar_t*> I;
643 long double ex;
644 std::ios_base::iostate err = std::ios_base::goodbit;
645 I iter = f.get(I(v.data()), I(v.data() + v.size()),
646 true, ios, err, ex);
647 assert(iter.base() == v.data() + v.size());
648 assert(err == std::ios_base::eofbit);
649 assert(ex == -1);
650 }
651 { // negative one, showbase
652 std::wstring v = L"-0,01 EUR";
653 showbase(ios);
654 typedef input_iterator<const wchar_t*> I;
655 long double ex;
656 std::ios_base::iostate err = std::ios_base::goodbit;
657 I iter = f.get(I(v.data()), I(v.data() + v.size()),
658 true, ios, err, ex);
659 assert(iter.base() == v.data() + v.size());
660 assert(err == std::ios_base::eofbit);
661 assert(ex == -1);
662 }
663 { // positive, showbase
664 std::wstring v = L"1 234 567,89 EUR";
665 typedef input_iterator<const wchar_t*> I;
666 long double ex;
667 std::ios_base::iostate err = std::ios_base::goodbit;
668 I iter = f.get(I(v.data()), I(v.data() + v.size()),
669 true, ios, err, ex);
670 assert(iter.base() == v.data() + v.size());
671 assert(err == std::ios_base::eofbit);
672 assert(ex == 123456789);
673 }
674 { // positive, showbase
675 std::wstring v = L"1 234 567,89 EUR";
676 showbase(ios);
677 typedef input_iterator<const wchar_t*> I;
678 long double ex;
679 std::ios_base::iostate err = std::ios_base::goodbit;
680 I iter = f.get(I(v.data()), I(v.data() + v.size()),
681 true, ios, err, ex);
682 assert(iter.base() == v.data() + v.size());
683 assert(err == std::ios_base::eofbit);
684 assert(ex == 123456789);
685 noshowbase(ios);
686 }
687 { // negative, showbase
688 std::wstring v = L"-1 234 567,89 EUR";
689 showbase(ios);
690 typedef input_iterator<const wchar_t*> I;
691 long double ex;
692 std::ios_base::iostate err = std::ios_base::goodbit;
693 I iter = f.get(I(v.data()), I(v.data() + v.size()),
694 true, ios, err, ex);
695 assert(iter.base() == v.data() + v.size());
696 assert(err == std::ios_base::eofbit);
697 assert(ex == -123456789);
698 noshowbase(ios);
699 }
700 { // negative, showbase
701 std::wstring v = L"1 234 567,89 Eu-";
702 showbase(ios);
703 typedef input_iterator<const wchar_t*> I;
704 long double ex;
705 std::ios_base::iostate err = std::ios_base::goodbit;
706 I iter = f.get(I(v.data()), I(v.data() + v.size()),
707 true, ios, err, ex);
708 assert(iter.base() == v.data() + 14);
709 assert(err == std::ios_base::failbit);
710 noshowbase(ios);
711 }
712 { // negative, showbase
713 std::wstring v = L"1 234 567,89 Eu-";
714 typedef input_iterator<const wchar_t*> I;
715 long double ex;
716 std::ios_base::iostate err = std::ios_base::goodbit;
717 I iter = f.get(I(v.data()), I(v.data() + v.size()),
718 true, ios, err, ex);
719 assert(iter.base() == v.data() + 13);
720 assert(err == std::ios_base::goodbit);
721 assert(ex == 123456789);
722 }
723 }
724 }
725