diff options
| author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-07 21:48:01 +0000 |
|---|---|---|
| committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-07 21:48:01 +0000 |
| commit | 8cbb7faaad12fcaa9ee7fec9fac48c5939d9c56d (patch) | |
| tree | ada7289afa96cb40c16f8be542b8129e99b4a7a3 /libstdc++-v3/testsuite/27_io/basic_stringbuf | |
| parent | b5f5c5e8be1f22e01fbc9ed541241d6085a78b68 (diff) | |
| download | ppe42-gcc-8cbb7faaad12fcaa9ee7fec9fac48c5939d9c56d.tar.gz ppe42-gcc-8cbb7faaad12fcaa9ee7fec9fac48c5939d9c56d.zip | |
2004-07-07 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/16401
* include/bits/sstream.tcc (overflow): When reallocating _M_string
use an exponential grow policy.
* testsuite/27_io/basic_stringbuf/overflow/char/1.cc: New.
* testsuite/performance/27_io/stringbuf_overflow.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84235 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_stringbuf')
| -rw-r--r-- | libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/char/1.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/char/1.cc new file mode 100644 index 00000000000..d1608649b80 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/char/1.cc @@ -0,0 +1,57 @@ +// 2004-07-07 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.7.1.3 basic_stringbuf overridden virtual functions. + +#include <sstream> +#include <cstdlib> +#include <testsuite_hooks.h> + +using namespace std; + +string +data(unsigned len) +{ + string ret; + for (unsigned i = 0; i < len; ++i) + ret.push_back('a' + rand() % 26); + return ret; +} + +void +test01(unsigned iter) +{ + bool test __attribute__((unused)) = true; + + for (unsigned n = 1; n <= iter; n *= 10) + { + const string str = data(n); + stringbuf sstr; + for (unsigned i = 0; i < n; ++i) + sstr.sputc(str[i]); + VERIFY( str == sstr.str() ); + } +} + +int main() +{ + test01(10000000); + return 0; +} |

