Commit ba4b172f by Paolo Carlini Committed by Paolo Carlini

9827.cc: New.

2005-01-23  Paolo Carlini  <pcarlini@suse.de>

	* testsuite/27_io/basic_ostream/cons/wchar_t/9827.cc: New.
	* testsuite/27_io/basic_ostream/endl/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/ends/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/ends/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc: Likewise.
	* testsuite/27_io/basic_ostream/flush/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/flush/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/flush/wchar_t/
	exceptions_badbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	wchar_t/3.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	wchar_t/4.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	wchar_t/4402.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	wchar_t/5.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	wchar_t/6.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	wchar_t/9555-oa.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	wchar_t/exceptions_badbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	wchar_t/exceptions_failbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_character/
	wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_character/
	wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_character/
	wchar_t/3.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_character/
	wchar_t/4.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_character/
	wchar_t/5.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_character/
	wchar_t/6.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_character/
	wchar_t/9555-oc.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/
	wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/
	wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/
	wchar_t/3.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/
	wchar_t/4.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/
	wchar_t/5.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/
	wchar_t/9318-out.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/
	wchar_t/9424-out.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/
	wchar_t/9555-oo.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
	error_failbit.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
	exceptions_badbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
	exceptions_failbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
	exceptions_null.cc: Likewise.
	* testsuite/27_io/basic_ostream/put/char/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/put/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/seekp/char/
	exceptions_badbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/seekp/wchar_t/
	2346-fstream.cc: Likewise.
	* testsuite/27_io/basic_ostream/seekp/wchar_t/
	2346-sstream.cc: Likewise.
	* testsuite/27_io/basic_ostream/seekp/wchar_t/
	exceptions_badbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/sentry/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/sentry/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/tellp/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/tellp/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/tellp/wchar_t/
	exceptions_badbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/write/wchar_t/1.cc: Likewise.

	* testsuite/data/wostream_inserter_char-1.tst: Likewise.
	* testsuite/data/wostream_inserter_char-1.txt: Likewise.
	* testsuite/data/wostream_inserter_other-1.tst: Likewise.
	* testsuite/data/wostream_inserter_other-2.tst: Likewise.
	* testsuite/data/wostream_seeks-1.tst: Likewise.

	* testsuite/27_io/basic_ostream/endl/char/1.cc: Minor tweaks.
	* testsuite/27_io/basic_ostream/ends/char/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/exceptions/char/9561.cc: Likewise.
	* testsuite/27_io/basic_ostream/flush/char/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/flush/char/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/flush/char/
	exceptions_badbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	char/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	char/3.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	char/4.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	char/4402.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	char/5.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_arithmetic/
	char/6.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_character/
	char/4.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/
	2.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/
	5.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/
	error_failbit.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/
	exceptions_badbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/
	exceptions_failbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/
	exceptions_null.cc: Likewise.
	* testsuite/27_io/basic_ostream/put/char/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/seekp/char/
	exceptions_badbit_throw.cc: Likewise.
	* testsuite/27_io/basic_ostream/sentry/char/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/write/char/1.cc: Likewise.

