Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / testsuite / 22_locale / num_get / get / char / 22131.cc
blob827fd6c5b8eac37392771d261fbd362b4f97db3f
1 // 2005-06-28 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2005 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
21 // 22.2.2.1.1 num_get members
23 #include <locale>
24 #include <sstream>
25 #include <testsuite_hooks.h>
27 struct Punct: std::numpunct<char>
29 std::string do_grouping() const { return "\1"; }
30 char do_thousands_sep() const { return '#'; }
33 // libstdc++/22131
34 void test01()
36 using namespace std;
37 typedef istreambuf_iterator<char> iterator_type;
39 bool test __attribute__((unused)) = true;
41 istringstream iss1, iss2;
42 iss1.imbue(locale(iss1.getloc(), new Punct));
43 const num_get<char>& ng1 = use_facet<num_get<char> >(iss1.getloc());
45 ios_base::iostate err = ios_base::goodbit;
46 iterator_type end;
47 long l = 0l;
48 long l1 = 1l;
49 long l2 = 2l;
50 long l3 = 3l;
51 double d = 0.0;
52 double d1 = 1.0;
53 double d2 = 2.0;
55 iss1.str("00#0#1");
56 err = ios_base::goodbit;
57 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
58 VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
59 VERIFY( l == l1 );
61 iss1.str("000##2");
62 iss1.clear();
63 err = ios_base::goodbit;
64 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
65 VERIFY( err == ios_base::failbit );
66 VERIFY( *end == '#' );
67 VERIFY( l == l1 );
69 iss1.str("0#0#0#2");
70 iss1.clear();
71 err = ios_base::goodbit;
72 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
73 VERIFY( err == ios_base::eofbit );
74 VERIFY( l == l2 );
76 iss1.str("00#0#1");
77 iss1.clear();
78 err = ios_base::goodbit;
79 end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
80 VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
81 VERIFY( d == d1 );
83 iss1.str("000##2");
84 iss1.clear();
85 err = ios_base::goodbit;
86 end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
87 VERIFY( err == ios_base::failbit );
88 VERIFY( *end == '#' );
89 VERIFY( d == d1 );
91 iss1.str("0#0#0#2");
92 iss1.clear();
93 err = ios_base::goodbit;
94 end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
95 VERIFY( err == ios_base::eofbit );
96 VERIFY( d == d2 );
98 iss1.str("0#0");
99 iss1.clear();
100 iss1.unsetf(ios::basefield);
101 err = ios_base::goodbit;
102 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
103 VERIFY( err == ios_base::failbit );
104 VERIFY( *end == '#' );
105 VERIFY( l == l2 );
107 iss1.str("00#0#3");
108 iss1.clear();
109 err = ios_base::goodbit;
110 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
111 VERIFY( err == ios_base::eofbit );
112 VERIFY( l == l3 );
114 iss1.str("00#02");
115 iss1.clear();
116 err = ios_base::goodbit;
117 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
118 VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
119 VERIFY( l == l2 );
122 int main()
124 test01();
125 return 0;