1// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com> 2 3// Copyright (C) 2001, 2002, 2003, 2004 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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. 30void 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 fmt1.imbue(loc_c); 51 InIt ibeg1(fmt1); 52 mg.get(ibeg1, iend1, false, fmt1, err, val); 53 VERIFY( val == buffer1 ); 54 55 wistringstream fmt2(buffer2); 56 fmt2.imbue(loc_c); 57 InIt ibeg2(fmt2); 58 mg.get(ibeg2, iend2, false, fmt2, err, val); 59 VERIFY( val == buffer2 ); 60 61 val = buffer3; 62 wistringstream fmt3(buffer3); 63 fmt3.imbue(loc_c); 64 InIt ibeg3(fmt3); 65 mg.get(ibeg3, iend3, false, fmt3, err, val); 66 VERIFY( val == buffer3 ); 67} 68 69int main() 70{ 71 test07(); 72 return 0; 73} 74