1 // 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // 27.7.1.3 Overridden virtual functions
24 #include <testsuite_hooks.h>
32 const char* strlit = "how to tell a story and other essays: mark twain";
33 const size_t strlitsize = std::strlen(strlit);
34 stringbuf sbuf(ios_base::out);
36 sbuf.pubsetbuf(buf, strlitsize);
37 sbuf.sputn(strlit, strlitsize);
38 VERIFY( std::strncmp(strlit, buf, strlitsize) != 0 );
41 void test02(std::stringbuf& in, bool pass)
44 typedef streambuf::pos_type pos_type;
45 typedef streambuf::off_type off_type;
46 pos_type bad = pos_type(off_type(-1));
50 p = in.pubseekoff(0, ios_base::beg, ios_base::in);
54 p = in.pubseekoff(0, ios_base::beg, ios_base::out);
57 p = in.pubseekoff(0, ios_base::beg);
62 p = in.pubseekpos(0, ios_base::in);
66 p = in.pubseekpos(0, ios_base::out);
81 VERIFY( ob.getloc() == loc );
83 locale::global(locale("en_US"));
84 VERIFY( ob.getloc() == loc );
86 locale loc_de ("de_DE");
87 locale ret = ob.pubimbue(loc_de);
88 VERIFY( ob.getloc() == loc_de );
92 VERIFY( ob.getloc() == loc_de );
97 class Derived_stringbuf : public std::stringbuf
100 int_type overflow(int_type c)
103 return std::stringbuf::overflow(c);
106 const char_type* pub_epptr() const
111 const char_type* pub_pptr() const
125 Derived_stringbuf dsbuf_01;
128 VERIFY( over_called );
129 over_expected = dsbuf_01.pub_epptr() == dsbuf_01.pub_pptr();
132 VERIFY( (!over_expected && !over_called)
133 || (over_expected && over_called) );
135 VERIFY( dsbuf_01.str() == "ivi" ); // Sanity check.
138 Derived_stringbuf dsbuf_02;
140 dsbuf_02.sputn("sonne's", 7);
141 VERIFY( over_called );
142 over_expected = dsbuf_02.pub_epptr() == dsbuf_02.pub_pptr();
144 dsbuf_02.sputn(" peak", 5);
145 VERIFY( (!over_expected && !over_called)
146 || (over_expected && over_called) );
147 VERIFY( dsbuf_02.str() == "sonne's peak" ); // Sanity check.
155 // movie star, submarine scientist!
156 stringbuf in1("Hedy Lamarr", ios_base::in);
157 stringbuf in2(ios_base::in);
158 stringbuf in3("", ios_base::in);
163 __gnu_cxx_test::run_test_wrapped_generic_locale_exception_catcher(test08);