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