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