10.cc: New.
authorPaolo Carlini <pcarlini@suse.de>
Sun, 25 Apr 2004 12:56:41 +0000 (12:56 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 25 Apr 2004 12:56:41 +0000 (12:56 +0000)
2004-04-25  Paolo Carlini  <pcarlini@suse.de>

* testsuite/21_strings/basic_string/inserters_extractors/char/10.cc:
New.
* testsuite/21_strings/basic_string/inserters_extractors/wchar_t/10.cc:
Likewise.
* testsuite/27_io/basic_istream/getline/char/5.cc: Likewise.

From-SVN: r81159

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/10.cc [new file with mode: 0644]
libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/10.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_istream/getline/char/5.cc [new file with mode: 0644]

index 0f1838ee43bfc63452eb78cf59a09608834dc515..0b728ee3ff62e34b2621c5081db0a852e36d34ed 100644 (file)
@@ -1,3 +1,11 @@
+2004-04-25  Paolo Carlini  <pcarlini@suse.de>
+
+       * testsuite/21_strings/basic_string/inserters_extractors/char/10.cc:
+       New.
+       * testsuite/21_strings/basic_string/inserters_extractors/wchar_t/10.cc:
+       Likewise.
+       * testsuite/27_io/basic_istream/getline/char/5.cc: Likewise.
+
 2004-04-24  Paolo Carlini  <pcarlini@suse.de>
            Petur Runolfsson  <peturr02@ru.is>
 
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/10.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/10.cc
new file mode 100644 (file)
index 0000000..75b7e89
--- /dev/null
@@ -0,0 +1,80 @@
+// Copyright (C) 2004 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 21.3.7.9 inserters and extractors
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+string prepare(string::size_type len, unsigned nchunks, char delim)
+{
+  string ret;
+  for (unsigned i = 0; i < nchunks; ++i)
+    {
+      for (string::size_type j = 0; j < len; ++j)
+       ret.push_back('a' + rand() % 26);
+      len *= 2;
+      ret.push_back(delim);
+    }
+  return ret;
+}
+
+void check(istream& stream, const string& str, char delim)
+{
+  bool test __attribute__((unused)) = true;
+
+  string chunk;
+  string::size_type index = 0, index_new = 0;
+
+  while (getline(stream, chunk, delim))
+    {
+      index_new = str.find(delim, index);
+      VERIFY( !str.compare(index, index_new - index, chunk) );
+      index = index_new + 1;
+    }
+  VERIFY( stream.eof() );
+}
+
+// istream& getline(istream&, string&, char)
+void test01()
+{
+  const char filename[] = "inserters_extractors-2.txt";
+
+  const char delim = '|';
+  const string data = prepare(777, 10, delim);
+
+  ofstream ofstrm;
+  ofstrm.open(filename);
+  ofstrm.write(data.data(), data.size());
+  ofstrm.close();
+
+  ifstream ifstrm;
+  ifstrm.open(filename);
+  check(ifstrm, data, delim);
+  ifstrm.close();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/10.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/10.cc
new file mode 100644 (file)
index 0000000..5f1e1d7
--- /dev/null
@@ -0,0 +1,80 @@
+// Copyright (C) 2004 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 21.3.7.9 inserters and extractors
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+wstring prepare(wstring::size_type len, unsigned nchunks, wchar_t delim)
+{
+  wstring ret;
+  for (unsigned i = 0; i < nchunks; ++i)
+    {
+      for (wstring::size_type j = 0; j < len; ++j)
+       ret.push_back(L'a' + rand() % 26);
+      len *= 2;
+      ret.push_back(delim);
+    }
+  return ret;
+}
+
+void check(wistream& stream, const wstring& str, wchar_t delim)
+{
+  bool test __attribute__((unused)) = true;
+
+  wstring chunk;
+  wstring::size_type index = 0, index_new = 0;
+
+  while (getline(stream, chunk, delim))
+    {
+      index_new = str.find(delim, index);
+      VERIFY( !str.compare(index, index_new - index, chunk) );
+      index = index_new + 1;
+    }
+  VERIFY( stream.eof() );
+}
+
+// istream& getline(istream&, string&, char)
+void test01()
+{
+  const char filename[] = "inserters_extractors-2.txt";
+
+  const wchar_t delim = L'|';
+  const wstring data = prepare(777, 10, delim);
+
+  wofstream ofstrm;
+  ofstrm.open(filename);
+  ofstrm.write(data.data(), data.size());
+  ofstrm.close();
+
+  wifstream ifstrm;
+  ifstrm.open(filename);
+  check(ifstrm, data, delim);
+  ifstrm.close();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/5.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/5.cc
new file mode 100644 (file)
index 0000000..b2f0772
--- /dev/null
@@ -0,0 +1,81 @@
+// Copyright (C) 2004 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.6.1.3 unformatted input functions
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+string prepare(string::size_type len, unsigned nchunks, char delim)
+{
+  string ret;
+  for (unsigned i = 0; i < nchunks; ++i)
+    {
+      for (string::size_type j = 0; j < len; ++j)
+       ret.push_back('a' + rand() % 26);
+      len *= 2;
+      ret.push_back(delim);
+    }
+  return ret;
+}
+
+void check(istream& stream, const string& str, char delim)
+{
+  bool test __attribute__((unused)) = true;
+
+  char buf[1000000];
+  string::size_type index = 0, index_new = 0;
+
+  while (stream.getline(buf, sizeof(buf), delim))
+    {
+      index_new = str.find(delim, index);
+      VERIFY( stream.gcount() == index_new - index + 1 );
+      VERIFY( !str.compare(index, index_new - index, buf) );
+      index = index_new + 1;
+    }
+  VERIFY( stream.gcount() == 0 );
+  VERIFY( stream.eof() );
+}
+
+void test01()
+{
+  const char filename[] = "istream_getline.txt";
+
+  const char delim = '|';
+  const string data = prepare(777, 10, delim);
+
+  ofstream ofstrm;
+  ofstrm.open(filename);
+  ofstrm.write(data.data(), data.size());
+  ofstrm.close();
+
+  ifstream ifstrm;
+  ifstrm.open(filename);
+  check(ifstrm, data, delim);
+  ifstrm.close();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}