]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/7.cc
locale_facets.tcc: Tweak to avoid warnings.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / money_get / get / wchar_t / 7.cc
1 // 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
2
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.
10
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.
15
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.
20
21 // 22.2.6.1.1 money_get members
22
23 #include <locale>
24 #include <sstream>
25 #include <testsuite_hooks.h>
26
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()
31 {
32 using namespace std;
33 bool test __attribute__((unused)) = true;
34
35 typedef istreambuf_iterator<wchar_t> InIt;
36 InIt iend1, iend2, iend3;
37
38 locale loc_c = locale::classic();
39 wstring buffer1(L"123");
40 wstring buffer2(L"456");
41 wstring buffer3(L"Golgafrincham"); // From Nathan's original idea.
42
43 wstring val;
44
45 ios_base::iostate err;
46
47 const money_get<wchar_t,InIt>& mg = use_facet<money_get<wchar_t, InIt> >(loc_c);
48
49 wistringstream fmt1(buffer1);
50 InIt ibeg1(fmt1);
51 mg.get(ibeg1,iend1,false,fmt1,err,val);
52 VERIFY( val == buffer1 );
53
54 wistringstream fmt2(buffer2);
55 InIt ibeg2(fmt2);
56 mg.get(ibeg2,iend2,false,fmt2,err,val);
57 VERIFY( val == buffer2 );
58
59 val = buffer3;
60 wistringstream fmt3(buffer3);
61 InIt ibeg3(fmt3);
62 mg.get(ibeg3,iend3,false,fmt3,err,val);
63 VERIFY( val == buffer3 );
64 }
65
66 int main()
67 {
68 test07();
69 return 0;
70 }