FSF GCC merge 02/23/03
[official-gcc.git] / libstdc++-v3 / testsuite / 22_locale / money_get / get / char / 7.cc
blobf275d4e59d43ef567524186fe85b9b53314bc2c7
1 // 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001, 2002, 2003 Free Software Foundation
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
21 // 22.2.6.1.1 money_get members
23 #include <locale>
24 #include <sstream>
25 #include <testsuite_hooks.h>
27 // We were appending to the string val passed by reference, instead
28 // of constructing a temporary candidate, eventually copied into
29 // val in case of successful parsing.
30 void test07()
32 using namespace std;
33 bool test = true;
35 typedef istreambuf_iterator<char> InIt;
36 InIt iend1, iend2, iend3;
38 locale loc_c = locale::classic();
39 string buffer1("123");
40 string buffer2("456");
41 string buffer3("Golgafrincham"); // From Nathan's original idea.
43 string val;
45 ios_base::iostate err;
47 const money_get<char,InIt>& mg = use_facet<money_get<char, InIt> >(loc_c);
49 istringstream fmt1(buffer1);
50 InIt ibeg1(fmt1);
51 mg.get(ibeg1,iend1,false,fmt1,err,val);
52 VERIFY( val == buffer1 );
54 istringstream fmt2(buffer2);
55 InIt ibeg2(fmt2);
56 mg.get(ibeg2,iend2,false,fmt2,err,val);
57 VERIFY( val == buffer2 );
59 val = buffer3;
60 istringstream fmt3(buffer3);
61 InIt ibeg3(fmt3);
62 mg.get(ibeg3,iend3,false,fmt3,err,val);
63 VERIFY( val == buffer3 );
66 int main()
68 test07();
69 return 0;