]> gcc.gnu.org Git - gcc.git/blame - libstdc++-v3/testsuite/22_locale/money_get/get/char/5.cc
Update copyright years.
[gcc.git] / libstdc++-v3 / testsuite / 22_locale / money_get / get / char / 5.cc
CommitLineData
5f8d36fe
BK
1// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
2
5624e564 3// Copyright (C) 2001-2015 Free Software Foundation, Inc.
5f8d36fe
BK
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
748086b7 8// Free Software Foundation; either version 3, or (at your option)
5f8d36fe
BK
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
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
5f8d36fe
BK
19
20// 22.2.6.1.1 money_get members
21
22#include <locale>
23#include <sstream>
24#include <testsuite_hooks.h>
25
26void test05()
27{
28 using namespace std;
11f10e6b 29 bool test __attribute__((unused)) = true;
5f8d36fe
BK
30
31 // Check money_get works with other iterators besides streambuf
32 // input iterators.
33 typedef string::const_iterator iter_type;
34 typedef money_get<char, iter_type> mon_get_type;
35 const ios_base::iostate goodbit = ios_base::goodbit;
5f8d36fe
BK
36 ios_base::iostate err = goodbit;
37 const locale loc_c = locale::classic();
015daa3a 38 const string str = "1Eleanor Roosevelt";
5f8d36fe
BK
39
40 istringstream iss;
41 iss.imbue(locale(loc_c, new mon_get_type));
42
43 // Iterator advanced, state, output.
44 const mon_get_type& mg = use_facet<mon_get_type>(iss.getloc());
45
46 // 01 string
47 string res1;
48 iter_type end1 = mg.get(str.begin(), str.end(), false, iss, err, res1);
49 string rem1(end1, str.end());
50 VERIFY( err == goodbit );
51 VERIFY( res1 == "1" );
52 VERIFY( rem1 == "Eleanor Roosevelt" );
53
54 // 02 long double
55 iss.clear();
56 err = goodbit;
57 long double res2;
58 iter_type end2 = mg.get(str.begin(), str.end(), false, iss, err, res2);
59 string rem2(end2, str.end());
60 VERIFY( err == goodbit );
61 VERIFY( res2 == 1 );
62 VERIFY( rem2 == "Eleanor Roosevelt" );
63}
64
65int main()
66{
67 test05();
68 return 0;
69}
This page took 1.103232 seconds and 5 git commands to generate.