summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_ofstream
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/27_io/basic_ofstream
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
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.
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_ofstream')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ofstream/cons/2020.cc54
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ofstream/cons/char/1.cc50
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ofstream/cons/char/2.cc27
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/1.cc60
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/2.cc31
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ofstream/pthread2.cc60
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ofstream/rdbuf/char/2832.cc71
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/base_classes.cc44
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/explicit_instantiation.cc31
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/typedefs.cc37
10 files changed, 465 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/2020.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/2020.cc
new file mode 100644
index 000000000..b1594112e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/2020.cc
@@ -0,0 +1,54 @@
+// 1999-01-17 bkoz test functionality of basic_filebuf for char_type == char
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.1 - Template class basic_filebuf
+// NB: This file is for testing basic_filebuf with NO OTHER INCLUDES.
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+// libstdc++/2020
+// should be able to use custom char_type, custom traits type
+void test07()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_ofstream<__gnu_test::pod_ushort> gnu_ofstr;
+
+ try
+ {
+ gnu_ofstr obj;
+ }
+ catch(std::exception& obj)
+ {
+ test = false;
+ VERIFY( test );
+ }
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
+
+
+
+// more surf!!!
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/char/1.cc
new file mode 100644
index 000000000..6b84f36d1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/char/1.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2000, 2001, 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.10 ofstream member functions
+// @require@ %-*.tst
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+
+#include <ostream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+const char name_02[] = "ofstream_members-1.txt";
+
+// http://gcc.gnu.org/ml/libstdc++/2000-07/msg00004.html
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ const int more_than_max_open_files = 8200;
+
+ for(int i = 0; ++i < more_than_max_open_files;)
+ {
+ std::ofstream ifs(name_02);
+ VERIFY( static_cast<bool>(ifs) );
+ }
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
+
+
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/char/2.cc
new file mode 100644
index 000000000..ecdb5c1af
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/char/2.cc
@@ -0,0 +1,27 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <fstream>
+
+void test01()
+{
+ const std::string name = "ofstream_name.txt";
+ std::ofstream ofs(name);
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/1.cc
new file mode 100644
index 000000000..f7805c28c
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/1.cc
@@ -0,0 +1,60 @@
+// Copyright (C) 2000, 2001, 2003, 2005, 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.10 ofstream member functions
+// @require@ %-*.tst
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+
+#include <ostream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+const char name_01[] = "ofstream_members-1.tst";
+const char name_02[] = "ofstream_members-1.txt";
+
+// http://gcc.gnu.org/ml/libstdc++/2000-06/msg00136.html
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::ofstream ofs1;
+ ofs1.close();
+
+ // false as expected:
+ VERIFY( !ofs1.is_open() );
+ // this is now true:
+ VERIFY( !(ofs1) );
+
+ ofs1.open(name_02);
+ VERIFY( ofs1.is_open() );
+
+ // As per the resolution of DR 409.
+ VERIFY( (ofs1) );
+ VERIFY( ofs1.rdstate() == std::ios_base::goodbit );
+
+ ofs1.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
+
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/2.cc
new file mode 100644
index 000000000..395d84952
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/2.cc
@@ -0,0 +1,31 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <fstream>
+
+void test01()
+{
+ std::ofstream ofs;
+
+ const std::string name = "ofstream_name.txt";
+ ofs.open(name);
+
+ ofs.close();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/pthread2.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/pthread2.cc
new file mode 100644
index 000000000..cb683666c
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/pthread2.cc
@@ -0,0 +1,60 @@
+// 2002-01-23 Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
+// Adpated from libstdc++/5347 submitted by markus.breuer@materna.de
+//
+// Copyright (C) 2002, 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthreads" { target *-*-solaris* } }
+
+#include <fstream>
+#include <pthread.h>
+
+const int max_thread_count = 2;
+const int max_loop_count = 1000000;
+
+void*
+thread_main (void *)
+{
+ for (int i = 0; i < max_loop_count; i++)
+ {
+ std::ofstream* pos1 = new std::ofstream;
+ delete pos1;
+ }
+
+ return 0;
+}
+
+int
+main()
+{
+ pthread_t tid[max_thread_count];
+
+#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
+ pthread_setconcurrency (max_thread_count);
+#endif
+
+ for (int i = 0; i < max_thread_count; i++)
+ pthread_create (&tid[i], 0, thread_main, 0);
+
+ for (int i = 0; i < max_thread_count; i++)
+ pthread_join (tid[i], 0);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/rdbuf/char/2832.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/rdbuf/char/2832.cc
new file mode 100644
index 000000000..7bed0d25e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/rdbuf/char/2832.cc
@@ -0,0 +1,71 @@
+// Copyright (C) 2000, 2001, 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.10 ofstream member functions
+// @require@ %-*.tst
+// @diff@ %-*.tst %-*.txt
+
+#include <ostream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+const char name_01[] = "ofstream_members-1.tst";
+
+void
+redirect_buffer(std::ios& stream, std::streambuf* new_buf)
+{ stream.rdbuf(new_buf); }
+
+std::streambuf*
+active_buffer(std::ios& stream)
+{ return stream.rdbuf(); }
+
+// libstdc++/2832
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const char* strlit01 = "fuck war";
+ const std::string str00;
+ const std::string str01(strlit01);
+ std::string str02;
+ std::filebuf fbuf;
+ std::streambuf* pbasebuf0 = &fbuf;
+
+ std::ofstream sstrm1;
+ // derived rdbuf() always returns original streambuf, even though
+ // it's no longer associated with the stream.
+ std::filebuf* const buf1 = sstrm1.rdbuf();
+ // base rdbuf() returns the currently associated streambuf
+ std::streambuf* pbasebuf1 = active_buffer(sstrm1);
+ redirect_buffer(sstrm1, &fbuf);
+ std::filebuf* const buf2 = sstrm1.rdbuf();
+ std::streambuf* pbasebuf2 = active_buffer(sstrm1);
+ VERIFY( buf1 == buf2 );
+ VERIFY( pbasebuf1 != pbasebuf2 );
+ VERIFY( pbasebuf2 == pbasebuf0 );
+
+ // How confusing and non-intuitive is this?
+ // These semantics are a joke, a serious defect, and incredibly lame.
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
+
+
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/base_classes.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/base_classes.cc
new file mode 100644
index 000000000..30380f8f2
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/base_classes.cc
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// 2003-03-26 B enjamin Kosnik <bkoz@redhat.com>
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.1 - Template class basic_filebuf
+
+#include <ostream>
+#include <fstream>
+
+void test01()
+{
+ // Check for required base class.
+ typedef std::ofstream test_type;
+ typedef std::ostream base_type;
+ const test_type& obj = *new test_type();
+ const base_type* base __attribute__((unused)) = &obj;
+}
+
+// more surf!!!
+
+
+
+
+
+
+
+
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/explicit_instantiation.cc
new file mode 100644
index 000000000..54a9e80f8
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/explicit_instantiation.cc
@@ -0,0 +1,31 @@
+// { dg-do compile }
+// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2002, 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
+// <http://www.gnu.org/licenses/>.
+
+
+// 27.8.1.8 - Template class basic_ofstream
+// NB: This file is for testing basic_ofstream with NO OTHER INCLUDES.
+
+#include <fstream>
+
+namespace std
+{
+ typedef short type_t;
+ template class basic_ifstream<type_t, char_traits<type_t> >;
+} // test
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/typedefs.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/typedefs.cc
new file mode 100644
index 000000000..22b20f4ea
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/requirements/typedefs.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+// 27.8.1.8 - Template class basic_ofstream
+// NB: This file is for testing basic_ofstream with NO OTHER INCLUDES.
+
+#include <fstream>
+
+// libstdc++/7216
+void test01()
+{
+ // Check for required typedefs
+ typedef std::ifstream test_type;
+ typedef test_type::char_type char_type;
+ typedef test_type::traits_type traits_type;
+ typedef test_type::int_type int_type;
+ typedef test_type::pos_type pos_type;
+ typedef test_type::off_type off_type;
+}