get_string_en_US.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===----------------------------------------------------------------------===//
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ��������������������The LLVM Compiler Infrastructure
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file is distributed under the University of Illinois Open Source
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// License. See LICENSE.TXT for details.
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===----------------------------------------------------------------------===//
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// <locale>
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// class money_get<charT, InputIterator>
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//               ios_base::iostate& err, string_type& v) const;
161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <locale>
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <ios>
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <streambuf>
20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include <cassert>
21c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "iterators.h"
22c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
23c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)typedef std::money_get<char, input_iterator<const char*> > Fn;
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class my_facet
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    : public Fn
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)public:
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    explicit my_facet(std::size_t refs = 0)
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        : Fn(refs) {}
317dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch};
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class my_facetw
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    : public Fw
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)public:
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    explicit my_facetw(std::size_t refs = 0)
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        : Fw(refs) {}
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int main()
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    std::ios ios(0);
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    std::string loc_name("en_US");
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ios.imbue(std::locale(ios.getloc(),
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                          new std::moneypunct_byname<char, false>(loc_name)));
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ios.imbue(std::locale(ios.getloc(),
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          new std::moneypunct_byname<char, true>(loc_name)));
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ios.imbue(std::locale(ios.getloc(),
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ios.imbue(std::locale(ios.getloc(),
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    {
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        const my_facet f(1);
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        // char, national
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {   // zero
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::string v = "0.00";
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            typedef input_iterator<const char*> I;
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::string ex;
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::ios_base::iostate err = std::ios_base::goodbit;
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            I iter = f.get(I(v.data()), I(v.data() + v.size()),
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                                false, ios, err, ex);
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            assert(iter.base() == v.data() + v.size());
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            assert(err == std::ios_base::eofbit);
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            assert(ex == "0");
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        }
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {   // negative one
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::string v = "-0.01";
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            typedef input_iterator<const char*> I;
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::string ex;
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::ios_base::iostate err = std::ios_base::goodbit;
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            I iter = f.get(I(v.data()), I(v.data() + v.size()),
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                                false, ios, err, ex);
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            assert(iter.base() == v.data() + v.size());
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            assert(err == std::ios_base::eofbit);
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            assert(ex == "-1");
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        }
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {   // positive
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::string v = "1,234,567.89";
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            typedef input_iterator<const char*> I;
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::string ex;
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::ios_base::iostate err = std::ios_base::goodbit;
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            I iter = f.get(I(v.data()), I(v.data() + v.size()),
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                                false, ios, err, ex);
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            assert(iter.base() == v.data() + v.size());
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            assert(err == std::ios_base::eofbit);
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            assert(ex == "123456789");
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        }
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {   // negative
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::string v = "-1,234,567.89";
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            typedef input_iterator<const char*> I;
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::string ex;
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            std::ios_base::iostate err = std::ios_base::goodbit;
96            I iter = f.get(I(v.data()), I(v.data() + v.size()),
97                                                false, ios, err, ex);
98            assert(iter.base() == v.data() + v.size());
99            assert(err == std::ios_base::eofbit);
100            assert(ex == "-123456789");
101        }
102        {   // negative
103            std::string v = "-1234567.89";
104            typedef input_iterator<const char*> I;
105            std::string ex;
106            std::ios_base::iostate err = std::ios_base::goodbit;
107            I iter = f.get(I(v.data()), I(v.data() + v.size()),
108                                                false, ios, err, ex);
109            assert(iter.base() == v.data() + v.size());
110            assert(err == std::ios_base::eofbit);
111            assert(ex == "-123456789");
112        }
113        {   // zero, showbase
114            std::string v = "$0.00";
115            typedef input_iterator<const char*> I;
116            std::string ex;
117            std::ios_base::iostate err = std::ios_base::goodbit;
118            I iter = f.get(I(v.data()), I(v.data() + v.size()),
119                                                false, ios, err, ex);
120            assert(iter.base() == v.data() + v.size());
121            assert(err == std::ios_base::eofbit);
122            assert(ex == "0");
123        }
124        {   // zero, showbase
125            std::string v = "$0.00";
126            showbase(ios);
127            typedef input_iterator<const char*> I;
128            std::string ex;
129            std::ios_base::iostate err = std::ios_base::goodbit;
130            I iter = f.get(I(v.data()), I(v.data() + v.size()),
131                                                false, ios, err, ex);
132            assert(iter.base() == v.data() + v.size());
133            assert(err == std::ios_base::eofbit);
134            assert(ex == "0");
135            noshowbase(ios);
136        }
137        {   // negative one, showbase
138            std::string v = "-$0.01";
139            typedef input_iterator<const char*> I;
140            std::string ex;
141            std::ios_base::iostate err = std::ios_base::goodbit;
142            I iter = f.get(I(v.data()), I(v.data() + v.size()),
143                                                false, ios, err, ex);
144            assert(iter.base() == v.data() + v.size());
145            assert(err == std::ios_base::eofbit);
146            assert(ex == "-1");
147        }
148        {   // negative one, showbase
149            std::string v = "-$0.01";
150            showbase(ios);
151            typedef input_iterator<const char*> I;
152            std::string ex;
153            std::ios_base::iostate err = std::ios_base::goodbit;
154            I iter = f.get(I(v.data()), I(v.data() + v.size()),
155                                                false, ios, err, ex);
156            assert(iter.base() == v.data() + v.size());
157            assert(err == std::ios_base::eofbit);
158            assert(ex == "-1");
159            noshowbase(ios);
160        }
161        {   // positive, showbase
162            std::string v = "$1,234,567.89";
163            typedef input_iterator<const char*> I;
164            std::string ex;
165            std::ios_base::iostate err = std::ios_base::goodbit;
166            I iter = f.get(I(v.data()), I(v.data() + v.size()),
167                                                false, ios, err, ex);
168            assert(iter.base() == v.data() + v.size());
169            assert(err == std::ios_base::eofbit);
170            assert(ex == "123456789");
171        }
172        {   // positive, showbase
173            std::string v = "$1,234,567.89";
174            showbase(ios);
175            typedef input_iterator<const char*> I;
176            std::string ex;
177            std::ios_base::iostate err = std::ios_base::goodbit;
178            I iter = f.get(I(v.data()), I(v.data() + v.size()),
179                                                false, ios, err, ex);
180            assert(iter.base() == v.data() + v.size());
181            assert(err == std::ios_base::eofbit);
182            assert(ex == "123456789");
183            noshowbase(ios);
184        }
185        {   // negative, showbase
186            std::string v = "-$1,234,567.89";
187            showbase(ios);
188            typedef input_iterator<const char*> I;
189            std::string ex;
190            std::ios_base::iostate err = std::ios_base::goodbit;
191            I iter = f.get(I(v.data()), I(v.data() + v.size()),
192                                                false, ios, err, ex);
193            assert(iter.base() == v.data() + v.size());
194            assert(err == std::ios_base::eofbit);
195            assert(ex == "-123456789");
196            noshowbase(ios);
197        }
198        {   // negative, showbase
199            std::string v = "-USD 1,234,567.89";
200            showbase(ios);
201            typedef input_iterator<const char*> I;
202            std::string ex;
203            std::ios_base::iostate err = std::ios_base::goodbit;
204            I iter = f.get(I(v.data()), I(v.data() + v.size()),
205                                                false, ios, err, ex);
206            assert(iter.base() == v.data() + 1);
207            assert(err == std::ios_base::failbit);
208            assert(ex == "");
209            noshowbase(ios);
210        }
211        {   // negative, showbase
212            std::string v = "-USD 1,234,567.89";
213            typedef input_iterator<const char*> I;
214            std::string ex;
215            std::ios_base::iostate err = std::ios_base::goodbit;
216            I iter = f.get(I(v.data()), I(v.data() + v.size()),
217                                                false, ios, err, ex);
218            assert(iter.base() == v.data() + 1);
219            assert(err == std::ios_base::failbit);
220            assert(ex == "");
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            std::string 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            std::string 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            std::string 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            std::string 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            std::string 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 = "USD 0.00";
283            typedef input_iterator<const char*> I;
284            std::string 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 = "USD 0.00";
294            showbase(ios);
295            typedef input_iterator<const char*> I;
296            std::string 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 = "-USD 0.01";
307            typedef input_iterator<const char*> I;
308            std::string 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 = "-USD 0.01";
318            showbase(ios);
319            typedef input_iterator<const char*> I;
320            std::string 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 = "USD 1,234,567.89";
331            typedef input_iterator<const char*> I;
332            std::string 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 = "USD 1,234,567.89";
342            showbase(ios);
343            typedef input_iterator<const char*> I;
344            std::string 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 = "-USD 1,234,567.89";
355            showbase(ios);
356            typedef input_iterator<const char*> I;
357            std::string 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 = "-$1,234,567.89";
368            showbase(ios);
369            typedef input_iterator<const char*> I;
370            std::string 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() + 1);
375            assert(err == std::ios_base::failbit);
376            assert(ex == "");
377            noshowbase(ios);
378        }
379        {   // negative, showbase
380            std::string v = "-$1,234,567.89";
381            typedef input_iterator<const char*> I;
382            std::string ex;
383            std::ios_base::iostate err = std::ios_base::goodbit;
384            I iter = f.get(I(v.data()), I(v.data() + v.size()),
385                                                true, ios, err, ex);
386            assert(iter.base() == v.data() + 1);
387            assert(err == std::ios_base::failbit);
388            assert(ex == "");
389        }
390    }
391    {
392        const my_facetw f(1);
393        // wchar_t, national
394        {   // zero
395            std::wstring v = L"0.00";
396            typedef input_iterator<const wchar_t*> I;
397            std::wstring ex;
398            std::ios_base::iostate err = std::ios_base::goodbit;
399            I iter = f.get(I(v.data()), I(v.data() + v.size()),
400                                                false, ios, err, ex);
401            assert(iter.base() == v.data() + v.size());
402            assert(err == std::ios_base::eofbit);
403            assert(ex == L"0");
404        }
405        {   // negative one
406            std::wstring v = L"-0.01";
407            typedef input_iterator<const wchar_t*> I;
408            std::wstring ex;
409            std::ios_base::iostate err = std::ios_base::goodbit;
410            I iter = f.get(I(v.data()), I(v.data() + v.size()),
411                                                false, ios, err, ex);
412            assert(iter.base() == v.data() + v.size());
413            assert(err == std::ios_base::eofbit);
414            assert(ex == L"-1");
415        }
416        {   // positive
417            std::wstring v = L"1,234,567.89";
418            typedef input_iterator<const wchar_t*> I;
419            std::wstring ex;
420            std::ios_base::iostate err = std::ios_base::goodbit;
421            I iter = f.get(I(v.data()), I(v.data() + v.size()),
422                                                false, ios, err, ex);
423            assert(iter.base() == v.data() + v.size());
424            assert(err == std::ios_base::eofbit);
425            assert(ex == L"123456789");
426        }
427        {   // negative
428            std::wstring v = L"-1,234,567.89";
429            typedef input_iterator<const wchar_t*> I;
430            std::wstring ex;
431            std::ios_base::iostate err = std::ios_base::goodbit;
432            I iter = f.get(I(v.data()), I(v.data() + v.size()),
433                                                false, ios, err, ex);
434            assert(iter.base() == v.data() + v.size());
435            assert(err == std::ios_base::eofbit);
436            assert(ex == L"-123456789");
437        }
438        {   // negative
439            std::wstring v = L"-1234567.89";
440            typedef input_iterator<const wchar_t*> I;
441            std::wstring ex;
442            std::ios_base::iostate err = std::ios_base::goodbit;
443            I iter = f.get(I(v.data()), I(v.data() + v.size()),
444                                                false, ios, err, ex);
445            assert(iter.base() == v.data() + v.size());
446            assert(err == std::ios_base::eofbit);
447            assert(ex == L"-123456789");
448        }
449        {   // zero, showbase
450            std::wstring v = L"$0.00";
451            typedef input_iterator<const wchar_t*> I;
452            std::wstring ex;
453            std::ios_base::iostate err = std::ios_base::goodbit;
454            I iter = f.get(I(v.data()), I(v.data() + v.size()),
455                                                false, ios, err, ex);
456            assert(iter.base() == v.data() + v.size());
457            assert(err == std::ios_base::eofbit);
458            assert(ex == L"0");
459        }
460        {   // zero, showbase
461            std::wstring v = L"$0.00";
462            showbase(ios);
463            typedef input_iterator<const wchar_t*> I;
464            std::wstring ex;
465            std::ios_base::iostate err = std::ios_base::goodbit;
466            I iter = f.get(I(v.data()), I(v.data() + v.size()),
467                                                false, ios, err, ex);
468            assert(iter.base() == v.data() + v.size());
469            assert(err == std::ios_base::eofbit);
470            assert(ex == L"0");
471            noshowbase(ios);
472        }
473        {   // negative one, showbase
474            std::wstring v = L"-$0.01";
475            typedef input_iterator<const wchar_t*> I;
476            std::wstring ex;
477            std::ios_base::iostate err = std::ios_base::goodbit;
478            I iter = f.get(I(v.data()), I(v.data() + v.size()),
479                                                false, ios, err, ex);
480            assert(iter.base() == v.data() + v.size());
481            assert(err == std::ios_base::eofbit);
482            assert(ex == L"-1");
483        }
484        {   // negative one, showbase
485            std::wstring v = L"-$0.01";
486            showbase(ios);
487            typedef input_iterator<const wchar_t*> I;
488            std::wstring ex;
489            std::ios_base::iostate err = std::ios_base::goodbit;
490            I iter = f.get(I(v.data()), I(v.data() + v.size()),
491                                                false, ios, err, ex);
492            assert(iter.base() == v.data() + v.size());
493            assert(err == std::ios_base::eofbit);
494            assert(ex == L"-1");
495            noshowbase(ios);
496        }
497        {   // positive, showbase
498            std::wstring v = L"$1,234,567.89";
499            typedef input_iterator<const wchar_t*> I;
500            std::wstring 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 == L"123456789");
507        }
508        {   // positive, showbase
509            std::wstring v = L"$1,234,567.89";
510            showbase(ios);
511            typedef input_iterator<const wchar_t*> I;
512            std::wstring 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 == L"123456789");
519            noshowbase(ios);
520        }
521        {   // negative, showbase
522            std::wstring v = L"-$1,234,567.89";
523            showbase(ios);
524            typedef input_iterator<const wchar_t*> I;
525            std::wstring 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 == L"-123456789");
532            noshowbase(ios);
533        }
534        {   // negative, showbase
535            std::wstring v = L"-USD 1,234,567.89";
536            showbase(ios);
537            typedef input_iterator<const wchar_t*> I;
538            std::wstring 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() + 1);
543            assert(err == std::ios_base::failbit);
544            assert(ex == L"");
545            noshowbase(ios);
546        }
547        {   // negative, showbase
548            std::wstring v = L"-USD 1,234,567.89";
549            typedef input_iterator<const wchar_t*> I;
550            std::wstring ex;
551            std::ios_base::iostate err = std::ios_base::goodbit;
552            I iter = f.get(I(v.data()), I(v.data() + v.size()),
553                                                false, ios, err, ex);
554            assert(iter.base() == v.data() + 1);
555            assert(err == std::ios_base::failbit);
556            assert(ex == L"");
557        }
558    }
559    {
560        const my_facetw f(1);
561        // wchar_t, international
562        {   // zero
563            std::wstring v = L"0.00";
564            typedef input_iterator<const wchar_t*> I;
565            std::wstring ex;
566            std::ios_base::iostate err = std::ios_base::goodbit;
567            I iter = f.get(I(v.data()), I(v.data() + v.size()),
568                                                true, ios, err, ex);
569            assert(iter.base() == v.data() + v.size());
570            assert(err == std::ios_base::eofbit);
571            assert(ex == L"0");
572        }
573        {   // negative one
574            std::wstring v = L"-0.01";
575            typedef input_iterator<const wchar_t*> I;
576            std::wstring ex;
577            std::ios_base::iostate err = std::ios_base::goodbit;
578            I iter = f.get(I(v.data()), I(v.data() + v.size()),
579                                                true, ios, err, ex);
580            assert(iter.base() == v.data() + v.size());
581            assert(err == std::ios_base::eofbit);
582            assert(ex == L"-1");
583        }
584        {   // positive
585            std::wstring v = L"1,234,567.89";
586            typedef input_iterator<const wchar_t*> I;
587            std::wstring ex;
588            std::ios_base::iostate err = std::ios_base::goodbit;
589            I iter = f.get(I(v.data()), I(v.data() + v.size()),
590                                                true, ios, err, ex);
591            assert(iter.base() == v.data() + v.size());
592            assert(err == std::ios_base::eofbit);
593            assert(ex == L"123456789");
594        }
595        {   // negative
596            std::wstring v = L"-1,234,567.89";
597            typedef input_iterator<const wchar_t*> I;
598            std::wstring ex;
599            std::ios_base::iostate err = std::ios_base::goodbit;
600            I iter = f.get(I(v.data()), I(v.data() + v.size()),
601                                                true, ios, err, ex);
602            assert(iter.base() == v.data() + v.size());
603            assert(err == std::ios_base::eofbit);
604            assert(ex == L"-123456789");
605        }
606        {   // negative
607            std::wstring v = L"-1234567.89";
608            typedef input_iterator<const wchar_t*> I;
609            std::wstring ex;
610            std::ios_base::iostate err = std::ios_base::goodbit;
611            I iter = f.get(I(v.data()), I(v.data() + v.size()),
612                                                true, ios, err, ex);
613            assert(iter.base() == v.data() + v.size());
614            assert(err == std::ios_base::eofbit);
615            assert(ex == L"-123456789");
616        }
617        {   // zero, showbase
618            std::wstring v = L"USD 0.00";
619            typedef input_iterator<const wchar_t*> I;
620            std::wstring 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 == L"0");
627        }
628        {   // zero, showbase
629            std::wstring v = L"USD 0.00";
630            showbase(ios);
631            typedef input_iterator<const wchar_t*> I;
632            std::wstring 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 == L"0");
639            noshowbase(ios);
640        }
641        {   // negative one, showbase
642            std::wstring v = L"-USD 0.01";
643            typedef input_iterator<const wchar_t*> I;
644            std::wstring ex;
645            std::ios_base::iostate err = std::ios_base::goodbit;
646            I iter = f.get(I(v.data()), I(v.data() + v.size()),
647                                                true, ios, err, ex);
648            assert(iter.base() == v.data() + v.size());
649            assert(err == std::ios_base::eofbit);
650            assert(ex == L"-1");
651        }
652        {   // negative one, showbase
653            std::wstring v = L"-USD 0.01";
654            showbase(ios);
655            typedef input_iterator<const wchar_t*> I;
656            std::wstring ex;
657            std::ios_base::iostate err = std::ios_base::goodbit;
658            I iter = f.get(I(v.data()), I(v.data() + v.size()),
659                                                true, ios, err, ex);
660            assert(iter.base() == v.data() + v.size());
661            assert(err == std::ios_base::eofbit);
662            assert(ex == L"-1");
663            noshowbase(ios);
664        }
665        {   // positive, showbase
666            std::wstring v = L"USD 1,234,567.89";
667            typedef input_iterator<const wchar_t*> I;
668            std::wstring ex;
669            std::ios_base::iostate err = std::ios_base::goodbit;
670            I iter = f.get(I(v.data()), I(v.data() + v.size()),
671                                                true, ios, err, ex);
672            assert(iter.base() == v.data() + v.size());
673            assert(err == std::ios_base::eofbit);
674            assert(ex == L"123456789");
675        }
676        {   // positive, showbase
677            std::wstring v = L"USD 1,234,567.89";
678            showbase(ios);
679            typedef input_iterator<const wchar_t*> I;
680            std::wstring ex;
681            std::ios_base::iostate err = std::ios_base::goodbit;
682            I iter = f.get(I(v.data()), I(v.data() + v.size()),
683                                                true, ios, err, ex);
684            assert(iter.base() == v.data() + v.size());
685            assert(err == std::ios_base::eofbit);
686            assert(ex == L"123456789");
687            noshowbase(ios);
688        }
689        {   // negative, showbase
690            std::wstring v = L"-USD 1,234,567.89";
691            showbase(ios);
692            typedef input_iterator<const wchar_t*> I;
693            std::wstring ex;
694            std::ios_base::iostate err = std::ios_base::goodbit;
695            I iter = f.get(I(v.data()), I(v.data() + v.size()),
696                                                true, ios, err, ex);
697            assert(iter.base() == v.data() + v.size());
698            assert(err == std::ios_base::eofbit);
699            assert(ex == L"-123456789");
700            noshowbase(ios);
701        }
702        {   // negative, showbase
703            std::wstring v = L"-$1,234,567.89";
704            showbase(ios);
705            typedef input_iterator<const wchar_t*> I;
706            std::wstring ex;
707            std::ios_base::iostate err = std::ios_base::goodbit;
708            I iter = f.get(I(v.data()), I(v.data() + v.size()),
709                                                true, ios, err, ex);
710            assert(iter.base() == v.data() + 1);
711            assert(err == std::ios_base::failbit);
712            assert(ex == L"");
713            noshowbase(ios);
714        }
715        {   // negative, showbase
716            std::wstring v = L"-$1,234,567.89";
717            typedef input_iterator<const wchar_t*> I;
718            std::wstring ex;
719            std::ios_base::iostate err = std::ios_base::goodbit;
720            I iter = f.get(I(v.data()), I(v.data() + v.size()),
721                                                true, ios, err, ex);
722            assert(iter.base() == v.data() + 1);
723            assert(err == std::ios_base::failbit);
724            assert(ex == L"");
725        }
726    }
727}
728