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, long double& 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_zh_CN_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 long double 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 long double 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 long double 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 long double 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 long double 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 = "\xEF\xBF\xA5""0.00";
117 typedef input_iterator<const char*> I;
118 long double 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 = "\xEF\xBF\xA5""0.00";
128 showbase(ios);
129 typedef input_iterator<const char*> I;
130 long double 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 = "\xEF\xBF\xA5""-0.01";
141 typedef input_iterator<const char*> I;
142 long double 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 = "\xEF\xBF\xA5""-0.01";
152 showbase(ios);
153 typedef input_iterator<const char*> I;
154 long double 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 = "\xEF\xBF\xA5""1,234,567.89";
165 typedef input_iterator<const char*> I;
166 long double 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 = "\xEF\xBF\xA5""1,234,567.89";
176 showbase(ios);
177 typedef input_iterator<const char*> I;
178 long double 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 = "\xEF\xBF\xA5""-1,234,567.89";
189 showbase(ios);
190 typedef input_iterator<const char*> I;
191 long double 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 = "CNY -1,234,567.89";
202 showbase(ios);
203 typedef input_iterator<const char*> I;
204 long double 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() + 0);
209 assert(err == std::ios_base::failbit);
210 noshowbase(ios);
211 }
212 { // negative, showbase
213 std::string v = "CNY -1,234,567.89";
214 typedef input_iterator<const char*> I;
215 long double ex;
216 std::ios_base::iostate err = std::ios_base::goodbit;
217 I iter = f.get(I(v.data()), I(v.data() + v.size()),
218 false, ios, err, ex);
219 assert(iter.base() == v.data() + 0);
220 assert(err == std::ios_base::failbit);
221 }
222 }
223 {
224 const my_facet f(1);
225 // char, international
226 { // zero
227 std::string v = "0.00";
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 true, ios, err, ex);
233 assert(iter.base() == v.data() + v.size());
234 assert(err == std::ios_base::eofbit);
235 assert(ex == 0);
236 }
237 { // negative one
238 std::string v = "-0.01";
239 typedef input_iterator<const char*> I;
240 long double ex;
241 std::ios_base::iostate err = std::ios_base::goodbit;
242 I iter = f.get(I(v.data()), I(v.data() + v.size()),
243 true, ios, err, ex);
244 assert(iter.base() == v.data() + v.size());
245 assert(err == std::ios_base::eofbit);
246 assert(ex == -1);
247 }
248 { // positive
249 std::string v = "1,234,567.89";
250 typedef input_iterator<const char*> I;
251 long double ex;
252 std::ios_base::iostate err = std::ios_base::goodbit;
253 I iter = f.get(I(v.data()), I(v.data() + v.size()),
254 true, ios, err, ex);
255 assert(iter.base() == v.data() + v.size());
256 assert(err == std::ios_base::eofbit);
257 assert(ex == 123456789);
258 }
259 { // negative
260 std::string v = "-1,234,567.89";
261 typedef input_iterator<const char*> I;
262 long double ex;
263 std::ios_base::iostate err = std::ios_base::goodbit;
264 I iter = f.get(I(v.data()), I(v.data() + v.size()),
265 true, ios, err, ex);
266 assert(iter.base() == v.data() + v.size());
267 assert(err == std::ios_base::eofbit);
268 assert(ex == -123456789);
269 }
270 { // negative
271 std::string v = "-1234567.89";
272 typedef input_iterator<const char*> I;
273 long double ex;
274 std::ios_base::iostate err = std::ios_base::goodbit;
275 I iter = f.get(I(v.data()), I(v.data() + v.size()),
276 true, ios, err, ex);
277 assert(iter.base() == v.data() + v.size());
278 assert(err == std::ios_base::eofbit);
279 assert(ex == -123456789);
280 }
281 { // zero, showbase
282 std::string v = "CNY 0.00";
283 typedef input_iterator<const char*> I;
284 long double ex;
285 std::ios_base::iostate err = std::ios_base::goodbit;
286 I iter = f.get(I(v.data()), I(v.data() + v.size()),
287 true, ios, err, ex);
288 assert(iter.base() == v.data() + v.size());
289 assert(err == std::ios_base::eofbit);
290 assert(ex == 0);
291 }
292 { // zero, showbase
293 std::string v = "CNY 0.00";
294 showbase(ios);
295 typedef input_iterator<const char*> I;
296 long double ex;
297 std::ios_base::iostate err = std::ios_base::goodbit;
298 I iter = f.get(I(v.data()), I(v.data() + v.size()),
299 true, ios, err, ex);
300 assert(iter.base() == v.data() + v.size());
301 assert(err == std::ios_base::eofbit);
302 assert(ex == 0);
303 noshowbase(ios);
304 }
305 { // negative one, showbase
306 std::string v = "CNY -0.01";
307 typedef input_iterator<const char*> I;
308 long double ex;
309 std::ios_base::iostate err = std::ios_base::goodbit;
310 I iter = f.get(I(v.data()), I(v.data() + v.size()),
311 true, ios, err, ex);
312 assert(iter.base() == v.data() + v.size());
313 assert(err == std::ios_base::eofbit);
314 assert(ex == -1);
315 }
316 { // negative one, showbase
317 std::string v = "CNY -0.01";
318 showbase(ios);
319 typedef input_iterator<const char*> I;
320 long double ex;
321 std::ios_base::iostate err = std::ios_base::goodbit;
322 I iter = f.get(I(v.data()), I(v.data() + v.size()),
323 true, ios, err, ex);
324 assert(iter.base() == v.data() + v.size());
325 assert(err == std::ios_base::eofbit);
326 assert(ex == -1);
327 noshowbase(ios);
328 }
329 { // positive, showbase
330 std::string v = "CNY 1,234,567.89";
331 typedef input_iterator<const char*> I;
332 long double ex;
333 std::ios_base::iostate err = std::ios_base::goodbit;
334 I iter = f.get(I(v.data()), I(v.data() + v.size()),
335 true, ios, err, ex);
336 assert(iter.base() == v.data() + v.size());
337 assert(err == std::ios_base::eofbit);
338 assert(ex == 123456789);
339 }
340 { // positive, showbase
341 std::string v = "CNY 1,234,567.89";
342 showbase(ios);
343 typedef input_iterator<const char*> I;
344 long double ex;
345 std::ios_base::iostate err = std::ios_base::goodbit;
346 I iter = f.get(I(v.data()), I(v.data() + v.size()),
347 true, ios, err, ex);
348 assert(iter.base() == v.data() + v.size());
349 assert(err == std::ios_base::eofbit);
350 assert(ex == 123456789);
351 noshowbase(ios);
352 }
353 { // negative, showbase
354 std::string v = "CNY -1,234,567.89";
355 showbase(ios);
356 typedef input_iterator<const char*> I;
357 long double ex;
358 std::ios_base::iostate err = std::ios_base::goodbit;
359 I iter = f.get(I(v.data()), I(v.data() + v.size()),
360 true, ios, err, ex);
361 assert(iter.base() == v.data() + v.size());
362 assert(err == std::ios_base::eofbit);
363 assert(ex == -123456789);
364 noshowbase(ios);
365 }
366 { // negative, showbase
367 std::string v = "\xEF\xBF\xA5""-1,234,567.89";
368 showbase(ios);
369 typedef input_iterator<const char*> I;
370 long double ex;
371 std::ios_base::iostate err = std::ios_base::goodbit;
372 I iter = f.get(I(v.data()), I(v.data() + v.size()),
373 true, ios, err, ex);
374 assert(iter.base() == v.data() + 0);
375 assert(err == std::ios_base::failbit);
376 noshowbase(ios);
377 }
378 { // negative, showbase
379 std::string v = "\xEF\xBF\xA5""-1,234,567.89";
380 typedef input_iterator<const char*> I;
381 long double ex;
382 std::ios_base::iostate err = std::ios_base::goodbit;
383 I iter = f.get(I(v.data()), I(v.data() + v.size()),
384 true, ios, err, ex);
385 assert(iter.base() == v.data() + 0);
386 assert(err == std::ios_base::failbit);
387 }
388 }
389 {
390 const my_facetw f(1);
391 // wchar_t, national
392 { // zero
393 std::wstring v = L"0.00";
394 typedef input_iterator<const wchar_t*> I;
395 long double ex;
396 std::ios_base::iostate err = std::ios_base::goodbit;
397 I iter = f.get(I(v.data()), I(v.data() + v.size()),
398 false, ios, err, ex);
399 assert(iter.base() == v.data() + v.size());
400 assert(err == std::ios_base::eofbit);
401 assert(ex == 0);
402 }
403 { // negative one
404 std::wstring v = L"-0.01";
405 typedef input_iterator<const wchar_t*> I;
406 long double ex;
407 std::ios_base::iostate err = std::ios_base::goodbit;
408 I iter = f.get(I(v.data()), I(v.data() + v.size()),
409 false, ios, err, ex);
410 assert(iter.base() == v.data() + v.size());
411 assert(err == std::ios_base::eofbit);
412 assert(ex == -1);
413 }
414 { // positive
415 std::wstring v = L"1,234,567.89";
416 typedef input_iterator<const wchar_t*> I;
417 long double ex;
418 std::ios_base::iostate err = std::ios_base::goodbit;
419 I iter = f.get(I(v.data()), I(v.data() + v.size()),
420 false, ios, err, ex);
421 assert(iter.base() == v.data() + v.size());
422 assert(err == std::ios_base::eofbit);
423 assert(ex == 123456789);
424 }
425 { // negative
426 std::wstring v = L"-1,234,567.89";
427 typedef input_iterator<const wchar_t*> I;
428 long double ex;
429 std::ios_base::iostate err = std::ios_base::goodbit;
430 I iter = f.get(I(v.data()), I(v.data() + v.size()),
431 false, ios, err, ex);
432 assert(iter.base() == v.data() + v.size());
433 assert(err == std::ios_base::eofbit);
434 assert(ex == -123456789);
435 }
436 { // negative
437 std::wstring v = L"-1234567.89";
438 typedef input_iterator<const wchar_t*> I;
439 long double ex;
440 std::ios_base::iostate err = std::ios_base::goodbit;
441 I iter = f.get(I(v.data()), I(v.data() + v.size()),
442 false, ios, err, ex);
443 assert(iter.base() == v.data() + v.size());
444 assert(err == std::ios_base::eofbit);
445 assert(ex == -123456789);
446 }
447 { // zero, showbase
448 std::wstring v = L"\xFFE5""0.00";
449 typedef input_iterator<const wchar_t*> I;
450 long double ex;
451 std::ios_base::iostate err = std::ios_base::goodbit;
452 I iter = f.get(I(v.data()), I(v.data() + v.size()),
453 false, ios, err, ex);
454 assert(iter.base() == v.data() + v.size());
455 assert(err == std::ios_base::eofbit);
456 assert(ex == 0);
457 }
458 { // zero, showbase
459 std::wstring v = L"\xFFE5""0.00";
460 showbase(ios);
461 typedef input_iterator<const wchar_t*> I;
462 long double ex;
463 std::ios_base::iostate err = std::ios_base::goodbit;
464 I iter = f.get(I(v.data()), I(v.data() + v.size()),
465 false, ios, err, ex);
466 assert(iter.base() == v.data() + v.size());
467 assert(err == std::ios_base::eofbit);
468 assert(ex == 0);
469 noshowbase(ios);
470 }
471 { // negative one, showbase
472 std::wstring v = L"\xFFE5""-0.01";
473 typedef input_iterator<const wchar_t*> I;
474 long double ex;
475 std::ios_base::iostate err = std::ios_base::goodbit;
476 I iter = f.get(I(v.data()), I(v.data() + v.size()),
477 false, ios, err, ex);
478 assert(iter.base() == v.data() + v.size());
479 assert(err == std::ios_base::eofbit);
480 assert(ex == -1);
481 }
482 { // negative one, showbase
483 std::wstring v = L"\xFFE5""-0.01";
484 showbase(ios);
485 typedef input_iterator<const wchar_t*> I;
486 long double ex;
487 std::ios_base::iostate err = std::ios_base::goodbit;
488 I iter = f.get(I(v.data()), I(v.data() + v.size()),
489 false, ios, err, ex);
490 assert(iter.base() == v.data() + v.size());
491 assert(err == std::ios_base::eofbit);
492 assert(ex == -1);
493 noshowbase(ios);
494 }
495 { // positive, showbase
496 std::wstring v = L"\xFFE5""1,234,567.89";
497 typedef input_iterator<const wchar_t*> I;
498 long double ex;
499 std::ios_base::iostate err = std::ios_base::goodbit;
500 I iter = f.get(I(v.data()), I(v.data() + v.size()),
501 false, ios, err, ex);
502 assert(iter.base() == v.data() + v.size());
503 assert(err == std::ios_base::eofbit);
504 assert(ex == 123456789);
505 }
506 { // positive, showbase
507 std::wstring v = L"\xFFE5""1,234,567.89";
508 showbase(ios);
509 typedef input_iterator<const wchar_t*> I;
510 long double ex;
511 std::ios_base::iostate err = std::ios_base::goodbit;
512 I iter = f.get(I(v.data()), I(v.data() + v.size()),
513 false, ios, err, ex);
514 assert(iter.base() == v.data() + v.size());
515 assert(err == std::ios_base::eofbit);
516 assert(ex == 123456789);
517 noshowbase(ios);
518 }
519 { // negative, showbase
520 std::wstring v = L"\xFFE5""-1,234,567.89";
521 showbase(ios);
522 typedef input_iterator<const wchar_t*> I;
523 long double ex;
524 std::ios_base::iostate err = std::ios_base::goodbit;
525 I iter = f.get(I(v.data()), I(v.data() + v.size()),
526 false, ios, err, ex);
527 assert(iter.base() == v.data() + v.size());
528 assert(err == std::ios_base::eofbit);
529 assert(ex == -123456789);
530 noshowbase(ios);
531 }
532 { // negative, showbase
533 std::wstring v = L"CNY -1,234,567.89";
534 showbase(ios);
535 typedef input_iterator<const wchar_t*> I;
536 long double ex;
537 std::ios_base::iostate err = std::ios_base::goodbit;
538 I iter = f.get(I(v.data()), I(v.data() + v.size()),
539 false, ios, err, ex);
540 assert(iter.base() == v.data() + 0);
541 assert(err == std::ios_base::failbit);
542 noshowbase(ios);
543 }
544 { // negative, showbase
545 std::wstring v = L"CNY -1,234,567.89";
546 typedef input_iterator<const wchar_t*> I;
547 long double ex;
548 std::ios_base::iostate err = std::ios_base::goodbit;
549 I iter = f.get(I(v.data()), I(v.data() + v.size()),
550 false, ios, err, ex);
551 assert(iter.base() == v.data() + 0);
552 assert(err == std::ios_base::failbit);
553 }
554 }
555 {
556 const my_facetw f(1);
557 // wchar_t, international
558 { // zero
559 std::wstring v = L"0.00";
560 typedef input_iterator<const wchar_t*> I;
561 long double ex;
562 std::ios_base::iostate err = std::ios_base::goodbit;
563 I iter = f.get(I(v.data()), I(v.data() + v.size()),
564 true, ios, err, ex);
565 assert(iter.base() == v.data() + v.size());
566 assert(err == std::ios_base::eofbit);
567 assert(ex == 0);
568 }
569 { // negative one
570 std::wstring v = L"-0.01";
571 typedef input_iterator<const wchar_t*> I;
572 long double ex;
573 std::ios_base::iostate err = std::ios_base::goodbit;
574 I iter = f.get(I(v.data()), I(v.data() + v.size()),
575 true, ios, err, ex);
576 assert(iter.base() == v.data() + v.size());
577 assert(err == std::ios_base::eofbit);
578 assert(ex == -1);
579 }
580 { // positive
581 std::wstring v = L"1,234,567.89";
582 typedef input_iterator<const wchar_t*> I;
583 long double ex;
584 std::ios_base::iostate err = std::ios_base::goodbit;
585 I iter = f.get(I(v.data()), I(v.data() + v.size()),
586 true, ios, err, ex);
587 assert(iter.base() == v.data() + v.size());
588 assert(err == std::ios_base::eofbit);
589 assert(ex == 123456789);
590 }
591 { // negative
592 std::wstring v = L"-1,234,567.89";
593 typedef input_iterator<const wchar_t*> I;
594 long double ex;
595 std::ios_base::iostate err = std::ios_base::goodbit;
596 I iter = f.get(I(v.data()), I(v.data() + v.size()),
597 true, ios, err, ex);
598 assert(iter.base() == v.data() + v.size());
599 assert(err == std::ios_base::eofbit);
600 assert(ex == -123456789);
601 }
602 { // negative
603 std::wstring v = L"-1234567.89";
604 typedef input_iterator<const wchar_t*> I;
605 long double ex;
606 std::ios_base::iostate err = std::ios_base::goodbit;
607 I iter = f.get(I(v.data()), I(v.data() + v.size()),
608 true, ios, err, ex);
609 assert(iter.base() == v.data() + v.size());
610 assert(err == std::ios_base::eofbit);
611 assert(ex == -123456789);
612 }
613 { // zero, showbase
614 std::wstring v = L"CNY 0.00";
615 typedef input_iterator<const wchar_t*> I;
616 long double ex;
617 std::ios_base::iostate err = std::ios_base::goodbit;
618 I iter = f.get(I(v.data()), I(v.data() + v.size()),
619 true, ios, err, ex);
620 assert(iter.base() == v.data() + v.size());
621 assert(err == std::ios_base::eofbit);
622 assert(ex == 0);
623 }
624 { // zero, showbase
625 std::wstring v = L"CNY 0.00";
626 showbase(ios);
627 typedef input_iterator<const wchar_t*> I;
628 long double ex;
629 std::ios_base::iostate err = std::ios_base::goodbit;
630 I iter = f.get(I(v.data()), I(v.data() + v.size()),
631 true, ios, err, ex);
632 assert(iter.base() == v.data() + v.size());
633 assert(err == std::ios_base::eofbit);
634 assert(ex == 0);
635 noshowbase(ios);
636 }
637 { // negative one, showbase
638 std::wstring v = L"CNY -0.01";
639 typedef input_iterator<const wchar_t*> I;
640 long double ex;
641 std::ios_base::iostate err = std::ios_base::goodbit;
642 I iter = f.get(I(v.data()), I(v.data() + v.size()),
643 true, ios, err, ex);
644 assert(iter.base() == v.data() + v.size());
645 assert(err == std::ios_base::eofbit);
646 assert(ex == -1);
647 }
648 { // negative one, showbase
649 std::wstring v = L"CNY -0.01";
650 showbase(ios);
651 typedef input_iterator<const wchar_t*> I;
652 long double ex;
653 std::ios_base::iostate err = std::ios_base::goodbit;
654 I iter = f.get(I(v.data()), I(v.data() + v.size()),
655 true, ios, err, ex);
656 assert(iter.base() == v.data() + v.size());
657 assert(err == std::ios_base::eofbit);
658 assert(ex == -1);
659 noshowbase(ios);
660 }
661 { // positive, showbase
662 std::wstring v = L"CNY 1,234,567.89";
663 typedef input_iterator<const wchar_t*> I;
664 long double ex;
665 std::ios_base::iostate err = std::ios_base::goodbit;
666 I iter = f.get(I(v.data()), I(v.data() + v.size()),
667 true, ios, err, ex);
668 assert(iter.base() == v.data() + v.size());
669 assert(err == std::ios_base::eofbit);
670 assert(ex == 123456789);
671 }
672 { // positive, showbase
673 std::wstring v = L"CNY 1,234,567.89";
674 showbase(ios);
675 typedef input_iterator<const wchar_t*> I;
676 long double ex;
677 std::ios_base::iostate err = std::ios_base::goodbit;
678 I iter = f.get(I(v.data()), I(v.data() + v.size()),
679 true, ios, err, ex);
680 assert(iter.base() == v.data() + v.size());
681 assert(err == std::ios_base::eofbit);
682 assert(ex == 123456789);
683 noshowbase(ios);
684 }
685 { // negative, showbase
686 std::wstring v = L"CNY -1,234,567.89";
687 showbase(ios);
688 typedef input_iterator<const wchar_t*> I;
689 long double ex;
690 std::ios_base::iostate err = std::ios_base::goodbit;
691 I iter = f.get(I(v.data()), I(v.data() + v.size()),
692 true, ios, err, ex);
693 assert(iter.base() == v.data() + v.size());
694 assert(err == std::ios_base::eofbit);
695 assert(ex == -123456789);
696 noshowbase(ios);
697 }
698 { // negative, showbase
699 std::wstring v = L"\xFFE5""-1,234,567.89";
700 showbase(ios);
701 typedef input_iterator<const wchar_t*> I;
702 long double ex;
703 std::ios_base::iostate err = std::ios_base::goodbit;
704 I iter = f.get(I(v.data()), I(v.data() + v.size()),
705 true, ios, err, ex);
706 assert(iter.base() == v.data() + 0);
707 assert(err == std::ios_base::failbit);
708 noshowbase(ios);
709 }
710 { // negative, showbase
711 std::wstring v = L"\xFFE5""-1,234,567.89";
712 typedef input_iterator<const wchar_t*> I;
713 long double ex;
714 std::ios_base::iostate err = std::ios_base::goodbit;
715 I iter = f.get(I(v.data()), I(v.data() + v.size()),
716 true, ios, err, ex);
717 assert(iter.base() == v.data() + 0);
718 assert(err == std::ios_base::failbit);
719 }
720 }
721 }
722