From-SVN: r94129
parent 69029c61
2005-01-23 Paolo Carlini <pcarlini@suse.de> 2005-01-23 Paolo Carlini <pcarlini@suse.de>
* testsuite/27_io/basic_ostream/cons/wchar_t/9827.cc: New.
* testsuite/27_io/basic_ostream/endl/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_ostream/ends/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_ostream/ends/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc: Likewise.
* testsuite/27_io/basic_ostream/flush/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_ostream/flush/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostream/flush/wchar_t/
exceptions_badbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
wchar_t/3.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
wchar_t/4.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
wchar_t/4402.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
wchar_t/5.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
wchar_t/6.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
wchar_t/9555-oa.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
wchar_t/exceptions_badbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
wchar_t/exceptions_failbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/
wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/
wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/
wchar_t/3.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/
wchar_t/4.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/
wchar_t/5.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/
wchar_t/6.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/
wchar_t/9555-oc.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/
wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/
wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/
wchar_t/3.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/
wchar_t/4.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/
wchar_t/5.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/
wchar_t/9318-out.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/
wchar_t/9424-out.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/
wchar_t/9555-oo.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
error_failbit.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_badbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_failbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_ostream/put/char/1.cc: Likewise.
* testsuite/27_io/basic_ostream/put/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_ostream/seekp/char/
exceptions_badbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/seekp/wchar_t/
2346-fstream.cc: Likewise.
* testsuite/27_io/basic_ostream/seekp/wchar_t/
2346-sstream.cc: Likewise.
* testsuite/27_io/basic_ostream/seekp/wchar_t/
exceptions_badbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/sentry/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_ostream/sentry/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostream/tellp/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_ostream/tellp/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_ostream/tellp/wchar_t/
exceptions_badbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/write/wchar_t/1.cc: Likewise.
* testsuite/data/wostream_inserter_char-1.tst: Likewise.
* testsuite/data/wostream_inserter_char-1.txt: Likewise.
* testsuite/data/wostream_inserter_other-1.tst: Likewise.
* testsuite/data/wostream_inserter_other-2.tst: Likewise.
* testsuite/data/wostream_seeks-1.tst: Likewise.
* testsuite/27_io/basic_ostream/endl/char/1.cc: Minor tweaks.
* testsuite/27_io/basic_ostream/ends/char/1.cc: Likewise.
* testsuite/27_io/basic_ostream/exceptions/char/9561.cc: Likewise.
* testsuite/27_io/basic_ostream/flush/char/1.cc: Likewise.
* testsuite/27_io/basic_ostream/flush/char/2.cc: Likewise.
* testsuite/27_io/basic_ostream/flush/char/
exceptions_badbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
char/2.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
char/3.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
char/4.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
char/4402.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
char/5.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/
char/6.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/
char/4.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
2.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
5.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
error_failbit.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_badbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_failbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_ostream/put/char/1.cc: Likewise.
* testsuite/27_io/basic_ostream/seekp/char/
exceptions_badbit_throw.cc: Likewise.
* testsuite/27_io/basic_ostream/sentry/char/2.cc: Likewise.
* testsuite/27_io/basic_ostream/write/char/1.cc: Likewise.
2005-01-23 Paolo Carlini <pcarlini@suse.de>
* include/tr1/type_traits (aligned_storage): Use __aligned__ instead * include/tr1/type_traits (aligned_storage): Use __aligned__ instead
of aligned. of aligned.
......
// Copyright (C) 2005 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.
#include <ostream>
#include <streambuf>
#include <testsuite_hooks.h>
// libstdc++/9827
class Buf : public std::wstreambuf
{
};
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
Buf buf;
wostream stream(&buf);
stream << 1;
VERIFY(!stream.good());
}
int main()
{
test01();
return 0;
}
// 1999-07-22 bkoz // 1999-07-22 bkoz
// Copyright (C) 1994, 1999, 2000, 2003 Free Software Foundation, Inc. // Copyright (C) 1994, 1999, 2000, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -30,7 +30,6 @@ void test01(void) ...@@ -30,7 +30,6 @@ void test01(void)
const char str_lit01[] = " venice "; const char str_lit01[] = " venice ";
const std::string str01(" santa barbara "); const std::string str01(" santa barbara ");
std::string str02(str_lit01);
std::string str04; std::string str04;
std::string str05; std::string str05;
......
// Copyright (C) 2005 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.6.2.7 standard basic_ostream manipulators
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
void test01(void)
{
bool test __attribute__((unused)) = true;
const wchar_t str_lit01[] = L" venice ";
const std::wstring str01(L" santa barbara ");
std::wstring str04;
std::wstring str05;
std::wostringstream oss01(str01);
std::wostringstream oss02;
typedef std::wostringstream::traits_type traits_type;
// template<_CharT, _Traits>
// basic_ostream<_CharT, _Traits>& ends(basic_ostream<_Char, _Traits>& os)
oss01 << std::endl;
str04 = oss01.str();
VERIFY( str04.size() == str01.size() );
oss02 << std::endl;
str05 = oss02.str();
VERIFY( str05.size() == 1 );
}
int main()
{
test01();
return 0;
}
// 1999-07-22 bkoz // 1999-07-22 bkoz
// Copyright (C) 1994, 1999, 2000, 2003 Free Software Foundation, Inc. // Copyright (C) 1994, 1999, 2000, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -30,13 +30,11 @@ void test01(void) ...@@ -30,13 +30,11 @@ void test01(void)
const char str_lit01[] = " venice "; const char str_lit01[] = " venice ";
const std::string str01(" santa barbara "); const std::string str01(" santa barbara ");
std::string str02(str_lit01);
std::string str04; std::string str04;
std::string str05; std::string str05;
std::ostringstream oss01(str01); std::ostringstream oss01(str01);
std::ostringstream oss02; std::ostringstream oss02;
typedef std::ostringstream::traits_type traits_type;
// template<_CharT, _Traits> // template<_CharT, _Traits>
// basic_ostream<_CharT, _Traits>& ends(basic_ostream<_Char, _Traits>& os) // basic_ostream<_CharT, _Traits>& ends(basic_ostream<_Char, _Traits>& os)
......
// Copyright (C) 2005 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.6.2.7 standard basic_ostream manipulators
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
void test01(void)
{
bool test __attribute__((unused)) = true;
const wchar_t str_lit01[] = L" venice ";
const std::wstring str01(L" santa barbara ");
std::wstring str04;
std::wstring str05;
std::wostringstream oss01(str01);
std::wostringstream oss02;
// template<_CharT, _Traits>
// basic_ostream<_CharT, _Traits>& ends(basic_ostream<_Char, _Traits>& os)
oss01 << std::ends;
str04 = oss01.str();
VERIFY( str04.size() == str01.size() );
oss02 << std::ends;
str05 = oss02.str();
VERIFY( str05.size() == 1 );
VERIFY( str05[0] == wchar_t() );
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2005 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.6.2.7 standard basic_ostream manipulators
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
// based vaguely on this:
// http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00109.html
void test02()
{
using namespace std;
typedef wostringstream::int_type int_type;
bool test __attribute__((unused)) = true;
wostringstream osst_01;
const wstring str_00(L"herbie_hancock");
int_type len1 = str_00.size();
osst_01 << str_00;
VERIFY( static_cast<int_type>(osst_01.str().size()) == len1 );
osst_01 << ends;
const wstring str_01(L"speak like a child");
int_type len2 = str_01.size();
osst_01 << str_01;
int_type len3 = osst_01.str().size();
VERIFY( len1 < len3 );
VERIFY( len3 == len1 + len2 + 1 );
osst_01 << ends;
const wstring str_02(L"+ inventions and dimensions");
int_type len4 = str_02.size();
osst_01 << str_02;
int_type len5 = osst_01.str().size();
VERIFY( len3 < len5 );
VERIFY( len5 == len3 + len4 + 1 );
}
int main()
{
test02();
return 0;
}
// 2003-03-08 Jerry Quinn <jlquinn@optonline.net> // 2003-03-08 Jerry Quinn <jlquinn@optonline.net>
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -27,10 +27,12 @@ struct foobar: std::exception { }; ...@@ -27,10 +27,12 @@ struct foobar: std::exception { };
struct buf: std::streambuf struct buf: std::streambuf
{ {
virtual int_type overflow (int_type) { virtual int_type
throw foobar (); overflow(int_type)
return -1; {
} throw foobar();
return int_type();
}
}; };
void test01() void test01()
...@@ -40,22 +42,25 @@ void test01() ...@@ -40,22 +42,25 @@ void test01()
buf b; buf b;
std::ostream strm (&b); std::ostream strm (&b);
strm.exceptions (std::ios::badbit); strm.exceptions(std::ios::badbit);
try { try
strm << std::endl; {
} strm << std::endl;
catch (foobar) { }
// strm should throw foobar and not do anything else catch(foobar)
VERIFY(strm.bad()); {
return; // strm should throw foobar and not do anything else
} VERIFY(strm.bad());
catch (...) { return;
VERIFY(false); }
return; catch(...)
} {
VERIFY( false );
return;
}
VERIFY(false); VERIFY( false );
} }
int main() int main()
......
// Copyright (C) 2005 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.
#include <ostream>
#include <streambuf>
#include <testsuite_hooks.h>
// libstdc++/9561
struct foobar: std::exception { };
struct buf: std::wstreambuf
{
virtual int_type
overflow(int_type)
{
throw foobar();
return int_type();
}
};
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
buf b;
std::wostream strm(&b);
strm.exceptions(std::wios::badbit);
try
{
strm << std::endl;
}
catch(foobar)
{
// strm should throw foobar and not do anything else
VERIFY(strm.bad());
return;
}
catch(...)
{
VERIFY( false );
return;
}
VERIFY( false );
}
int main()
{
test01();
return 0;
}
// 1999-07-22 bkoz // 1999-07-22 bkoz
// Copyright (C) 1994, 1999, 2000, 2003 Free Software Foundation, Inc. // Copyright (C) 1994, 1999, 2000, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -30,13 +30,11 @@ void test01(void) ...@@ -30,13 +30,11 @@ void test01(void)
const char str_lit01[] = " venice "; const char str_lit01[] = " venice ";
const std::string str01(" santa barbara "); const std::string str01(" santa barbara ");
std::string str02(str_lit01);
std::string str04; std::string str04;
std::string str05; std::string str05;
std::ostringstream oss01(str01); std::ostringstream oss01(str01);
std::ostringstream oss02; std::ostringstream oss02;
typedef std::ostringstream::traits_type traits_type;
// template<_CharT, _Traits> // template<_CharT, _Traits>
// basic_ostream<_CharT, _Traits>& flush(basic_ostream<_Char, _Traits>& os) // basic_ostream<_CharT, _Traits>& flush(basic_ostream<_Char, _Traits>& os)
......
// 2003-09-22 Petur Runolfsson <peturr02@ru.is> // 2003-09-22 Petur Runolfsson <peturr02@ru.is>
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
void test02() void test02()
{ {
bool test = true; bool test __attribute__((unused)) = true;
__gnu_test::sync_streambuf buf; __gnu_test::sync_streambuf buf;
std::ostream os(&buf); std::ostream os(&buf);
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -54,7 +54,7 @@ void test01() ...@@ -54,7 +54,7 @@ void test01()
} }
catch (...) catch (...)
{ {
VERIFY(false); VERIFY( false );
} }
} }
......
// Copyright (C) 2005 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.6.2.7 standard basic_ostream manipulators
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
void test01(void)
{
bool test __attribute__((unused)) = true;
const wchar_t str_lit01[] = L" venice ";
const std::wstring str01(L" santa barbara ");
std::wstring str04;
std::wstring str05;
std::wostringstream oss01(str01);
std::wostringstream oss02;
// template<_CharT, _Traits>
// basic_ostream<_CharT, _Traits>& flush(basic_ostream<_Char, _Traits>& os)
oss01.flush();
str04 = oss01.str();
VERIFY( str04.size() == str01.size() );
oss02.flush();
str05 = oss02.str();
VERIFY( str05.size() == 0 );
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2005 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.6.2.6 Unformatted output functions
//
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// basic_ostream::flush() does not behave as an unformatted output function.
#include <ostream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
void test02()
{
bool test __attribute__((unused)) = true;
__gnu_test::sync_wstreambuf buf;
std::wostream os(&buf);
__gnu_test::sync_wstreambuf buf_tie;
std::wostream os_tie(&buf_tie);
// No sentry should be constructed so os.tie()->flush() should not be
// called.
os.tie(&os_tie);
os.flush();
VERIFY( os.good() );
VERIFY( buf.sync_called() );
VERIFY( !buf_tie.sync_called() );
// os.rdbuf()->pubsync() should be called even if !os.good().
os.setstate(std::ios_base::eofbit);
os.flush();
VERIFY( os.rdstate() == std::ios_base::eofbit );
VERIFY( buf.sync_called() );
VERIFY( !buf_tie.sync_called() );
}
int main()
{
test02();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <ostream>
#include <streambuf>
#include <sstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
using namespace std;
void test01()
{
bool test __attribute__((unused)) = true;
__gnu_test::fail_wstreambuf bib;
wostream stream(&bib);
stream.exceptions(ios_base::badbit);
try
{
stream.flush();
VERIFY( false );
}
catch (const __gnu_test::positioning_error&)
{
// stream should set badbit and rethrow facet_error.
VERIFY( stream.bad() );
VERIFY( (stream.rdstate() & ios_base::failbit) == 0 );
VERIFY( !stream.eof() );
}
catch (...)
{
VERIFY( false );
}
}
// libstdc++/9546
int main()
{
test01();
return 0;
}
// 1999-11-15 Kevin Ediger <kediger@licor.com> // 1999-11-15 Kevin Ediger <kediger@licor.com>
// test the floating point inserters (facet num_put) // test the floating point inserters (facet num_put)
// Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -26,11 +26,10 @@ ...@@ -26,11 +26,10 @@
#include <limits> #include <limits>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using namespace std;
void void
test02() test02()
{ {
using namespace std;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
// Make sure we can output a long float in fixed format // Make sure we can output a long float in fixed format
......
// 1999-11-15 Kevin Ediger <kediger@licor.com> // 1999-11-15 Kevin Ediger <kediger@licor.com>
// test the floating point inserters (facet num_put) // test the floating point inserters (facet num_put)
// Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -23,16 +23,16 @@ ...@@ -23,16 +23,16 @@
#include <limits> #include <limits>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using namespace std;
template<typename T> template<typename T>
bool bool
test03_check(T n) test03_check(T n)
{ {
using namespace std;
bool test __attribute__((unused)) = true;
stringbuf strbuf; stringbuf strbuf;
ostream o(&strbuf); ostream o(&strbuf);
const char *expect; const char *expect;
bool test __attribute__((unused)) = true;
if (numeric_limits<T>::digits + 1 == 16) if (numeric_limits<T>::digits + 1 == 16)
expect = "177777 ffff"; expect = "177777 ffff";
......
// 1999-11-15 Kevin Ediger <kediger@licor.com> // 1999-11-15 Kevin Ediger <kediger@licor.com>
// test the floating point inserters (facet num_put) // test the floating point inserters (facet num_put)
// Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -23,16 +23,16 @@ ...@@ -23,16 +23,16 @@
#include <sstream> #include <sstream>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using namespace std;
// libstdc++/3655 // libstdc++/3655
int int
test04() test04()
{ {
stringbuf strbuf1, strbuf2; using namespace std;
ostream o1(&strbuf1), o2(&strbuf2);
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
stringbuf strbuf1, strbuf2;
ostream o1(&strbuf1), o2(&strbuf2);
o1 << hex << showbase << setw(6) << internal << 0xff; o1 << hex << showbase << setw(6) << internal << 0xff;
VERIFY( strbuf1.str() == "0x ff" ); VERIFY( strbuf1.str() == "0x ff" );
......
// 1999-11-15 Kevin Ediger <kediger@licor.com> // 1999-11-15 Kevin Ediger <kediger@licor.com>
// test the floating point inserters (facet num_put) // test the floating point inserters (facet num_put)
// Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
#include <limits> #include <limits>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using namespace std;
void void
test02() test02()
{ {
using namespace std;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
// make sure we can output a very long float // make sure we can output a very long float
long double val = 1.2345678901234567890123456789e+1000L; long double val = 1.2345678901234567890123456789e+1000L;
int prec = numeric_limits<long double>::digits10; int prec = numeric_limits<long double>::digits10;
...@@ -47,7 +47,7 @@ test02() ...@@ -47,7 +47,7 @@ test02()
cout << "expect: " << largebuf << endl; cout << "expect: " << largebuf << endl;
cout << "result: " << os.str() << endl; cout << "result: " << os.str() << endl;
#endif #endif
VERIFY(os && os.str() == largebuf); VERIFY( os && os.str() == largebuf );
// Make sure we can output a long float in fixed format // Make sure we can output a long float in fixed format
// without seg-faulting (libstdc++/4402) // without seg-faulting (libstdc++/4402)
...@@ -63,7 +63,7 @@ test02() ...@@ -63,7 +63,7 @@ test02()
cout << "expect: " << largebuf << endl; cout << "expect: " << largebuf << endl;
cout << "result: " << os2.str() << endl; cout << "result: " << os2.str() << endl;
#endif #endif
VERIFY(os2 && os2.str() == largebuf); VERIFY( os2 && os2.str() == largebuf );
} }
int int
......
// 1999-11-15 Kevin Ediger <kediger@licor.com> // 1999-11-15 Kevin Ediger <kediger@licor.com>
// test the floating point inserters (facet num_put) // test the floating point inserters (facet num_put)
// Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
#include <limits> #include <limits>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using namespace std;
void void
test05() test05()
{ {
using namespace std;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
double pi = 3.14159265358979323846; double pi = 3.14159265358979323846;
ostringstream ostr; ostringstream ostr;
ostr.precision(20); ostr.precision(20);
......
// 1999-11-15 Kevin Ediger <kediger@licor.com> // 1999-11-15 Kevin Ediger <kediger@licor.com>
// test the floating point inserters (facet num_put) // test the floating point inserters (facet num_put)
// Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -25,13 +25,13 @@ ...@@ -25,13 +25,13 @@
#include <limits> #include <limits>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using namespace std;
// libstdc++/9151 // libstdc++/9151
int void
test06() test06()
{ {
using namespace std;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
int prec = numeric_limits<double>::digits10 + 2; int prec = numeric_limits<double>::digits10 + 2;
double oval = numeric_limits<double>::min(); double oval = numeric_limits<double>::min();
...@@ -43,7 +43,6 @@ test06() ...@@ -43,7 +43,6 @@ test06()
double ival; double ival;
istr >> ival; istr >> ival;
VERIFY( abs(oval-ival)/oval < DBL_EPSILON ); VERIFY( abs(oval-ival)/oval < DBL_EPSILON );
return 0;
} }
int int
......
// Copyright (C) 2005 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.
#include <iostream>
#include <iomanip>
#include <locale>
#include <sstream>
#include <limits>
#include <testsuite_hooks.h>
void
test02()
{
using namespace std;
bool test __attribute__((unused)) = true;
// Make sure we can output a long float in fixed format
// without seg-faulting (libstdc++/4402)
double val2 = 3.5e230;
wostringstream os2;
os2.precision(3);
os2.setf(wios::fixed);
// Check it can be done in a locale with grouping on.
locale loc2 = __gnu_test::try_named_locale("de_DE");
os2.imbue(loc2);
os2 << fixed << setprecision(3) << val2 << endl;
os2 << endl;
os2 << fixed << setprecision(1) << val2 << endl;
}
int
main()
{
test02();
return 0;
}
// Copyright (C) 2005 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.
#include <sstream>
#include <limits>
#include <testsuite_hooks.h>
template<typename T>
bool
test03_check(T n)
{
using namespace std;
bool test __attribute__((unused)) = true;
wstringbuf strbuf;
wostream o(&strbuf);
const wchar_t *expect;
if (numeric_limits<T>::digits + 1 == 16)
expect = L"177777 ffff";
else if (numeric_limits<T>::digits + 1 == 32)
expect = L"37777777777 ffffffff";
else if (numeric_limits<T>::digits + 1 == 64)
expect = L"1777777777777777777777 ffffffffffffffff";
else
expect = L"wow, you've got some big numbers here";
o << oct << n << L' ' << hex << n;
VERIFY ( strbuf.str() == expect );
return test;
}
void
test03()
{
short s = -1;
int i = -1;
long l = -1;
test03_check(s);
test03_check(i);
test03_check(l);
}
int
main()
{
test03();
return 0;
}
// Copyright (C) 2005 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.
#include <iomanip>
#include <sstream>
#include <testsuite_hooks.h>
// libstdc++/3655
int
test04()
{
using namespace std;
bool test __attribute__((unused)) = true;
wstringbuf strbuf1, strbuf2;
wostream o1(&strbuf1), o2(&strbuf2);
o1 << hex << showbase << setw(6) << internal << 0xff;
VERIFY( strbuf1.str() == L"0x ff" );
// ... vs internal-adjusted const char*-type objects
o2 << hex << showbase << setw(6) << internal << L"0xff";
VERIFY( strbuf2.str() == L" 0xff" );
return 0;
}
int
main()
{
test04();
return 0;
}
// Copyright (C) 2005 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.
#include <cstdio> // for swprintf
#include <iostream>
#include <iomanip>
#include <sstream>
#include <limits>
#include <testsuite_hooks.h>
void
test02()
{
using namespace std;
bool test __attribute__((unused)) = true;
// make sure we can output a very long float
long double val = 1.2345678901234567890123456789e+1000L;
int prec = numeric_limits<long double>::digits10;
wostringstream os;
os.precision(prec);
os.setf(wios::scientific);
os << val;
wchar_t largebuf[512];
swprintf(largebuf, 512, L"%.*Le", prec, val);
#ifdef TEST_NUMPUT_VERBOSE
cout << "expect: " << largebuf << endl;
cout << "result: " << os.str() << endl;
#endif
VERIFY( os && os.str() == largebuf );
// Make sure we can output a long float in fixed format
// without seg-faulting (libstdc++/4402)
double val2 = 3.5e230;
wostringstream os2;
os2.precision(3);
os2.setf(wios::fixed);
os2 << val2;
swprintf(largebuf, 512, L"%.*f", 3, val2);
#ifdef TEST_NUMPUT_VERBOSE
cout << "expect: " << largebuf << endl;
cout << "result: " << os2.str() << endl;
#endif
VERIFY( os2 && os2.str() == largebuf );
}
int
main()
{
test02();
return 0;
}
// Copyright (C) 2005 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.
#include <cmath> // for abs
#include <cfloat> // for DBL_EPSILON
#include <sstream>
#include <limits>
#include <testsuite_hooks.h>
void
test05()
{
using namespace std;
bool test __attribute__((unused)) = true;
double pi = 3.14159265358979323846;
wostringstream ostr;
ostr.precision(20);
ostr << pi;
wstring sval = ostr.str();
wistringstream istr(sval);
double d;
istr >> d;
VERIFY( abs(pi-d)/pi < DBL_EPSILON );
}
int
main()
{
test05();
return 0;
}
// Copyright (C) 2005 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.
#include <cmath> // for abs
#include <cfloat> // for DBL_EPSILON
#include <sstream>
#include <limits>
#include <testsuite_hooks.h>
// libstdc++/9151
void
test06()
{
using namespace std;
bool test __attribute__((unused)) = true;
int prec = numeric_limits<double>::digits10 + 2;
double oval = numeric_limits<double>::min();
wstringstream ostr;
ostr.precision(prec);
ostr << oval;
wstring sval = ostr.str();
wistringstream istr(sval);
double ival;
istr >> ival;
VERIFY( abs(oval-ival)/oval < DBL_EPSILON );
}
int
main()
{
test06();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <ostream>
#include <streambuf>
#include <testsuite_hooks.h>
struct buf: std::wstreambuf
{
virtual int_type overflow(int_type)
{ throw 0; }
};
template<typename T>
void testthrow(T arg)
{
bool test __attribute__((unused)) = true;
buf b;
std::wostream os(&b);
os.exceptions(std::wios::badbit);
try
{
os << arg;
}
catch(int)
{
// Expected return is zero.
VERIFY( os.bad() );
}
catch(...)
{
VERIFY( false );
}
}
int main()
{
bool b = true;
short s = -4;
unsigned short us = 4;
int i = -45;
unsigned int ui = 45;
long l = -456;
unsigned long ul = 456;
float f = 3.4;
double d = 3.45;
long double ld = 3.456;
testthrow(b);
testthrow(s);
testthrow(us);
testthrow(i);
testthrow(ui);
testthrow(l);
testthrow(ul);
testthrow(f);
testthrow(d);
testthrow(ld);
return 0;
}
// Copyright (C) 2005 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.
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
// libstdc++/9561
template<typename T>
void test_badbit()
{
using namespace std;
bool test __attribute__((unused)) = true;
locale loc(locale::classic(), new __gnu_test::fail_num_put_wchar_t);
wostringstream stream(L"jaylib - champion sound");
stream.imbue(loc);
stream.exceptions(ios_base::badbit);
VERIFY( stream.rdstate() == ios_base::goodbit );
try
{
T i = T();
stream << i;
VERIFY( false );
}
catch (const __gnu_test::facet_error&)
{
// stream should set badbit and rethrow facet_error.
VERIFY( stream.bad() );
VERIFY( (stream.rdstate() & ios_base::failbit) == 0 );
VERIFY( !stream.eof() );
}
catch (...)
{
VERIFY( false );
}
}
int main()
{
test_badbit<bool>();
test_badbit<short>();
test_badbit<unsigned short>();
test_badbit<int>();
test_badbit<unsigned int>();
test_badbit<long>();
test_badbit<unsigned long>();
test_badbit<float>();
test_badbit<double>();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <sstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
// libstdc++/10093
template<typename T>
void test_failbit()
{
using namespace std;
bool test __attribute__((unused)) = true;
locale loc(locale::classic(), new __gnu_test::fail_num_put_wchar_t);
wostringstream stream(L"jaylib - champion sound");
stream.imbue(loc);
stream.exceptions(ios_base::failbit);
try
{
T i = T();
stream << i;
}
catch (const ios_base::failure&)
{ VERIFY( false ); }
catch(...)
{ VERIFY( false ); }
// stream should set badbit.
VERIFY( stream.bad() );
VERIFY( (stream.rdstate() & ios_base::failbit) == 0 );
VERIFY( !stream.eof() );
}
int main()
{
test_failbit<bool>();
test_failbit<short>();
test_failbit<unsigned short>();
test_failbit<int>();
test_failbit<unsigned int>();
test_failbit<long>();
test_failbit<unsigned long>();
test_failbit<float>();
test_failbit<double>();
return 0;
}
// 1999-08-16 bkoz // 1999-08-16 bkoz
// Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation // Copyright (C) 1999, 2000, 2002, 2003, 2005 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -31,12 +31,9 @@ test04() ...@@ -31,12 +31,9 @@ test04()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::string str_01; std::string str_01;
const std::string str_02("coltrane playing 'softly as a morning sunrise'");
const std::string str_03("coltrane");
std::string str_tmp; std::string str_tmp;
const int i_max=250; const int i_max=250;
std::ostringstream oss_01(std::ios_base::out);
std::ostringstream oss_02(str_01, std::ios_base::out); std::ostringstream oss_02(str_01, std::ios_base::out);
std::ios_base::iostate statefail; std::ios_base::iostate statefail;
......
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.5.4 basic_ostream character inserters
#include <string>
#include <ostream>
#include <fstream>
#include <testsuite_hooks.h>
// ofstream
void test01()
{
std::wstring str01;
const int size = 1000;
const char name_02[] = "wostream_inserter_char-1.txt";
// initialize string
for(int i=0 ; i < size; i++) {
str01 += L'1';
str01 += L'2';
str01 += L'3';
str01 += L'4';
str01 += L'5';
str01 += L'6';
str01 += L'7';
str01 += L'8';
str01 += L'9';
str01 += L'\n';
}
std::wofstream f(name_02);
f << str01;
f.close();
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.5.4 basic_ostream character inserters
#include <string>
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
// ostringstream width() != zero
// left
void
test02(void)
{
bool test __attribute__((unused)) = true;
std::wstring tmp;
std::wstring str01 = L"";
std::wostringstream oss01;
oss01.width(5);
oss01.fill(L'0');
oss01.flags(std::ios_base::left);
oss01 << str01;
tmp = oss01.str();
VERIFY( tmp == L"00000" );
std::wstring str02 = L"1";
std::wostringstream oss02;
oss02.width(5);
oss02.fill(L'0');
oss02.flags(std::ios_base::left);
oss02 << str02;
tmp = oss02.str();
VERIFY( tmp == L"10000" );
std::wstring str03 = L"909909";
std::wostringstream oss03;
oss03.width(5);
oss03.fill(L'0');
oss03.flags(std::ios_base::left);
oss03 << str03;
tmp = oss03.str();
VERIFY( tmp == L"909909" );
}
int main()
{
test02();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.5.4 basic_ostream character inserters
#include <string>
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
// width() != zero
// right
void test03(void)
{
bool test __attribute__((unused)) = true;
std::wstring tmp;
std::wstring str01 = L"";
std::wostringstream oss01;
oss01.width(5);
oss01.fill(L'0');
oss01.flags(std::ios_base::right);
oss01 << str01;
tmp = oss01.str();
VERIFY( tmp == L"00000" );
std::wstring str02 = L"1";
std::wostringstream oss02;
oss02.width(5);
oss02.fill(L'0');
oss02.flags(std::ios_base::right);
oss02 << str02;
tmp = oss02.str();
VERIFY( tmp == L"00001" );
std::wstring str03 = L"909909";
std::wostringstream oss03;
oss03.width(5);
oss03.fill(L'0');
oss03.flags(std::ios_base::right);
oss03 << str03;
tmp = oss03.str();
VERIFY( tmp == L"909909" );
}
int main()
{
test03();
return 0;
}
// 1999-08-16 bkoz
// Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation
//
// 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.6.2.5.4 basic_ostream character inserters
#include <string>
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
// stringstream and large strings
void
test04()
{
bool test __attribute__((unused)) = true;
std::wstring str_01;
std::wstring str_tmp;
const int i_max=250;
std::wostringstream oss_02(str_01, std::ios_base::out);
std::ios_base::iostate statefail;
statefail = std::ios_base::failbit;
// template<_CharT, _Traits>
// basic_ostream& operator<<(ostream&, const wchar_t*)
for (int i = 0; i < i_max; ++i)
oss_02 << L"Test: " << i << std::endl;
str_tmp = oss_02.str();
VERIFY( !oss_02.bad() );
VERIFY( oss_02.good() );
VERIFY( str_tmp != str_01 );
VERIFY( str_tmp.size() == 2390 );
}
int main()
{
test04();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.5.4 basic_ostream character inserters
#include <string>
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
// ostringstream and large strings number 2
void
test05()
{
bool test __attribute__((unused)) = true;
std::wstring str05, str10;
typedef std::wostream::pos_type pos_type;
typedef std::wostream::off_type off_type;
std::wstring str01;
const int size = 1000;
// initialize string
for(int i=0 ; i < size; i++) {
str01 += L'1';
str01 += L'2';
str01 += L'3';
str01 += L'4';
str01 += L'5';
str01 += L'6';
str01 += L'7';
str01 += L'8';
str01 += L'9';
str01 += L'\n';
}
// test 1: out
std::wostringstream sstr01(str01, std::ios_base::out);
std::wostringstream sstr02;
sstr02 << str01;
str05 = sstr01.str();
str10 = sstr02.str();
VERIFY( str05 == str01 );
VERIFY( str10 == str01 );
// test 2: in | out
std::wostringstream sstr04(str01, std::ios_base::out | std::ios_base::in);
std::wostringstream sstr05(std::ios_base::in | std::ios_base::out);
sstr05 << str01;
str05 = sstr04.str();
str10 = sstr05.str();
VERIFY( str05 == str01 );
VERIFY( str10 == str01 );
}
int main()
{
test05();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.5.4 basic_ostream character inserters
#include <string>
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
// ostringstream and positioning, multiple writes
// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00326.html
void test06()
{
bool test __attribute__((unused)) = true;
const wchar_t carray01[] = L"mos def & talib kweli are black star";
// normal
std::wostringstream ostr1(L"mos def");
VERIFY( ostr1.str() == L"mos def" );
ostr1 << L" & talib kweli"; // should overwrite first part of buffer
VERIFY( ostr1.str() == L" & talib kweli" );
ostr1 << L" are black star"; // should append to string from above
VERIFY( ostr1.str() != carray01 );
VERIFY( ostr1.str() == L" & talib kweli are black star" );
// appending
std::wostringstream ostr2(L"blackalicious",
std::ios_base::out | std::ios_base::ate);
VERIFY( ostr2.str() == L"blackalicious" );
ostr2 << L" NIA "; // should not overwrite first part of buffer
VERIFY( ostr2.str() == L"blackalicious NIA " );
ostr2 << L"4: deception (5:19)"; // should append to full string from above
VERIFY( ostr2.str() == L"blackalicious NIA 4: deception (5:19)" );
}
int main()
{
test06();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <ostream>
#include <streambuf>
#include <testsuite_hooks.h>
struct buf: std::wstreambuf
{
virtual int_type overflow(int_type)
{ throw 0; }
};
template<typename T>
void testthrow(T arg)
{
bool test __attribute__((unused)) = true;
buf b;
std::wostream os(&b);
os.exceptions(std::wios::badbit);
try
{
os << arg;
}
catch(int)
{
// Expected return is zero.
VERIFY( os.bad() );
}
catch(...)
{
VERIFY( false );
}
}
int main()
{
wchar_t c = L'a';
const wchar_t* ccp = L"governor ann richards";
testthrow(c);
testthrow(ccp);
return 0;
}
// 1999-08-16 bkoz // 1999-08-16 bkoz
// 1999-11-01 bkoz // 1999-11-01 bkoz
// Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -49,12 +49,12 @@ test03(void) ...@@ -49,12 +49,12 @@ test03(void)
ifstream in(TEST_IN); ifstream in(TEST_IN);
ofstream out(TEST_OUT); ofstream out(TEST_OUT);
out << in.rdbuf(); out << in.rdbuf();
in.seekg(0,ios_base::beg); in.seekg(0, ios_base::beg);
out.seekp(0,ios_base::beg); out.seekp(0, ios_base::beg);
rs = in.tellg(); rs = in.tellg();
ws = out.tellp(); ws = out.tellp();
in.seekg(0,ios_base::end); in.seekg(0, ios_base::end);
out.seekp(0,ios_base::end); out.seekp(0, ios_base::end);
i_read = in.tellg() - rs; i_read = in.tellg() - rs;
i_wrote = out.tellp() - ws; i_wrote = out.tellp() - ws;
in.close(); in.close();
......
...@@ -41,7 +41,7 @@ std::ios_base& func3(std::ios_base&) ...@@ -41,7 +41,7 @@ std::ios_base& func3(std::ios_base&)
template<typename T> template<typename T>
void test(T& (*f)(T&)) void test(T& (*f)(T&))
{ {
bool test = true; bool test __attribute__((unused)) = true;
__gnu_test::sync_streambuf buf; __gnu_test::sync_streambuf buf;
std::ostream os(&buf); std::ostream os(&buf);
......
...@@ -42,8 +42,8 @@ void test5() ...@@ -42,8 +42,8 @@ void test5()
stream << &sbuf; stream << &sbuf;
VERIFY(stream.rdstate() & ios_base::failbit); VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY((stream.rdstate() & ios_base::badbit) == 0); VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
} }
void test7() void test7()
...@@ -54,8 +54,8 @@ void test7() ...@@ -54,8 +54,8 @@ void test7()
stream << &bib; stream << &bib;
VERIFY(stream.rdstate() & ios_base::failbit); VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY((stream.rdstate() & ios_base::badbit) == 0); VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
} }
// libstdc++/9371 // libstdc++/9371
......
...@@ -48,8 +48,8 @@ void test13() ...@@ -48,8 +48,8 @@ void test13()
catch (...) catch (...)
{ VERIFY(false); } { VERIFY(false); }
VERIFY(stream.rdstate() & ios_base::failbit); VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY((stream.rdstate() & ios_base::badbit) == 0); VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
} }
void test15() void test15()
...@@ -66,8 +66,8 @@ void test15() ...@@ -66,8 +66,8 @@ void test15()
catch (...) catch (...)
{ VERIFY(false); } { VERIFY(false); }
VERIFY(stream.rdstate() & ios_base::failbit); VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY((stream.rdstate() & ios_base::badbit) == 0); VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
} }
// libstdc++/9371 // libstdc++/9371
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -44,17 +44,17 @@ void test9() ...@@ -44,17 +44,17 @@ void test9()
try try
{ {
stream << &sbuf; stream << &sbuf;
VERIFY(false); VERIFY( false );
} }
catch (ios_base::failure&) catch (ios_base::failure&)
{ VERIFY(false); } { VERIFY( false ); }
catch (__gnu_test::overflow_error&) catch (__gnu_test::overflow_error&)
{ } { }
catch (...) catch (...)
{ VERIFY(false); } { VERIFY( false ); }
VERIFY(stream.rdstate() & ios_base::failbit); VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY((stream.rdstate() & ios_base::badbit) == 0); VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
} }
void test11() void test11()
...@@ -67,17 +67,17 @@ void test11() ...@@ -67,17 +67,17 @@ void test11()
try try
{ {
stream << &bib; stream << &bib;
VERIFY(false); VERIFY( false );
} }
catch (ios_base::failure&) catch (ios_base::failure&)
{ VERIFY(false); } { VERIFY( false ); }
catch (__gnu_test::underflow_error&) catch (__gnu_test::underflow_error&)
{ } { }
catch (...) catch (...)
{ VERIFY(false); } { VERIFY( false ); }
VERIFY(stream.rdstate() & ios_base::failbit); VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY((stream.rdstate() & ios_base::badbit) == 0); VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
} }
// libstdc++/9371 // libstdc++/9371
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -31,32 +31,34 @@ ...@@ -31,32 +31,34 @@
#include <sstream> #include <sstream>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using namespace std;
void test1() void test1()
{ {
using namespace std;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
ostringstream stream; ostringstream stream;
stream << static_cast<streambuf*>(NULL); stream << static_cast<streambuf*>(NULL);
VERIFY(stream.rdstate() & ios_base::badbit); VERIFY( stream.rdstate() & ios_base::badbit );
} }
void test3() void test3()
{ {
using namespace std;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
ostringstream stream; ostringstream stream;
stream.exceptions(ios_base::badbit); stream.exceptions(ios_base::badbit);
try try
{ {
stream << static_cast<streambuf*>(NULL); stream << static_cast<streambuf*>(NULL);
VERIFY(false); VERIFY( false );
} }
catch (ios_base::failure&) catch (ios_base::failure&)
{ {
} }
VERIFY(stream.rdstate() & ios_base::badbit); VERIFY( stream.rdstate() & ios_base::badbit );
} }
// libstdc++/9371 // libstdc++/9371
......
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.5.4 basic_ostream character inserters
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
#include <ostream>
#include <sstream>
#include <fstream>
#include <testsuite_hooks.h>
const int size = 1000;
const char name_01[] = "wostream_inserter_other-1.tst";
const char name_02[] = "wostream_inserter_other-1.txt";
const char name_03[] = "wostream_inserter_other-2.tst";
const char name_04[] = "wostream_inserter_other-2.txt";
// fstream
void
test02()
{
typedef std::ios_base::iostate iostate;
bool test __attribute__((unused)) = true;
// basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sb)
// filebuf-> NULL
std::wifstream f_in1(name_01);
std::wofstream f_out1(name_02);
std::wstringbuf* strbuf01 = NULL;
iostate state01 = f_in1.rdstate();
f_in1 >> strbuf01;
iostate state02 = f_in1.rdstate();
VERIFY( state01 != state02 );
VERIFY( (state02 & std::ios_base::failbit) != 0 );
state01 = f_out1.rdstate();
f_out1 << strbuf01;
state02 = f_out1.rdstate();
VERIFY( state01 != state02 );
VERIFY( (state02 & std::ios_base::badbit) != 0 );
// filebuf->filebuf
std::wifstream f_in(name_01);
std::wofstream f_out(name_02);
f_out << f_in.rdbuf();
f_in.close();
f_out.close();
// filebuf->stringbuf->filebuf
std::wifstream f_in2(name_03);
std::wofstream f_out2(name_04); // should be different name
std::wstringbuf strbuf02;
f_in2 >> &strbuf02;
f_out2 << &strbuf02;
f_in2.close();
f_out2.close();
}
int
main()
{
test02();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.5.4 basic_ostream character inserters
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
#include <ostream>
#include <fstream>
#include <testsuite_hooks.h>
// via Brent Verner <brent@rcfile.org>
// http://gcc.gnu.org/ml/libstdc++/2000-06/msg00005.html
void
test03(void)
{
using namespace std;
typedef wios::pos_type pos_type;
const char* TEST_IN = "wostream_inserter_other_in";
const char* TEST_OUT = "wostream_inserter_other_out";
pos_type i_read, i_wrote, rs, ws;
double tf_size = BUFSIZ * 2.5;
ofstream testfile(TEST_IN);
for (int i = 0; i < tf_size; ++i)
testfile.put(L'.');
testfile.close();
wifstream in(TEST_IN);
wofstream out(TEST_OUT);
out << in.rdbuf();
in.seekg(0, ios_base::beg);
out.seekp(0, ios_base::beg);
rs = in.tellg();
ws = out.tellp();
in.seekg(0, ios_base::end);
out.seekp(0, ios_base::end);
i_read = in.tellg() - rs;
i_wrote = out.tellp() - ws;
in.close();
out.close();
}
int
main()
{
test03();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.5.4 basic_ostream character inserters
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
// libstdc++/3272
void test04()
{
using namespace std;
bool test __attribute__((unused)) = true;
wistringstream istr(L"inside betty carter");
wostringstream ostr;
ostr << istr.rdbuf() << endl;
if (ostr.rdstate() & ios_base::eofbit)
test = false;
VERIFY( test );
}
int
main()
{
test04();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.5.4 basic_ostream character inserters
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
class test_buffer_1 : public std::wstreambuf
{
public:
test_buffer_1(const std::wstring& s)
: str(s), it(str.begin()) { }
protected:
virtual int_type
underflow()
{ return (it != str.end() ? *it : WEOF); }
virtual int_type
uflow()
{ return (it != str.end() ? *it++ : WEOF); }
private:
const std::wstring str;
std::wstring::const_iterator it;
};
class test_buffer_2 : public std::wstreambuf
{
public:
test_buffer_2(const std::wstring& s)
: str(s), it(str.begin()) { }
protected:
virtual int_type
underflow()
{ return (it != str.end() ? *it : WEOF); }
virtual int_type
uflow()
{ return (it != str.end() ? *it++ : WEOF); }
virtual std::streamsize
showmanyc()
{ return std::distance(it, str.end()); }
private:
const std::wstring str;
std::wstring::const_iterator it;
};
class test_buffer_3 : public std::wstreambuf
{
public:
test_buffer_3(const std::wstring& s)
: str(s), it(str.begin()) { }
protected:
virtual int_type
underflow()
{ return (it != str.end() ? *it : WEOF); }
virtual int_type
uflow()
{ return (it != str.end() ? *it++ : WEOF); }
virtual std::streamsize
showmanyc()
{
std::streamsize ret = std::distance(it, str.end());
return ret > 0 ? ret : -1;
}
private:
const std::wstring str;
std::wstring::const_iterator it;
};
class test_buffer_4 : public std::wstreambuf
{
public:
test_buffer_4(const std::wstring& s)
: str(s), it(str.begin())
{
if (it != str.end())
{
buf[0] = *it++;
setg(buf, buf, buf+1);
}
}
protected:
virtual int_type
underflow()
{ return (it != str.end() ? *it : WEOF); }
virtual int_type
uflow()
{ return (it != str.end() ? *it++ : WEOF); }
virtual std::streamsize
showmanyc()
{
std::streamsize ret = std::distance(it, str.end());
return ret > 0 ? ret : -1;
}
private:
const std::wstring str;
std::wstring::const_iterator it;
wchar_t buf[1];
};
void test(const std::wstring& str, std::wstreambuf& buf)
{
bool test __attribute__((unused)) = true;
std::wostringstream out;
std::wistream in(&buf);
out << in.rdbuf();
if (out.str() != str)
VERIFY( false );
}
// libstdc++/6745
// libstdc++/8071
// libstdc++/8127
// Jonathan Lennox <lennox@cs.columbia.edu>
void test05()
{
std::wstring string_a(L"Hello, world!");
std::wstring string_b(L"");
test_buffer_1 buf1a(string_a);
test_buffer_1 buf1b(string_b);
test_buffer_2 buf2a(string_a);
test_buffer_2 buf2b(string_b);
test_buffer_3 buf3a(string_a);
test_buffer_3 buf3b(string_b);
test_buffer_4 buf4a(string_a);
test_buffer_4 buf4b(string_b);
test(string_a, buf1a);
test(string_b, buf1b);
test(string_a, buf2a);
test(string_b, buf2b);
test(string_a, buf3a);
test(string_b, buf3b);
test(string_a, buf4a);
test(string_b, buf4b);
}
int
main()
{
test05();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.5.3 basic_ostream manipulator inserters
//
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// Inserters for manipulators do not behave as formatted output functions.
#include <ostream>
#include <stdexcept>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
std::wostream& func1(std::wostream&)
{ throw std::runtime_error(""); }
std::wios& func2(std::wios&)
{ throw std::runtime_error(""); }
std::ios_base& func3(std::ios_base&)
{ throw std::runtime_error(""); }
template<typename T>
void test(T& (*f)(T&))
{
bool test __attribute__((unused)) = true;
__gnu_test::sync_wstreambuf buf;
std::wostream os(&buf);
__gnu_test::sync_wstreambuf buf_tie;
std::wostream os_tie(&buf_tie);
// No sentry should be constructed so os.tie()->flush() should not be
// called.
os.tie(&os_tie);
try
{
os << f;
// Exceptions thrown by f should not be caught
VERIFY( false );
}
catch (std::runtime_error&)
{
}
// Exceptions thrown by f should not cause badbit to be set
VERIFY( os.good() );
VERIFY( !buf_tie.sync_called() );
// The manipulator should be called even if !os.good().
os.setstate(std::ios_base::eofbit);
try
{
os << f;
// Exceptions thrown by f should not be caught
VERIFY( false );
}
catch (std::runtime_error&)
{
}
// Exceptions thrown by f should not cause badbit to be set
VERIFY( os.rdstate() == std::ios_base::eofbit );
VERIFY( !buf_tie.sync_called() );
}
void test05()
{
test(&func1);
test(&func2);
test(&func3);
}
int main()
{
test05();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 27.5.2 template class basic_streambuf
#include <streambuf>
#include <sstream>
#include <ostream>
#include <testsuite_hooks.h>
// libstdc++/9318
class Outbuf : public std::wstreambuf
{
public:
typedef std::wstreambuf::traits_type traits_type;
std::wstring result() const { return str; }
protected:
virtual int_type
overflow(int_type c = traits_type::eof())
{
if (!traits_type::eq_int_type(c, traits_type::eof()))
str.push_back(traits_type::to_char_type(c));
return traits_type::not_eof(c);
}
private:
std::wstring str;
};
void test10()
{
bool test __attribute__((unused)) = true;
std::wstringbuf sbuf(L"Bad Moon Rising", std::wios::in);
Outbuf buf;
std::wostream stream(&buf);
stream << &sbuf;
VERIFY( buf.result() == L"Bad Moon Rising" );
}
int main()
{
test10();
return 0;
}
// 1999-10-11 bkoz
// Copyright (C) 1999, 2000, 2001, 2002, 2003 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 27.5.2 template class basic_streambuf
#include <cwchar>
#include <streambuf>
#include <sstream>
#include <ostream>
#include <testsuite_hooks.h>
// libstdc++/9424
class Outbuf_2 : public std::wstreambuf
{
wchar_t buf[1];
public:
Outbuf_2()
{
setp(buf, buf + 1);
}
int_type overflow(int_type c)
{
int_type eof = traits_type::eof();
if (pptr() < epptr())
{
if (traits_type::eq_int_type(c, eof))
return traits_type::not_eof(c);
*pptr() = traits_type::to_char_type(c);
pbump(1);
return c;
}
return eof;
}
};
class Inbuf_2 : public std::wstreambuf
{
static const wchar_t buf[];
const wchar_t* current;
int size;
public:
Inbuf_2()
{
current = buf;
size = std::wcslen(buf);
}
int_type underflow()
{
if (current < buf + size)
return traits_type::to_int_type(*current);
return traits_type::eof();
}
int_type uflow()
{
if (current < buf + size)
return traits_type::to_int_type(*current++);
return traits_type::eof();
}
};
const wchar_t Inbuf_2::buf[] = L"Atteivlis";
void test12()
{
bool test __attribute__((unused)) = true;
Outbuf_2 outbuf2;
std::wostream os (&outbuf2);
Inbuf_2 inbuf2;
os << &inbuf2;
VERIFY( inbuf2.sgetc() == L't' );
VERIFY( os.good() );
}
int main()
{
test12();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <ostream>
#include <streambuf>
#include <testsuite_hooks.h>
struct buf: std::wstreambuf
{
virtual int_type overflow(int_type)
{ throw 0; }
};
template<typename T>
void testthrow(T arg)
{
bool test __attribute__((unused)) = true;
buf b;
std::wostream os(&b);
os.exceptions(std::wios::badbit);
try
{
os << arg;
}
catch(int)
{
// Expected return is zero.
VERIFY( os.bad() );
}
catch(...)
{
VERIFY( false );
}
}
int main()
{
buf b;
testthrow(&b);
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <ostream>
#include <streambuf>
#include <sstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
using namespace std;
void test5()
{
bool test __attribute__((unused)) = true;
__gnu_test::fail_wstreambuf bob;
wostream stream(&bob);
wstringbuf sbuf(L"Foo, bar, qux", ios_base::in);
stream << &sbuf;
VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
}
void test7()
{
bool test __attribute__((unused)) = true;
wostringstream stream;
__gnu_test::fail_wstreambuf bib;
stream << &bib;
VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
}
// libstdc++/9371
int main()
{
test5();
test7();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <ostream>
#include <streambuf>
#include <sstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
using namespace std;
void test13()
{
bool test __attribute__((unused)) = true;
__gnu_test::fail_wstreambuf bob;
wostream stream(&bob);
stream.exceptions(ios_base::badbit);
wstringbuf sbuf(L"Foo, bar, qux", ios_base::in);
try
{
stream << &sbuf;
}
catch (...)
{ VERIFY(false); }
VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
}
void test15()
{
bool test __attribute__((unused)) = true;
wostringstream stream;
stream.exceptions(ios_base::badbit);
__gnu_test::fail_wstreambuf bib;
try
{
stream << &bib;
}
catch (...)
{ VERIFY(false); }
VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
}
// libstdc++/9371
int main()
{
test13();
test15();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <ostream>
#include <streambuf>
#include <sstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
using namespace std;
void test9()
{
bool test __attribute__((unused)) = true;
__gnu_test::fail_wstreambuf bob;
wostream stream(&bob);
stream.exceptions(ios_base::failbit);
wstringbuf sbuf(L"Foo, bar, qux", ios_base::in);
try
{
stream << &sbuf;
VERIFY( false );
}
catch (ios_base::failure&)
{ VERIFY( false ); }
catch (__gnu_test::overflow_error&)
{ }
catch (...)
{ VERIFY( false ); }
VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
}
void test11()
{
bool test __attribute__((unused)) = true;
wostringstream stream;
stream.exceptions(ios_base::failbit);
__gnu_test::fail_wstreambuf bib;
try
{
stream << &bib;
VERIFY( false );
}
catch (ios_base::failure&)
{ VERIFY( false ); }
catch (__gnu_test::underflow_error&)
{ }
catch (...)
{ VERIFY( false ); }
VERIFY( stream.rdstate() & ios_base::failbit );
VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
}
// libstdc++/9371
int main()
{
test9();
test11();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <istream>
#include <ostream>
#include <streambuf>
#include <sstream>
#include <testsuite_hooks.h>
void test1()
{
using namespace std;
bool test __attribute__((unused)) = true;
wostringstream stream;
stream << static_cast<wstreambuf*>(NULL);
VERIFY( stream.rdstate() & ios_base::badbit );
}
void test3()
{
using namespace std;
bool test __attribute__((unused)) = true;
wostringstream stream;
stream.exceptions(ios_base::badbit);
try
{
stream << static_cast<wstreambuf*>(NULL);
VERIFY( false );
}
catch (ios_base::failure&)
{
}
VERIFY( stream.rdstate() & ios_base::badbit );
}
// libstdc++/9371
int main()
{
test1();
test3();
return 0;
}
// 2003-09-22 Petur Runolfsson <peturr02@ru.is> // 2003-09-22 Petur Runolfsson <peturr02@ru.is>
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -34,13 +34,14 @@ ...@@ -34,13 +34,14 @@
class Buf : public std::streambuf class Buf : public std::streambuf
{ {
protected: protected:
virtual int_type overflow(int_type = traits_type::eof()) virtual int_type
overflow(int_type = traits_type::eof())
{ throw 0; } { throw 0; }
}; };
void test01() void test01()
{ {
bool test = true; bool test __attribute__((unused)) = true;
Buf buf; Buf buf;
std::ostream os(&buf); std::ostream os(&buf);
......
// Copyright (C) 2005 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.6.2.6 Unformatted output functions
//
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// basic_ostream::put(char_type) is an unformatted output function.
// DR 63. Exception-handling policy for unformatted output.
// Unformatted output functions should catch exceptions thrown
// from streambuf members.
#include <ostream>
#include <streambuf>
#include <testsuite_hooks.h>
class Buf : public std::wstreambuf
{
protected:
virtual int_type
overflow(int_type = traits_type::eof())
{ throw 0; }
};
void test01()
{
bool test __attribute__((unused)) = true;
Buf buf;
std::wostream os(&buf);
VERIFY( os.good() );
os.put(L'a');
VERIFY( os.rdstate() == std::ios_base::badbit );
os.clear();
os.exceptions(std::ios_base::badbit);
try
{
os.put(L'b');
VERIFY( false );
}
catch (int)
{
VERIFY( os.rdstate() == std::ios_base::badbit );
}
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2003, 2004 Free Software Foundation, Inc. // Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -31,11 +31,11 @@ ...@@ -31,11 +31,11 @@
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#include <testsuite_io.h> #include <testsuite_io.h>
using namespace std;
void test01() void test01()
{ {
using namespace std;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
__gnu_test::fail_streambuf bib; __gnu_test::fail_streambuf bib;
ostream stream(&bib); ostream stream(&bib);
stream.exceptions(ios_base::badbit); stream.exceptions(ios_base::badbit);
...@@ -56,13 +56,15 @@ void test01() ...@@ -56,13 +56,15 @@ void test01()
} }
catch (...) catch (...)
{ {
VERIFY(false); VERIFY( false );
} }
} }
void test02() void test02()
{ {
using namespace std;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
__gnu_test::fail_streambuf bib; __gnu_test::fail_streambuf bib;
ostream stream(&bib); ostream stream(&bib);
stream.exceptions(ios_base::badbit); stream.exceptions(ios_base::badbit);
...@@ -83,7 +85,7 @@ void test02() ...@@ -83,7 +85,7 @@ void test02()
} }
catch (...) catch (...)
{ {
VERIFY(false); VERIFY( false );
} }
} }
......
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.4 basic_ostream seek members [lib.ostream.seeks]
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
#include <ostream>
#include <istream>
#include <fstream>
#include <testsuite_hooks.h>
const wchar_t* s = L" lootpack, peanut butter wolf, rob swift, madlib, quasimoto";
const int times = 10;
void write_rewind(std::wiostream& stream)
{
bool test __attribute__((unused)) = true;
for (int j = 0; j < times; j++)
{
std::streampos begin = stream.tellp();
for (int i = 0; i < times; ++i)
stream << j << L'-' << i << s << L'\n';
stream.seekp(begin);
}
VERIFY( stream.good() );
}
void check_contents(std::wiostream& stream)
{
bool test __attribute__((unused)) = true;
stream.clear();
stream.seekg(0, std::wios::beg);
int i = 0;
int loop = times * times + 2;
while (i < loop)
{
stream.ignore(80, L'\n');
if (stream.good())
++i;
else
break;
}
VERIFY( i == times );
}
// fstream
// libstdc++/2346
void test02()
{
std::wfstream ofstrm;
ofstrm.open("wistream_seeks-3.txt", std::wios::out);
if (!ofstrm)
std::abort();
write_rewind(ofstrm);
ofstrm.close();
std::wfstream ifstrm;
ifstrm.open("wistream_seeks-3.txt", std::wios::in);
check_contents(ifstrm);
ifstrm.close();
}
int main()
{
test02();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.4 basic_ostream seek members [lib.ostream.seeks]
#include <ostream>
#include <istream>
#include <sstream>
#include <testsuite_hooks.h>
const wchar_t* s = L" lootpack, peanut butter wolf, rob swift, madlib, quasimoto";
const int times = 10;
void write_rewind(std::wiostream& stream)
{
bool test __attribute__((unused)) = true;
for (int j = 0; j < times; j++)
{
std::streampos begin = stream.tellp();
for (int i = 0; i < times; ++i)
stream << j << L'-' << i << s << L'\n';
stream.seekp(begin);
}
VERIFY( stream.good() );
}
void check_contents(std::wiostream& stream)
{
bool test __attribute__((unused)) = true;
stream.clear();
stream.seekg(0, std::wios::beg);
int i = 0;
int loop = times * times + 2;
while (i < loop)
{
stream.ignore(80, L'\n');
if (stream.good())
++i;
else
break;
}
VERIFY( i == times );
}
// stringstream
// libstdc++/2346
// N.B. The original testcase was broken, using tellg/seekg in write_rewind.
void test03()
{
std::wstringstream sstrm;
write_rewind(sstrm);
check_contents(sstrm);
}
int main()
{
test03();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <ostream>
#include <streambuf>
#include <sstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
__gnu_test::fail_wstreambuf bib;
wostream stream(&bib);
stream.exceptions(ios_base::badbit);
wostream::pos_type pos = wostream::pos_type();
try
{
stream.seekp(pos);
VERIFY( false );
}
catch (const __gnu_test::positioning_error&)
{
// stream should set badbit and rethrow facet_error.
VERIFY( stream.bad() );
VERIFY( (stream.rdstate() & ios_base::failbit) == 0 );
VERIFY( !stream.eof() );
}
catch (...)
{
VERIFY( false );
}
}
void test02()
{
using namespace std;
bool test __attribute__((unused)) = true;
__gnu_test::fail_wstreambuf bib;
wostream stream(&bib);
stream.exceptions(ios_base::badbit);
wostream::off_type off(5);
try
{
stream.seekp(off, ios_base::cur);
VERIFY( false );
}
catch (const __gnu_test::positioning_error&)
{
// stream should set badbit and rethrow facet_error.
VERIFY( stream.bad() );
VERIFY( (stream.rdstate() & ios_base::failbit) == 0 );
VERIFY( !stream.eof() );
}
catch (...)
{
VERIFY( false );
}
}
// libstdc++/9546
int main()
{
test01();
test02();
return 0;
}
// 2003-02-06 Paolo Carlini <pcarlini@unitus.it> // 2003-02-06 Paolo Carlini <pcarlini@unitus.it>
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -34,13 +34,15 @@ ...@@ -34,13 +34,15 @@
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// libstdc++/9563 // libstdc++/9563
struct buf: std::streambuf struct buf : std::streambuf
{ {
std::ios *io_; std::ios *io_;
buf (std::ios *io): io_ (io) { } buf(std::ios *io)
: io_(io) { }
virtual int sync () virtual int
sync()
{ {
io_->setstate (std::ios::failbit); io_->setstate (std::ios::failbit);
return 0; return 0;
......
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 27.6.2.3 class basic_ostream::sentry
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
// libstdc++/9562
void
test01()
{
bool test __attribute__((unused)) = true;
std::wstringbuf strbuf01;
std::wostream strm1(&strbuf01);
const std::wostream::sentry sentry1(strm1);
VERIFY( bool(sentry1) == true );
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 27.6.2.3 class basic_ostream::sentry
#include <ostream>
#include <sstream>
#include <testsuite_hooks.h>
// libstdc++/9563
struct buf : std::wstreambuf
{
std::wios *io_;
buf(std::wios *io)
: io_(io) { }
virtual int
sync()
{
io_->setstate (std::wios::failbit);
return 0;
}
};
void
test02()
{
bool test __attribute__((unused)) = true;
buf b(0);
std::wostream strm(&b);
buf tb(&strm);
std::wostream tied(&tb);
strm.tie(&tied);
std::wostream::sentry s(strm);
VERIFY( !s );
}
int main()
{
test02();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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.6.2.4 basic_ostream seek members
#include <ostream>
#include <sstream>
#include <fstream>
#include <testsuite_hooks.h>
void test01()
{
using namespace std;
typedef wios::off_type off_type;
typedef wios::pos_type pos_type;
bool test __attribute__((unused)) = true;
const char str_lit01[] = "wostream_seeks-1.txt";
// out
wostringstream ost1;
pos_type p1 = ost1.tellp();
wofstream ofs1;
pos_type p2 = ofs1.tellp();
// N.B. We implement the resolution of DR 453 and
// ostringstream::tellp() doesn't fail.
VERIFY( p1 == pos_type(off_type(0)) );
VERIFY( p2 == pos_type(off_type(-1)) );
// out
// test ctors leave things in the same positions...
wostringstream ost2(L"bob_marley:kaya");
p1 = ost2.tellp();
wofstream ofs2(str_lit01);
p2 = ofs2.tellp();
VERIFY( p1 == p2 );
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2005 Free Software Foundation
//
// 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,
//
#include <sstream>
#include <ostream>
#include <testsuite_hooks.h>
void test01()
{
using namespace std;
typedef std::wstringbuf::pos_type pos_type;
typedef std::wstringbuf::off_type off_type;
bool test __attribute__((unused)) = true;
// tellp
wostringstream ost;
pos_type pos1;
pos1 = ost.tellp();
VERIFY( pos1 == pos_type(off_type(0)) );
ost << L"RZA ";
pos1 = ost.tellp();
VERIFY( pos1 == pos_type(off_type(4)) );
ost << L"ghost dog: way of the samurai";
pos1 = ost.tellp();
VERIFY( pos1 == pos_type(off_type(33)) );
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2005 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.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <ostream>
#include <streambuf>
#include <sstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
using namespace std;
void test01()
{
bool test __attribute__((unused)) = true;
__gnu_test::fail_wstreambuf bib;
wostream stream(&bib);
stream.exceptions(ios_base::badbit);
try
{
stream.tellp();
VERIFY( false );
}
catch (const __gnu_test::positioning_error&)
{
// stream should set badbit and rethrow facet_error.
VERIFY( stream.bad() );
VERIFY( (stream.rdstate() & ios_base::failbit) == 0 );
VERIFY( !stream.eof() );
}
catch (...)
{
VERIFY(false);
}
}
// libstdc++/9546
int main()
{
test01();
return 0;
}
// 2003-09-22 Petur Runolfsson <peturr02@ru.is> // 2003-09-22 Petur Runolfsson <peturr02@ru.is>
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
class Buf : public std::streambuf class Buf : public std::streambuf
{ {
protected: protected:
virtual int_type overflow(int_type = traits_type::eof()) virtual int_type
overflow(int_type = traits_type::eof())
{ throw 0; } { throw 0; }
}; };
......
// Copyright (C) 2005 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.6.2.6 Unformatted output functions
//
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// basic_ostream::write(const char_type*, streamsize) is an unformatted
// output function.
// DR 63. Exception-handling policy for unformatted output.
// Unformatted output functions should catch exceptions thrown
// from streambuf members.
#include <ostream>
#include <streambuf>
#include <testsuite_hooks.h>
class Buf : public std::wstreambuf
{
protected:
virtual int_type
overflow(int_type = traits_type::eof())
{ throw 0; }
};
void test01()
{
bool test = true;
Buf buf;
std::wostream os(&buf);
VERIFY( os.good() );
os.write(L"a", 1);
VERIFY( os.rdstate() == std::ios_base::badbit );
os.clear();
os.exceptions(std::ios_base::badbit);
try
{
os.write(L"b", 1);
VERIFY( false );
}
catch (int)
{
VERIFY( os.rdstate() == std::ios_base::badbit );
}
}
int main()
{
test01();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment