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. --- libstdc++-v3/testsuite/27_io/objects/char/1.cc | 97 +++++++++++++++++++++ libstdc++-v3/testsuite/27_io/objects/char/10.cc | 75 ++++++++++++++++ .../testsuite/27_io/objects/char/12048-1.cc | 46 ++++++++++ .../testsuite/27_io/objects/char/12048-2.cc | 42 +++++++++ .../testsuite/27_io/objects/char/12048-3.cc | 42 +++++++++ .../testsuite/27_io/objects/char/12048-4.cc | 41 +++++++++ .../testsuite/27_io/objects/char/12048-5.cc | 56 ++++++++++++ libstdc++-v3/testsuite/27_io/objects/char/2.cc | 46 ++++++++++ .../testsuite/27_io/objects/char/2523-1_xin.cc | 88 +++++++++++++++++++ .../testsuite/27_io/objects/char/2523-1_xin.in | 1 + .../testsuite/27_io/objects/char/2523-2_xin.cc | 38 +++++++++ .../testsuite/27_io/objects/char/2523-2_xin.in | 1 + libstdc++-v3/testsuite/27_io/objects/char/3045.cc | 77 +++++++++++++++++ libstdc++-v3/testsuite/27_io/objects/char/3647.cc | 37 ++++++++ libstdc++-v3/testsuite/27_io/objects/char/3_xin.cc | 41 +++++++++ libstdc++-v3/testsuite/27_io/objects/char/3_xin.in | 1 + libstdc++-v3/testsuite/27_io/objects/char/41037.cc | 35 ++++++++ libstdc++-v3/testsuite/27_io/objects/char/4_xin.cc | 38 +++++++++ libstdc++-v3/testsuite/27_io/objects/char/4_xin.in | 1 + libstdc++-v3/testsuite/27_io/objects/char/5.cc | 84 ++++++++++++++++++ libstdc++-v3/testsuite/27_io/objects/char/5268.cc | 37 ++++++++ .../testsuite/27_io/objects/char/5280_xin.cc | 47 ++++++++++ .../testsuite/27_io/objects/char/5280_xin.in | 1 + libstdc++-v3/testsuite/27_io/objects/char/6.cc | 59 +++++++++++++ .../testsuite/27_io/objects/char/6548_xin.cc | 38 +++++++++ .../testsuite/27_io/objects/char/6548_xin.in | 1 + .../testsuite/27_io/objects/char/6648-1_xin.cc | 37 ++++++++ .../testsuite/27_io/objects/char/6648-1_xin.in | 1 + .../testsuite/27_io/objects/char/6648-2_xin.cc | 34 ++++++++ .../testsuite/27_io/objects/char/6648-2_xin.in | 1 + libstdc++-v3/testsuite/27_io/objects/char/7.cc | 86 +++++++++++++++++++ .../testsuite/27_io/objects/char/7744_xin.cc | 41 +++++++++ .../testsuite/27_io/objects/char/7744_xin.in | 1 + libstdc++-v3/testsuite/27_io/objects/char/8.cc | 50 +++++++++++ libstdc++-v3/testsuite/27_io/objects/char/9.cc | 48 +++++++++++ .../testsuite/27_io/objects/char/9661-1.cc | 99 ++++++++++++++++++++++ .../testsuite/27_io/objects/char/9661-2_xin.cc | 46 ++++++++++ .../testsuite/27_io/objects/char/9661-2_xin.in | 1 + libstdc++-v3/testsuite/27_io/objects/char/dr455.cc | 36 ++++++++ 39 files changed, 1551 insertions(+) create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/10.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/2.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/2523-1_xin.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/2523-1_xin.in create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/2523-2_xin.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/2523-2_xin.in create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/3045.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/3647.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/3_xin.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/3_xin.in create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/41037.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/4_xin.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/4_xin.in create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/5.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/5268.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/5280_xin.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/5280_xin.in create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/6.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/6548_xin.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/6548_xin.in create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/6648-1_xin.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/6648-1_xin.in create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/6648-2_xin.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/6648-2_xin.in create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/7.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/7744_xin.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/7744_xin.in create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/8.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/9.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.cc create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.in create mode 100644 libstdc++-v3/testsuite/27_io/objects/char/dr455.cc (limited to 'libstdc++-v3/testsuite/27_io/objects/char') diff --git a/libstdc++-v3/testsuite/27_io/objects/char/1.cc b/libstdc++-v3/testsuite/27_io/objects/char/1.cc new file mode 100644 index 000000000..ea57f0892 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/1.cc @@ -0,0 +1,97 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 all the headers except for iostream. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Include iostream last, just to make is as difficult as possible to +// properly initialize the standard iostream objects. +#include + +// Make sure all the standard streams are defined. +void test01() +{ + bool test __attribute__((unused)) = true; + + char array1[20]; + typedef std::ios::traits_type ctraits_type; + ctraits_type::int_type i = 15; + ctraits_type::copy(array1, "testing istream", i); + array1[i] = '\0'; + std::cout << "testing cout" << std::endl; + std::cerr << "testing cerr" << std::endl; + VERIFY( std::cerr.flags() & std::ios_base::unitbuf ); + std::clog << "testing clog" << std::endl; + // std::cin >> array1; // requires somebody to type something in. + VERIFY( std::cin.tie() == &std::cout ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/10.cc b/libstdc++-v3/testsuite/27_io/objects/char/10.cc new file mode 100644 index 000000000..eebebc20e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/10.cc @@ -0,0 +1,75 @@ +// 2003-05-01 Petur Runolfsson + +// Copyright (C) 2003, 2009, 2010 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 +// . + +// { dg-require-fileio "" } +// { dg-require-binary-io "" } + +#include +#include +#include + +void test10() +{ + using namespace std; + + bool test __attribute__((unused)) = true; + const char* name = "filebuf_virtuals-1.txt"; + + FILE* ret = freopen(name, "r", stdin); + VERIFY( ret ); + + streampos p1 = cin.tellg(); + VERIFY( p1 != streampos(-1) ); + VERIFY( streamoff(p1) == 0 ); + + cin.seekg(0, ios::end); + VERIFY( cin.good() ); + + streampos p2 = cin.tellg(); + VERIFY( p2 != streampos(-1) ); + VERIFY( p2 != p1 ); + VERIFY( streamoff(p2) == ftell(stdin) ); + + cin.seekg(p1); + VERIFY( cin.good() ); + + streamoff n = p2 - p1; + VERIFY( n > 0 ); + + for (int i = 0; i < n; ++i) + { + streampos p3 = cin.tellg(); + VERIFY( streamoff(p3) == i ); + VERIFY( ftell(stdin) == i ); + cin.get(); + VERIFY( cin.good() ); + } + + streampos p4 = cin.tellg(); + VERIFY( streamoff(p4) == n ); + VERIFY( ftell(stdin) == n ); + cin.get(); + VERIFY( cin.eof() ); +} + +int main() +{ + test10(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc new file mode 100644 index 000000000..e4982c5e7 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc @@ -0,0 +1,46 @@ +// Derived from libstdc++/12048 by LJR with +// reminder from Petur Runolfsson . + +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 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 +// . + +// { dg-require-fileio "" } + +#include +#include +#include + +void +test01() +{ + VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) ); + + char c1; + char c2; + std::cin.get(c1); + std::cin.unget(); + std::cin.get(c2); + VERIFY( std::cin.good() ); + VERIFY( c1 == c2 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc new file mode 100644 index 000000000..f18e5d393 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc @@ -0,0 +1,42 @@ +// 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 +// . + +// { dg-require-fileio "" } + +#include +#include +#include + +void +test01() +{ + VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) ); + + char c1; + int c2; + std::cin.get(c1); + std::cin.unget(); + VERIFY( std::cin.good() ); + c2 = std::fgetc(stdin); + VERIFY( c2 == std::char_traits::to_int_type(c1) ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc new file mode 100644 index 000000000..3b83ef176 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 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 +// . + +// { dg-require-fileio "" } + +#include +#include +#include + +void +test01() +{ + VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) ); + + char buf[2]; + VERIFY( std::cin.rdbuf()->sgetn(buf, 2) == 2 ); + int c1 = std::cin.rdbuf()->sungetc(); + int c2 = std::cin.rdbuf()->sbumpc(); + VERIFY( c1 == std::char_traits::to_int_type(buf[1]) ); + VERIFY( c2 == c1 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc new file mode 100644 index 000000000..0f8600dbb --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc @@ -0,0 +1,41 @@ +// 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 +// . + +// { dg-require-fileio "" } + +#include +#include +#include + +void +test01() +{ + VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) ); + + char buf[2]; + VERIFY( std::cin.rdbuf()->sgetn(buf, 2) == 2 ); + int c1 = std::cin.rdbuf()->sungetc(); + int c2 = std::fgetc(stdin); + VERIFY( c1 == std::char_traits::to_int_type(buf[1]) ); + VERIFY( c2 == c1 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc new file mode 100644 index 000000000..dd544b737 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc @@ -0,0 +1,56 @@ +// Derived from libstdc++/12048 by LJR with +// reminder from Petur Runolfsson . + +// 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 +// . + +// DR 49 states that cin.rdbuf()->sbumpc() and fgetc(stdin) should be +// equivalent and interchangable. Currently however, cin.rdbuf()->sungetc() +// only returns characters that were read with cin.rdbuf()->sbumpc() + +// { dg-require-fileio "" } + +// { dg-do run { xfail *-*-* } } + +#include +#include +#include + +void +test01() +{ + VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) ); + + char c1; + int c2; + char c3; + std::cin.get(c1); + c2 = std::fgetc(stdin); + std::cin.unget(); + if (std::cin.good()) + { + std::cin.get(c3); + VERIFY( std::cin.good() ); + VERIFY( c3 == std::char_traits::to_char_type(c2) ); + } +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/2.cc b/libstdc++-v3/testsuite/27_io/objects/char/2.cc new file mode 100644 index 000000000..286ba4fd9 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/2.cc @@ -0,0 +1,46 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 + +// Interactive test, to be exercised as follows: +// assign stderr to stdout in shell command line, +// pipe stdout to cat process and/or redirect stdout to file. +// a.out >& output +// "hello fine world\n" should be written to stdout, and output, in +// proper order. This is a version of the scott snyder test taken +// from: http://gcc.gnu.org/ml/libstdc++/1999-q4/msg00108.html +void test04() +{ + using namespace std; + + cout << "hello "; + cout.flush(); + cerr << "fine "; + cerr.flush(); + cout << "world" << endl; + cout.flush(); +} + +int +main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/2523-1_xin.cc b/libstdc++-v3/testsuite/27_io/objects/char/2523-1_xin.cc new file mode 100644 index 000000000..cc9516a95 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/2523-1_xin.cc @@ -0,0 +1,88 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 all the headers except for iostream. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Include iostream last, just to make is as difficult as possible to +// properly initialize the standard iostream objects. +#include + +// libstdc++/2523 +void test02() +{ + using namespace std; + int i; + cin >> i; + cout << "i == " << i << endl; +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/2523-1_xin.in b/libstdc++-v3/testsuite/27_io/objects/char/2523-1_xin.in new file mode 100644 index 000000000..ec308096e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/2523-1_xin.in @@ -0,0 +1 @@ +5588885 diff --git a/libstdc++-v3/testsuite/27_io/objects/char/2523-2_xin.cc b/libstdc++-v3/testsuite/27_io/objects/char/2523-2_xin.cc new file mode 100644 index 000000000..302f158ea --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/2523-2_xin.cc @@ -0,0 +1,38 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 + +// libstdc++/2523 +void test03() +{ + using namespace std; + ios_base::sync_with_stdio(false); + + int i; + cin >> i; + cout << "i == " << i << endl; +} + +int +main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/2523-2_xin.in b/libstdc++-v3/testsuite/27_io/objects/char/2523-2_xin.in new file mode 100644 index 000000000..aaee5e562 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/2523-2_xin.in @@ -0,0 +1 @@ +33332 diff --git a/libstdc++-v3/testsuite/27_io/objects/char/3045.cc b/libstdc++-v3/testsuite/27_io/objects/char/3045.cc new file mode 100644 index 000000000..9720e9634 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/3045.cc @@ -0,0 +1,77 @@ +// 2001-06-05 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 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 + +class gnu_filebuf: public std::filebuf +{ + int i; +public: + gnu_filebuf(int j = 1): i(j) { } + ~gnu_filebuf() { --i; } + int get_i() { return i;} +}; + +const int initial = 4; +gnu_filebuf buf(initial); + +// libstdc++/3045, in a vague way. +void test01() +{ + bool test __attribute__((unused)) = true; + int k1; + + // 1 normal + k1 = buf.get_i(); + VERIFY( k1 == initial ); + { + std::cout.rdbuf(&buf); + } + k1 = buf.get_i(); + VERIFY( k1 == initial ); + + // 2 syncd off + k1 = buf.get_i(); + VERIFY( k1 == initial ); + { + std::cout.rdbuf(&buf); + std::ios_base::sync_with_stdio(false); // make sure doesn't clobber buf + } + k1 = buf.get_i(); + VERIFY( k1 == initial ); + + // 3 callling init + k1 = buf.get_i(); + VERIFY( k1 == initial ); + { + std::cout.rdbuf(&buf); + std::ios_base::Init make_sure_initialized; + } + k1 = buf.get_i(); + VERIFY( k1 == initial ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/3647.cc b/libstdc++-v3/testsuite/27_io/objects/char/3647.cc new file mode 100644 index 000000000..506fb3130 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/3647.cc @@ -0,0 +1,37 @@ +// 2002-01-08 bkoz + +// Copyright (C) 2002, 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 +// . + + +// 27.6.1.5 - Template class basic_iostream +// NB: This file is for testing iostream with NO OTHER INCLUDES. + +#include + +// libstdc++/3647 +void test07() +{ + // Should not block. + std::cout << std::cin.rdbuf()->in_avail() << std::endl; +} + +int main() +{ + test07(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/3_xin.cc b/libstdc++-v3/testsuite/27_io/objects/char/3_xin.cc new file mode 100644 index 000000000..b09f58b8c --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/3_xin.cc @@ -0,0 +1,41 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 + +// Interactive test, to be exercised as follows: +// run test under truss(1) or strace(1). Look at +// size and pattern of write system calls. +// Should be 2 or 3 write(1,[...]) calls when run interactively +// depending upon buffering mode enforced. +void test05() +{ + std::cout << "hello" << ' ' << "world" << std::endl; + std::cout << "Enter your name: "; + std::string s; + std::cin >> s; + std::cout << "hello " << s << std::endl; +} + +int +main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/3_xin.in b/libstdc++-v3/testsuite/27_io/objects/char/3_xin.in new file mode 100644 index 000000000..a26c12687 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/3_xin.in @@ -0,0 +1 @@ +JOHN HUME and DAVID TRIMBLE diff --git a/libstdc++-v3/testsuite/27_io/objects/char/41037.cc b/libstdc++-v3/testsuite/27_io/objects/char/41037.cc new file mode 100644 index 000000000..a38221cab --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/41037.cc @@ -0,0 +1,35 @@ +// Copyright (C) 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 + +// PR libstdc++/41037 +void test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY( std::cerr.flags() & std::ios_base::dec ); + VERIFY( std::cerr.flags() & std::ios_base::skipws ); + VERIFY( std::cerr.flags() & std::ios_base::unitbuf ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/4_xin.cc b/libstdc++-v3/testsuite/27_io/objects/char/4_xin.cc new file mode 100644 index 000000000..dbeb9e049 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/4_xin.cc @@ -0,0 +1,38 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 + +// http://gcc.gnu.org/ml/libstdc++/2002-08/msg00060.html +// Should only have to hit enter once. +void +test10() +{ + using namespace std; + cout << "Press ENTER once\n"; + cin.ignore(1); + cout << "_M_gcount: "<< cin.gcount() << endl; +} + +int +main() +{ + test10(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/4_xin.in b/libstdc++-v3/testsuite/27_io/objects/char/4_xin.in new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/4_xin.in @@ -0,0 +1 @@ + diff --git a/libstdc++-v3/testsuite/27_io/objects/char/5.cc b/libstdc++-v3/testsuite/27_io/objects/char/5.cc new file mode 100644 index 000000000..c5bf54654 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/5.cc @@ -0,0 +1,84 @@ +// 2003-04-26 Petur Runolfsson + +// Copyright (C) 2003, 2004, 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.3 Standard iostream objects + +// Check that standard streams can be used from constructors and +// destructors of static objects, provided that an instance of +// ios_base::Init has been constructed. + +void init_standard_streams(); +int use_standard_streams(); + +struct Strange +{ + int i; + + Strange() + { + init_standard_streams(); + i = use_standard_streams(); + } + + ~Strange() + { + use_standard_streams(); + init_standard_streams(); + } +}; + +static Strange static_ob; + +#include +#include + +void init_standard_streams() +{ + std::ios_base::Init init; +} + +int use_standard_streams() +{ + std::cout << "Hello, world!" << std::endl; + std::cerr << "World, hello!" << std::endl; + + int ret = std::ios_base::xalloc(); + std::cin.iword(ret) = ret + 1; + std::cout.iword(ret) = ret + 2; + std::cerr.iword(ret) = ret + 3; + std::clog.iword(ret) = ret + 4; + return ret; +} + +void test05() +{ + bool test __attribute__((unused)) = true; + int i = static_ob.i; + + VERIFY( std::cin.iword(i) == i + 1 ); + VERIFY( std::cout.iword(i) == i + 2 ); + VERIFY( std::cerr.iword(i) == i + 3 ); + VERIFY( std::clog.iword(i) == i + 4 ); +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/5268.cc b/libstdc++-v3/testsuite/27_io/objects/char/5268.cc new file mode 100644 index 000000000..b7c0ac1df --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/5268.cc @@ -0,0 +1,37 @@ +// 2001-06-05 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009, 2010 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 + +// libstdc++/5268 +void test04() +{ + std::stringbuf b1; + std::cout.rdbuf( &b1 ); + std::cout << "hello\n"; + std::cout.rdbuf(0); +} + +int main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/5280_xin.cc b/libstdc++-v3/testsuite/27_io/objects/char/5280_xin.cc new file mode 100644 index 000000000..791959e7d --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/5280_xin.cc @@ -0,0 +1,47 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 + +// libstdc++/5280 +// Interactive test: input "1234^D^D" for i should terminate for EOF. +void test06() +{ + using namespace std; + int i; + cin >> i; + if (!cin.good()) + { + cerr << endl; + cerr << "i == " << i << endl; + cerr << "cin.rdstate() == " << cin.rdstate() << endl; + cerr << "cin.bad() == " << cin.bad() << endl; + cerr << "cin.fail() == " << cin.fail() << endl; + cerr << "cin.eof() == " << cin.eof() << endl; + } + else + cerr << "i == " << i << endl; +} + +int +main() +{ + test06(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/5280_xin.in b/libstdc++-v3/testsuite/27_io/objects/char/5280_xin.in new file mode 100644 index 000000000..274c0052d --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/5280_xin.in @@ -0,0 +1 @@ +1234 \ No newline at end of file diff --git a/libstdc++-v3/testsuite/27_io/objects/char/6.cc b/libstdc++-v3/testsuite/27_io/objects/char/6.cc new file mode 100644 index 000000000..8cf2e8d22 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/6.cc @@ -0,0 +1,59 @@ +// 2003-04-26 Petur Runolfsson + +// 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.3 Standard iostream objects + +// ios_base::Init::~Init() calls cout.flush(), which may call +// cout.setstate(badbit), which may throw an exception. Check that +// the exception doesn't escape from the destructor. + +#include +#include +#include + +class Badbuf : public std::streambuf +{ +protected: + virtual int sync() + { return -1; } +}; + +void test06() +{ + bool test __attribute__((unused)) = true; + + try + { + // No-op in current code. + std::ios_base::Init init; + std::cout.rdbuf(new Badbuf); + std::cout.exceptions(std::ios_base::badbit); + } + catch(...) + { + test = false; + } + VERIFY( test ); +} + +int main() +{ + test06(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/6548_xin.cc b/libstdc++-v3/testsuite/27_io/objects/char/6548_xin.cc new file mode 100644 index 000000000..10cf7177c --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/6548_xin.cc @@ -0,0 +1,38 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 + +// libstdc++/6548 +void test07() +{ + bool test __attribute__((unused)) = true; + std::cout << "Enter 'test':"; + std::string s; + std::getline(std::cin, s, '\n'); + VERIFY( s == "test" ); +} + +int +main() +{ + test07(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/6548_xin.in b/libstdc++-v3/testsuite/27_io/objects/char/6548_xin.in new file mode 100644 index 000000000..9daeafb98 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/6548_xin.in @@ -0,0 +1 @@ +test diff --git a/libstdc++-v3/testsuite/27_io/objects/char/6648-1_xin.cc b/libstdc++-v3/testsuite/27_io/objects/char/6648-1_xin.cc new file mode 100644 index 000000000..a69bdf5b3 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/6648-1_xin.cc @@ -0,0 +1,37 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 + +// libstdc++/6648 +// Interactive tests: each one (run alone) must terminate upon a single '\n'. +void test08() +{ + bool test __attribute__((unused)) = true; + char buff[2048]; + std::cout << "Enter name: "; + std::cin.getline(buff, 2048); +} + +int +main() +{ + test08(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/6648-1_xin.in b/libstdc++-v3/testsuite/27_io/objects/char/6648-1_xin.in new file mode 100644 index 000000000..9dd5f1f2e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/6648-1_xin.in @@ -0,0 +1 @@ +Kofi A. Annan diff --git a/libstdc++-v3/testsuite/27_io/objects/char/6648-2_xin.cc b/libstdc++-v3/testsuite/27_io/objects/char/6648-2_xin.cc new file mode 100644 index 000000000..a6b6e71f8 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/6648-2_xin.cc @@ -0,0 +1,34 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 + +void test09() +{ + bool test __attribute__((unused)) = true; + std::cout << "Enter favorite beach: "; + std::cin.ignore(2048, '\n'); +} + +int +main() +{ + test09(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/6648-2_xin.in b/libstdc++-v3/testsuite/27_io/objects/char/6648-2_xin.in new file mode 100644 index 000000000..0b2c7cf28 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/6648-2_xin.in @@ -0,0 +1 @@ +Oak St. Beach, Chicago diff --git a/libstdc++-v3/testsuite/27_io/objects/char/7.cc b/libstdc++-v3/testsuite/27_io/objects/char/7.cc new file mode 100644 index 000000000..fcb6e21e9 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/7.cc @@ -0,0 +1,86 @@ +// { dg-require-fork "" } +// { dg-require-mkfifo "" } + +// 2003-04-26 Petur Runolfsson + +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 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 +// . + +// 27.3 Standard iostream objects + +#include +#include +#include +#include +#include +#include +#include +#include + +// No asserts, avoid leaking the semaphore if a VERIFY fails. +#undef _GLIBCXX_ASSERT + +#include + +// Check that cout.flush() is called when last ios_base::Init is destroyed. +bool test07() +{ + using namespace std; + using namespace __gnu_test; + bool test __attribute__((unused)) = true; + + const char* name = "tmp_fifo4"; + + signal(SIGPIPE, SIG_IGN); + + unlink(name); + mkfifo(name, S_IRWXU); + semaphore s1; + + int child = fork(); + VERIFY( child != -1 ); + + if (child == 0) + { + filebuf fbout; + fbout.open(name, ios_base::in|ios_base::out); + VERIFY( fbout.is_open() ); + s1.wait(); + cout.rdbuf(&fbout); + fbout.sputc('a'); + // NB: fbout is *not* destroyed here! + exit(0); + } + + filebuf fbin; + fbin.open(name, ios_base::in); + s1.signal(); + filebuf::int_type c = fbin.sbumpc(); + VERIFY( c != filebuf::traits_type::eof() ); + VERIFY( c == filebuf::traits_type::to_int_type('a') ); + + fbin.close(); + + return test; +} + +int +main() +{ + return !test07(); +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/7744_xin.cc b/libstdc++-v3/testsuite/27_io/objects/char/7744_xin.cc new file mode 100644 index 000000000..b2577f9bf --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/7744_xin.cc @@ -0,0 +1,41 @@ +// 2000-08-02 bkoz + +// Copyright (C) 2000, 2001, 2002, 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 + +// libstdc++/7744 +void test11() +{ + bool test __attribute__((unused)) = true; + std::ios::sync_with_stdio(false); + + std::cout << "Type in the characters 'abc' and press : "; + std::cin.peek(); + + // The number of unread characters should be 4 (a, b, c, \\n) + VERIFY( 4 == std::cin.rdbuf()->in_avail() ); +} + +int +main() +{ + test11(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/7744_xin.in b/libstdc++-v3/testsuite/27_io/objects/char/7744_xin.in new file mode 100644 index 000000000..8baef1b4a --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/7744_xin.in @@ -0,0 +1 @@ +abc diff --git a/libstdc++-v3/testsuite/27_io/objects/char/8.cc b/libstdc++-v3/testsuite/27_io/objects/char/8.cc new file mode 100644 index 000000000..8c22690f7 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/8.cc @@ -0,0 +1,50 @@ +// 2003-04-28 Benjamin Kosnik + +// 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.3 - Standard iostream objects p 2 + +#include +#include + +void test02() +{ + bool test __attribute__((unused)) = true; + + // 27.3 - Standard iostream objects p 2 + // The objects are not destroyed during program execution. + void* p1 = &std::cout; + void* p2 = &std::cin; + void* p3 = &std::cerr; + void* p4 = &std::clog; + std::ios_base::sync_with_stdio(false); + void* p1s = &std::cout; + void* p2s = &std::cin; + void* p3s = &std::cerr; + void* p4s = &std::clog; + VERIFY( p1 == p1s ); + VERIFY( p2 == p2s ); + VERIFY( p3 == p3s ); + VERIFY( p4 == p4s ); +} + +int main(void) +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/9.cc b/libstdc++-v3/testsuite/27_io/objects/char/9.cc new file mode 100644 index 000000000..e4905bb46 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/9.cc @@ -0,0 +1,48 @@ +// 2003-05-01 Petur Runolfsson + +// Copyright (C) 2003, 2004, 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 +// . + +// { dg-require-fileio "" } + +#include +#include +#include + +void test09() +{ + using namespace std; + + bool test __attribute__((unused)) = true; + const char* name = "tmp_09"; + + FILE* fout = fopen(name, "w"); + fputs("abc\n", fout); + fclose(fout); + + VERIFY( freopen(name, "r", stdin) ); + + // basic_streambuf::showmanyc returns 0. + VERIFY( 0 == std::cin.rdbuf()->in_avail() ); +} + +int +main() +{ + test09(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc b/libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc new file mode 100644 index 000000000..8ca77c76e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc @@ -0,0 +1,99 @@ +// { dg-require-fork "" } +// { dg-require-mkfifo "" } + +// 2003-04-30 Petur Runolfsson + +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010 +// 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 +// . + +// No asserts, avoid leaking the semaphores if a VERIFY fails. +#undef _GLIBCXX_ASSERT + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Check that cin.rdbuf()->sputbackc() puts characters back to stdin. +// If cin.rdbuf() is a filebuf, this succeeds when stdin is a regular +// file, but fails otherwise, hence the named fifo. +bool test01() +{ + using namespace std; + using namespace __gnu_test; + + bool test __attribute__((unused)) = true; + + const char* name = "tmp_fifo5"; + + signal(SIGPIPE, SIG_IGN); + + unlink(name); + mkfifo(name, S_IRWXU); + semaphore s1, s2; + + int child = fork(); + VERIFY( child != -1 ); + + if (child == 0) + { + FILE* file = fopen(name, "r+"); + VERIFY( file != 0 ); + fputs("Whatever\n", file); + fflush(file); + s1.signal(); + s2.wait(); + fclose(file); + s1.signal(); + exit(0); + } + + VERIFY( freopen(name, "r", stdin) ); + s1.wait(); + + int c1 = fgetc(stdin); + VERIFY( c1 != EOF ); + int c2 = cin.rdbuf()->sputbackc('a'); + VERIFY( c2 != EOF ); + VERIFY( c2 == 'a' ); + + int c3 = fgetc(stdin); + VERIFY( c3 != EOF ); + VERIFY( c3 == c2 ); + int c4 = ungetc('b', stdin); + VERIFY( c4 != EOF ); + VERIFY( c4 == 'b' ); + + int c5 = cin.rdbuf()->sgetc(); + VERIFY( c5 != EOF ); + VERIFY( c5 == c4 ); + s2.signal(); + s1.wait(); + + return test; +} + +int main() +{ + return !test01(); +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.cc b/libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.cc new file mode 100644 index 000000000..f91f9508e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.cc @@ -0,0 +1,46 @@ +// 2003-04-30 Petur Runolfsson + +// 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 + +void test02() +{ + using namespace std; + + bool test __attribute__((unused)) = true; + + int c1 = fgetc(stdin); + int c2 = cin.rdbuf()->sputbackc(c1); + VERIFY( c2 == c1 ); + + int c3 = fgetc(stdin); + VERIFY( c3 == c1 ); + ungetc(c3, stdin); + + int c4 = cin.rdbuf()->sgetc(); + VERIFY( c4 == c3 ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.in b/libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.in new file mode 100644 index 000000000..ad9013028 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.in @@ -0,0 +1 @@ +For what you dream of diff --git a/libstdc++-v3/testsuite/27_io/objects/char/dr455.cc b/libstdc++-v3/testsuite/27_io/objects/char/dr455.cc new file mode 100644 index 000000000..ac464eca7 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/objects/char/dr455.cc @@ -0,0 +1,36 @@ +// 2006-03-08 Paolo Carlini + +// Copyright (C) 2006, 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 + +// DR 455. cerr::tie() and wcerr::tie() are overspecified. +void test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY( std::cerr.tie() == &std::cout ); +} + +int +main() +{ + test01(); + return 0; +} -- cgit v1.2.3