]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/money_get/get/char/19.cc
1 // 2004-03-15 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2004-2013 Free Software Foundation, Inc.
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 3, or (at your option)
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 COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 22.2.6.1.1 money_get members
24 #include <testsuite_hooks.h>
26 struct My_money_io_01
: public std::moneypunct
<char, false>
28 std::string
do_curr_symbol() const { return "$"; }
29 std::string
do_positive_sign() const { return ""; }
30 std::string
do_negative_sign() const { return ""; }
32 pattern
do_neg_format() const
34 pattern pat
= { { value
, symbol
, none
, sign
} };
39 struct My_money_io_02
: public std::moneypunct
<char, false>
41 std::string
do_curr_symbol() const { return "%"; }
42 std::string
do_positive_sign() const { return ""; }
43 std::string
do_negative_sign() const { return "-"; }
45 pattern
do_neg_format() const
47 pattern pat
= { { value
, symbol
, sign
, none
} };
52 struct My_money_io_03
: public std::moneypunct
<char, false>
54 std::string
do_curr_symbol() const { return "&"; }
55 std::string
do_positive_sign() const { return ""; }
56 std::string
do_negative_sign() const { return ""; }
58 pattern
do_neg_format() const
60 pattern pat
= { { value
, space
, symbol
, sign
} };
65 // When both do_positive_sign and do_negative_sign return an empty
66 // string, patterns of the forms { value, symbol, none, sign },
67 // { value, symbol, sign, none } and { X, Y, symbol, sign } imply
68 // that the symbol is not consumed since no other characters are
69 // needed to complete the format.
73 typedef istreambuf_iterator
<char> iterator_type
;
75 bool test
__attribute__((unused
)) = true;
78 locale
loc_01(locale::classic(), new My_money_io_01
);
79 locale
loc_02(locale::classic(), new My_money_io_02
);
80 locale
loc_03(locale::classic(), new My_money_io_03
);
82 iterator_type end
, end01
, end02
, end03
;
83 istringstream iss_01
, iss_02
, iss_03
;
87 // cache the money_get facet
88 const money_get
<char>& mon_get_01
=
89 use_facet
<money_get
<char> >(iss_01
.getloc());
90 const money_get
<char>& mon_get_02
=
91 use_facet
<money_get
<char> >(iss_02
.getloc());
92 const money_get
<char>& mon_get_03
=
93 use_facet
<money_get
<char> >(iss_03
.getloc());
96 iterator_type
is_it01(iss_01
);
98 ios_base::iostate err01
= ios_base::goodbit
;
99 end01
= mon_get_01
.get(is_it01
, end
, false, iss_01
, err01
, result01
);
100 VERIFY( err01
== ios_base::goodbit
);
101 VERIFY( *end01
== '$' );
104 iterator_type
is_it02(iss_02
);
106 ios_base::iostate err02
= ios_base::goodbit
;
107 end02
= mon_get_02
.get(is_it02
, end
, false, iss_02
, err02
, result02
);
108 VERIFY( err02
== ios_base::goodbit
);
109 VERIFY( *end02
== '%' );
112 iterator_type
is_it03(iss_03
);
114 ios_base::iostate err03
= ios_base::goodbit
;
115 end03
= mon_get_03
.get(is_it03
, end
, false, iss_03
, err03
, result03
);
116 VERIFY( err03
== ios_base::goodbit
);
117 VERIFY( *end03
== '&' );