From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../basic_ostream/inserters_character/char/1.cc | 57 ++++++++++++++++ .../inserters_character/char/11095-oa.cc | 45 +++++++++++++ .../inserters_character/char/11095-ob.cc | 45 +++++++++++++ .../inserters_character/char/11095-oc.cc | 45 +++++++++++++ .../basic_ostream/inserters_character/char/2.cc | 67 +++++++++++++++++++ .../inserters_character/char/28277-3.cc | 53 +++++++++++++++ .../inserters_character/char/28277-4.cc | 54 +++++++++++++++ .../basic_ostream/inserters_character/char/3.cc | 66 +++++++++++++++++++ .../basic_ostream/inserters_character/char/4.cc | 54 +++++++++++++++ .../basic_ostream/inserters_character/char/5.cc | 76 ++++++++++++++++++++++ .../basic_ostream/inserters_character/char/6.cc | 57 ++++++++++++++++ .../basic_ostream/inserters_character/char/8.cc | 47 +++++++++++++ .../inserters_character/char/9555-oc.cc | 69 ++++++++++++++++++++ 13 files changed, 735 insertions(+) create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-oa.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-ob.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-oc.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/2.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-3.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-4.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/3.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/4.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/5.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/6.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/8.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/9555-oc.cc (limited to 'libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char') diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/1.cc new file mode 100644 index 000000000..926b68bc7 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/1.cc @@ -0,0 +1,57 @@ +// 1999-08-16 bkoz + +// Copyright (C) 1999, 2000, 2002, 2003, 2009 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include +#include + +// ofstream +void test01() +{ + std::string str01; + const int size = 1000; + const char name_02[] = "ostream_inserter_char-1.txt"; + + // initialize string + for(int i=0 ; i < size; i++) { + str01 += '1'; + str01 += '2'; + str01 += '3'; + str01 += '4'; + str01 += '5'; + str01 += '6'; + str01 += '7'; + str01 += '8'; + str01 += '9'; + str01 += '\n'; + } + std::ofstream f(name_02); + + f << str01; + f.close(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-oa.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-oa.cc new file mode 100644 index 000000000..aeec2d51c --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-oa.cc @@ -0,0 +1,45 @@ +// 2003-06-05 Paolo Carlini + +// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include + +// libstdc++/11095 +// operator<<(basic_ostream&, char) +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ostringstream oss_01; + + oss_01.width(-60); + oss_01 << 'C'; + VERIFY( oss_01.good() ); + VERIFY( oss_01.str() == "C" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-ob.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-ob.cc new file mode 100644 index 000000000..80ef77595 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-ob.cc @@ -0,0 +1,45 @@ +// 2003-06-05 Paolo Carlini + +// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include + +// libstdc++/11095 +// operator<<(basic_ostream&, const char*) +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::ostringstream oss_01; + + oss_01.width(-60); + oss_01 << "Consoli"; + VERIFY( oss_01.good() ); + VERIFY( oss_01.str() == "Consoli" ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-oc.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-oc.cc new file mode 100644 index 000000000..43e1e0db0 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/11095-oc.cc @@ -0,0 +1,45 @@ +// 2003-06-05 Paolo Carlini + +// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include + +// libstdc++/11095 +// operator<<(basic_ostream&, const basic_string&) +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::ostringstream oss_01; + + oss_01.width(-60); + oss_01 << std::string("Consoli"); + VERIFY( oss_01.good() ); + VERIFY( oss_01.str() == "Consoli" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/2.cc new file mode 100644 index 000000000..988da4491 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/2.cc @@ -0,0 +1,67 @@ +// 1999-08-16 bkoz + +// Copyright (C) 1999, 2000, 2002, 2003, 2009 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include +#include + +// ostringstream width() != zero +// left +void +test02(void) +{ + bool test __attribute__((unused)) = true; + std::string tmp; + + std::string str01 = ""; + std::ostringstream oss01; + oss01.width(5); + oss01.fill('0'); + oss01.flags(std::ios_base::left); + oss01 << str01; + tmp = oss01.str(); + VERIFY( tmp == "00000" ); + + std::string str02 = "1"; + std::ostringstream oss02; + oss02.width(5); + oss02.fill('0'); + oss02.flags(std::ios_base::left); + oss02 << str02; + tmp = oss02.str(); + VERIFY( tmp == "10000" ); + + std::string str03 = "909909"; + std::ostringstream oss03; + oss03.width(5); + oss03.fill('0'); + oss03.flags(std::ios_base::left); + oss03 << str03; + tmp = oss03.str(); + VERIFY( tmp == "909909" ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-3.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-3.cc new file mode 100644 index 000000000..0d1c2f483 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-3.cc @@ -0,0 +1,53 @@ +// 2006-10-12 Paolo Carlini + +// Copyright (C) 2006, 2007, 2008, 2009 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 3, 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 COPYING3. If not see +// . + +// { dg-options "-DWIDTH=200000" { target simulator } } + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include + +#ifndef WIDTH +#define WIDTH 20000000 +#endif + +// libstdc++/28277 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + ostringstream oss_01; + + oss_01.width(WIDTH); + const streamsize width = oss_01.width(); + + oss_01 << 'a'; + + VERIFY( oss_01.good() ); + VERIFY( oss_01.str().size() == string::size_type(width) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-4.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-4.cc new file mode 100644 index 000000000..fe80c76ba --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/28277-4.cc @@ -0,0 +1,54 @@ +// 2006-10-12 Paolo Carlini + +// Copyright (C) 2006, 2007, 2008, 2009 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 3, 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 COPYING3. If not see +// . + +// { dg-options "-DWIDTH=200000" { target simulator } } + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include + +#ifndef WIDTH +#define WIDTH 20000000 +#endif + +// libstdc++/28277 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + ostringstream oss_01; + const string str_01(50, 'a'); + + oss_01.width(WIDTH); + const streamsize width = oss_01.width(); + + oss_01 << str_01.c_str(); + + VERIFY( oss_01.good() ); + VERIFY( oss_01.str().size() == string::size_type(width) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/3.cc new file mode 100644 index 000000000..87e299db5 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/3.cc @@ -0,0 +1,66 @@ +// 1999-08-16 bkoz + +// Copyright (C) 1999, 2000, 2002, 2003, 2009 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include +#include + +// width() != zero +// right +void test03(void) +{ + bool test __attribute__((unused)) = true; + std::string tmp; + + std::string str01 = ""; + std::ostringstream oss01; + oss01.width(5); + oss01.fill('0'); + oss01.flags(std::ios_base::right); + oss01 << str01; + tmp = oss01.str(); + VERIFY( tmp == "00000" ); + + std::string str02 = "1"; + std::ostringstream oss02; + oss02.width(5); + oss02.fill('0'); + oss02.flags(std::ios_base::right); + oss02 << str02; + tmp = oss02.str(); + VERIFY( tmp == "00001" ); + + std::string str03 = "909909"; + std::ostringstream oss03; + oss03.width(5); + oss03.fill('0'); + oss03.flags(std::ios_base::right); + oss03 << str03; + tmp = oss03.str(); + VERIFY( tmp == "909909" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/4.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/4.cc new file mode 100644 index 000000000..5ec21367b --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/4.cc @@ -0,0 +1,54 @@ +// 1999-08-16 bkoz + +// Copyright (C) 1999, 2000, 2002, 2003, 2005, 2009, 2010 +// 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include +#include + +// stringstream and large strings +void +test04() +{ + bool test __attribute__((unused)) = true; + std::string str_01; + std::string str_tmp; + const int i_max=250; + + std::ostringstream oss_02(str_01, std::ios_base::out); + + // template<_CharT, _Traits> + // basic_ostream& operator<<(ostream&, const char*) + for (int i = 0; i < i_max; ++i) + oss_02 << "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; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/5.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/5.cc new file mode 100644 index 000000000..6b6cbb38d --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/5.cc @@ -0,0 +1,76 @@ +// 1999-08-16 bkoz + +// Copyright (C) 1999, 2000, 2002, 2003, 2009 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include +#include + +// ostringstream and large strings number 2 +void +test05() +{ + bool test __attribute__((unused)) = true; + std::string str05, str10; + + typedef std::ostream::pos_type pos_type; + typedef std::ostream::off_type off_type; + std::string str01; + const int size = 1000; + + // initialize string + for(int i=0 ; i < size; i++) { + str01 += '1'; + str01 += '2'; + str01 += '3'; + str01 += '4'; + str01 += '5'; + str01 += '6'; + str01 += '7'; + str01 += '8'; + str01 += '9'; + str01 += '\n'; + } + + // test 1: out + std::ostringstream sstr01(str01, std::ios_base::out); + std::ostringstream sstr02; + sstr02 << str01; + str05 = sstr01.str(); + str10 = sstr02.str(); + VERIFY( str05 == str01 ); + VERIFY( str10 == str01 ); + + // test 2: in | out + std::ostringstream sstr04(str01, std::ios_base::out | std::ios_base::in); + std::ostringstream 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; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/6.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/6.cc new file mode 100644 index 000000000..25aad8a04 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/6.cc @@ -0,0 +1,57 @@ +// 1999-08-16 bkoz + +// Copyright (C) 1999, 2000, 2002, 2003, 2009 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include +#include + +// ostringstream and positioning, multiple writes +// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00326.html +void test06() +{ + bool test __attribute__((unused)) = true; + const char carray01[] = "mos def & talib kweli are black star"; + + // normal + std::ostringstream ostr1("mos def"); + VERIFY( ostr1.str() == "mos def" ); + ostr1 << " & talib kweli"; // should overwrite first part of buffer + VERIFY( ostr1.str() == " & talib kweli" ); + ostr1 << " are black star"; // should append to string from above + VERIFY( ostr1.str() != carray01 ); + VERIFY( ostr1.str() == " & talib kweli are black star" ); + + // appending + std::ostringstream ostr2("blackalicious", + std::ios_base::out | std::ios_base::ate); + VERIFY( ostr2.str() == "blackalicious" ); + ostr2 << " NIA "; // should not overwrite first part of buffer + VERIFY( ostr2.str() == "blackalicious NIA " ); + ostr2 << "4: deception (5:19)"; // should append to full string from above + VERIFY( ostr2.str() == "blackalicious NIA 4: deception (5:19)" ); +} + +int main() +{ + test06(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/8.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/8.cc new file mode 100644 index 000000000..f38e2e703 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/8.cc @@ -0,0 +1,47 @@ +// 1999-08-16 bkoz + +// Copyright (C) 1999, 2000, 2002, 2003, 2009, 2010 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include +#include + +void test08() +{ + bool test __attribute__((unused)) = true; + char* pt = 0; + + // 1 + std::ostringstream oss; + oss << pt; + VERIFY( oss.bad() ); + VERIFY( oss.str().size() == 0 ); + + oss.clear(); + oss << ""; + VERIFY( oss.good() ); +} + +int main() +{ + test08(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/9555-oc.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/9555-oc.cc new file mode 100644 index 000000000..b46b2aede --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_character/char/9555-oc.cc @@ -0,0 +1,69 @@ +// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see +// . + + +#include +#include +#include + +struct buf: std::streambuf +{ + virtual int_type overflow(int_type) + { throw 0; } +}; + +template +void testthrow(T arg) +{ + bool test __attribute__((unused)) = true; + buf b; + std::ostream os(&b); + os.exceptions(std::ios::badbit); + + try + { + os << arg; + } + catch(int) + { + // Expected return is zero. + VERIFY( os.bad() ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + char c = 'a'; + unsigned char uc = 'a'; + signed char sc = 'a'; + const char* ccp = "governor ann richards"; + const signed char* cscp = reinterpret_cast(ccp); + const unsigned char* cucp = reinterpret_cast(ccp); + + testthrow(c); + testthrow(uc); + testthrow(sc); + testthrow(ccp); + testthrow(cscp); + testthrow(cucp); + + return 0; +} -- cgit v1.2.3