summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_istream/read
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_istream/read
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_istream/read')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/char/1.cc72
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/char/2.cc58
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/char/3.cc46
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/1.cc69
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/2.cc55
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/3.cc44
6 files changed, 344 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/1.cc
new file mode 100644
index 000000000..3879f7b42
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/1.cc
@@ -0,0 +1,72 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.6.1.3 unformatted input functions
+
+#include <cstring> // for strncmp,...
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ const std::string str_02("soul eyes: john coltrane quartet");
+
+ std::stringbuf isbuf_03(str_02, std::ios_base::in);
+ std::stringbuf isbuf_04(str_02, std::ios_base::in);
+
+ std::istream is_00(0);
+ std::istream is_03(&isbuf_03);
+ std::istream is_04(&isbuf_04);
+ std::ios_base::iostate state1, state2, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+
+ // istream& read(char_type* s, streamsize n)
+ char carray[60] = "";
+ state1 = is_04.rdstate();
+ is_04.read(carray, 0);
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+
+ state1 = is_04.rdstate();
+ is_04.read(carray, 9);
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !std::strncmp(carray, "soul eyes", 9) );
+ VERIFY( is_04.peek() == ':' );
+
+ state1 = is_03.rdstate();
+ is_03.read(carray, 60);
+ state2 = is_03.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & stateeof) );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( !std::strncmp(carray, "soul eyes: john coltrane quartet", 35) );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/2.cc
new file mode 100644
index 000000000..acb1b800a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/2.cc
@@ -0,0 +1,58 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.6.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// Jim Parsons <parsons at clearway dot com>
+// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00177.html
+void
+test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::string str_00("Red_Garland_Qunitet-Soul_Junction");
+ char c_array[str_00.size() + 4];
+
+ std::stringbuf isbuf_00(str_00, std::ios_base::in);
+ std::istream is_00(&isbuf_00);
+ std::ios_base::iostate state1, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+
+ state1 = stateeof | statefail;
+ VERIFY( is_00.gcount() == 0 );
+ is_00.read(c_array, str_00.size() + 1);
+ VERIFY( is_00.gcount() == static_cast<std::streamsize>(str_00.size()) );
+ VERIFY( is_00.rdstate() == state1 );
+
+ is_00.read(c_array, str_00.size());
+ VERIFY( is_00.rdstate() == state1 );
+}
+
+int
+main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/3.cc
new file mode 100644
index 000000000..c3c7769d4
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/3.cc
@@ -0,0 +1,46 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.6.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// Theodore Papadopoulo
+void
+test09()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ istringstream iss("Juana Briones");
+ char tab[13];
+ iss.read(tab, 13);
+ if (!iss)
+ test = false;
+ VERIFY( test );
+}
+
+int
+main()
+{
+ test09();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/1.cc
new file mode 100644
index 000000000..508e0c8cb
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/1.cc
@@ -0,0 +1,69 @@
+// Copyright (C) 2004, 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.6.1.3 unformatted input functions
+
+#include <cwchar> // for wcsncmp,...
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ const std::wstring str_02(L"soul eyes: john coltrane quartet");
+
+ std::wstringbuf isbuf_03(str_02, std::ios_base::in);
+ std::wstringbuf isbuf_04(str_02, std::ios_base::in);
+
+ std::wistream is_00(0);
+ std::wistream is_03(&isbuf_03);
+ std::wistream is_04(&isbuf_04);
+ std::ios_base::iostate state1, state2, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+
+ // istream& read(char_type* s, streamsize n)
+ wchar_t carray[60] = L"";
+ state1 = is_04.rdstate();
+ is_04.read(carray, 0);
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+
+ state1 = is_04.rdstate();
+ is_04.read(carray, 9);
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !std::wcsncmp(carray, L"soul eyes", 9) );
+ VERIFY( is_04.peek() == L':' );
+
+ state1 = is_03.rdstate();
+ is_03.read(carray, 60);
+ state2 = is_03.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & stateeof) );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( !std::wcsncmp(carray, L"soul eyes: john coltrane quartet", 35) );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/2.cc
new file mode 100644
index 000000000..2ea0b663d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/2.cc
@@ -0,0 +1,55 @@
+// Copyright (C) 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.6.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// Jim Parsons <parsons at clearway dot com>
+// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00177.html
+void
+test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::wstring str_00(L"Red_Garland_Qunitet-Soul_Junction");
+ wchar_t c_array[str_00.size() + 4];
+
+ std::wstringbuf isbuf_00(str_00, std::ios_base::in);
+ std::wistream is_00(&isbuf_00);
+ std::ios_base::iostate state1, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+
+ state1 = stateeof | statefail;
+ VERIFY( is_00.gcount() == 0 );
+ is_00.read(c_array, str_00.size() + 1);
+ VERIFY( is_00.gcount() == static_cast<std::streamsize>(str_00.size()) );
+ VERIFY( is_00.rdstate() == state1 );
+
+ is_00.read(c_array, str_00.size());
+ VERIFY( is_00.rdstate() == state1 );
+}
+
+int
+main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/3.cc
new file mode 100644
index 000000000..0de14bdd8
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/3.cc
@@ -0,0 +1,44 @@
+// Copyright (C) 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
+// <http://www.gnu.org/licenses/>.
+
+// 27.6.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// Theodore Papadopoulo
+void
+test09()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wistringstream iss(L"Juana Briones");
+ wchar_t tab[13];
+ iss.read(tab, 13);
+ if (!iss)
+ test = false;
+ VERIFY( test );
+}
+
+int
+main()
+{
+ test09();
+ return 0;
+}