This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3, libstdcxx_so_7] Prep work on the basic_string testsuite


Hi,

tested x86-linux, committed to the branch.

Paolo.

///////////
2005-02-10  Paolo Carlini  <pcarlini@suse.de>

	* testsuite/21_strings/basic_string/capacity/1.c: Tweak,
	avoid the assumption that the capacity of a default constructed
	string is zero.
	* testsuite/21_strings/basic_string/capacity/char/1.cc: Same.
	* testsuite/21_strings/basic_string/capacity/char/18654.cc: Same.
	* testsuite/21_strings/basic_string/capacity/char/2.cc: Same.
	* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Same.
	* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc: Same.
	* testsuite/21_strings/basic_string/capacity/wchar_t/2.cc: Same.

	* testsuite/21_strings/basic_string/swap/char/1.cc: New.
	* testsuite/21_strings/basic_string/swap/wchar_t/1.cc: Same.
diff -urN libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/1.cc libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc
--- libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/1.cc	2004-04-19 20:59:59.000000000 +0200
+++ libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc	2005-02-10 19:05:38.000000000 +0100
@@ -1,6 +1,7 @@
 // 1999-05-11 bkoz
 
-// Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2002, 2003, 2004, 2005
+// 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
@@ -139,8 +140,8 @@
   VERIFY( sz04 >= sz03 );
   VERIFY( sz04 >= 100 );
   str02.reserve();
-  sz03 = str02.capacity();
-  VERIFY( sz03 == 0 );
+  sz04 = str02.capacity();
+  VERIFY( sz04 == sz03 );
 
   sz03 = str02.size() + 5;
   str02.resize(sz03);
diff -urN libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/char/1.cc libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc
--- libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/char/1.cc	2004-04-19 20:59:59.000000000 +0200
+++ libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc	2005-02-10 19:06:14.000000000 +0100
@@ -1,6 +1,7 @@
 // 1999-05-11 bkoz
 
-// Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2002, 2003, 2004, 2005
+// 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
@@ -36,8 +37,8 @@
   VERIFY( sz02 >= sz01 );
   VERIFY( sz02 >= 100 );
   str01.reserve();
-  sz01 = str01.capacity();
-  VERIFY( sz01 == 0 );
+  sz02 = str01.capacity();
+  VERIFY( sz02 == sz01 );
 
   sz01 = str01.size() + 5;
   str01.resize(sz01);
diff -urN libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/char/18654.cc libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/18654.cc
--- libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/char/18654.cc	2004-12-06 12:13:04.000000000 +0100
+++ libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/18654.cc	2005-02-10 19:11:22.000000000 +0100
@@ -1,6 +1,6 @@
 // 2004-11-29  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2004 Free Software Foundation
+// Copyright (C) 2004, 2005 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
@@ -34,8 +34,8 @@
   // Our current implementation provides exact shrink-to-size
   // and shrink-to-fit (in the future, maybe this will change
   // for short strings).
-  const size_type minsize = 2 << 0;
-  const size_type maxsize = 2 << 20;
+  const size_type minsize = 1 << 6;
+  const size_type maxsize = 1 << 20;
   for (size_type i = minsize; i <= maxsize; i *= 2)
     {
       string str(i, 'x');
diff -urN libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/char/2.cc libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/2.cc
--- libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/char/2.cc	2003-09-23 22:02:06.000000000 +0200
+++ libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/2.cc	2005-02-10 19:13:58.000000000 +0100
@@ -1,6 +1,6 @@
 // 1999-05-11 bkoz
 
-// Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2002, 2003, 2005 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
@@ -33,7 +33,7 @@
   // str01 becomes shared
   std::string str02 = str01;
   str01.reserve(1);
-  VERIFY( str01.capacity() == 12 );
+  VERIFY( str01.capacity() >= 12 );
 }
 
 int main()
diff -urN libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc
--- libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc	2004-04-19 20:59:59.000000000 +0200
+++ libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc	2005-02-10 19:07:38.000000000 +0100
@@ -1,6 +1,7 @@
 // 1999-05-11 bkoz
 
-// Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2002, 2003, 2004, 2005
+// 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
@@ -36,8 +37,8 @@
   VERIFY( sz02 >= sz01 );
   VERIFY( sz02 >= 100 );
   str01.reserve();
-  sz01 = str01.capacity();
-  VERIFY( sz01 == 0 );
+  sz02 = str01.capacity();
+  VERIFY( sz02 == sz01 );
 
   sz01 = str01.size() + 5;
   str01.resize(sz01);
diff -urN libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc
--- libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc	2004-12-06 12:13:05.000000000 +0100
+++ libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc	2005-02-10 19:11:36.000000000 +0100
@@ -1,6 +1,6 @@
 // 2004-11-29  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2004 Free Software Foundation
+// Copyright (C) 2004, 2005 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
@@ -34,8 +34,8 @@
   // Our current implementation provides exact shrink-to-size
   // and shrink-to-fit (in the future, maybe this will change
   // for short strings).
-  const size_type minsize = 2 << 0;
-  const size_type maxsize = 2 << 20;
+  const size_type minsize = 1 << 6;
+  const size_type maxsize = 1 << 20;
   for (size_type i = minsize; i <= maxsize; i *= 2)
     {
       wstring str(i, L'x');
diff -urN libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/wchar_t/2.cc libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/2.cc
--- libstdc++-v3-orig/testsuite/21_strings/basic_string/capacity/wchar_t/2.cc	2003-09-23 22:02:06.000000000 +0200
+++ libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/2.cc	2005-02-10 19:14:23.000000000 +0100
@@ -1,6 +1,6 @@
 // 1999-05-11 bkoz
 
-// Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2002, 2003, 2005 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
@@ -33,7 +33,7 @@
   // str01 becomes shared
   std::wstring str02 = str01;
   str01.reserve(1);
-  VERIFY( str01.capacity() == 12 );
+  VERIFY( str01.capacity() >= 12 );
 }
 
 int main()
diff -urN libstdc++-v3-orig/testsuite/21_strings/basic_string/swap/char/1.cc libstdc++-v3/testsuite/21_strings/basic_string/swap/char/1.cc
--- libstdc++-v3-orig/testsuite/21_strings/basic_string/swap/char/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/21_strings/basic_string/swap/char/1.cc	2005-02-10 22:12:50.000000000 +0100
@@ -0,0 +1,123 @@
+// 2005-02-10  Paolo Carlini  <pcarlini@suse.de>
+
+// Copyright (C) 2005 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 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.5.8 basic_string::swap
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// A few basic tests...
+void
+test01()
+{
+  bool test __attribute__((unused)) = true;
+  using namespace std;
+
+  const char* title00 = "";
+  const char* title01 = "Rivers of sand";
+  const char* title02 = "Concret PH";
+  const char* title03 = "Sonatas and Interludes for Prepared Piano";
+  const char* title04 = "never as tired as when i'm waking up";
+
+  string::size_type size01, size02;
+
+  string str01 = title00;
+  size01 = str01.size();
+  string str02 = title00;
+  size02 = str02.size();
+  
+  str01.swap(str02);
+  VERIFY( str01.size() == size02 );
+  VERIFY( str01 == title00 );
+  VERIFY( str02.size() == size01 );
+  VERIFY( str02 == title00 );
+
+  string str03 = title00;
+  size01 = str03.size();
+  string str04 = title02;
+  size02 = str04.size();
+  
+  str03.swap(str04);
+  VERIFY( str03.size() == size02 );
+  VERIFY( str03 == title02 );
+  VERIFY( str04.size() == size01 );
+  VERIFY( str04 == title00 );
+  
+  string str05 = title01;
+  size01 = str05.size();
+  string str06 = title02;
+  size02 = str06.size();
+  
+  str05.swap(str06);
+  VERIFY( str05.size() == size02 );
+  VERIFY( str05 == title02 );
+  VERIFY( str06.size() == size01 );
+  VERIFY( str06 == title01 );
+
+  string str07 = title01;
+  size01 = str07.size();
+  string str08 = title03;
+  size02 = str08.size();
+
+  str07.swap(str08);
+  VERIFY( str07.size() == size02 );
+  VERIFY( str07 == title03 );
+  VERIFY( str08.size() == size01 );
+  VERIFY( str08 == title01 );
+
+  string str09 = title03;
+  size01 = str09.size();
+  string str10 = title04;
+  size02 = str10.size();
+
+  str09.swap(str10);
+  VERIFY( str09.size() == size02 );
+  VERIFY( str09 == title04 );
+  VERIFY( str10.size() == size01 );
+  VERIFY( str10 == title03 );
+
+  string str11 = title04;
+  size01 = str11.size();
+  string str12 = title01;
+  size02 = str12.size();
+
+  str11.swap(str12);
+  VERIFY( str11.size() == size02 );
+  VERIFY( str11 == title01 );
+  VERIFY( str12.size() == size01 );
+  VERIFY( str12 == title04 );
+
+  string str13 = title03;
+  size01 = str13.size();
+  string str14 = title03;
+  size02 = str14.size();
+
+  str13.swap(str14);
+  VERIFY( str13.size() == size02 );
+  VERIFY( str13 == title03 );
+  VERIFY( str14.size() == size01 );
+  VERIFY( str14 == title03 );
+}
+
+int main()
+{ 
+  test01();
+  return 0;
+}
diff -urN libstdc++-v3-orig/testsuite/21_strings/basic_string/swap/wchar_t/1.cc libstdc++-v3/testsuite/21_strings/basic_string/swap/wchar_t/1.cc
--- libstdc++-v3-orig/testsuite/21_strings/basic_string/swap/wchar_t/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/21_strings/basic_string/swap/wchar_t/1.cc	2005-02-10 22:13:03.000000000 +0100
@@ -0,0 +1,123 @@
+// 2005-02-10  Paolo Carlini  <pcarlini@suse.de>
+
+// Copyright (C) 2005 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 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.5.8 basic_string::swap
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// A few basic tests...
+void
+test01()
+{
+  bool test __attribute__((unused)) = true;
+  using namespace std;
+
+  const wchar_t* title00 = L"";
+  const wchar_t* title01 = L"Rivers of sand";
+  const wchar_t* title02 = L"Concret PH";
+  const wchar_t* title03 = L"Sonatas and Interludes for Prepared Piano";
+  const wchar_t* title04 = L"never as tired as when i'm waking up";
+
+  wstring::size_type size01, size02;
+
+  wstring str01 = title00;
+  size01 = str01.size();
+  wstring str02 = title00;
+  size02 = str02.size();
+  
+  str01.swap(str02);
+  VERIFY( str01.size() == size02 );
+  VERIFY( str01 == title00 );
+  VERIFY( str02.size() == size01 );
+  VERIFY( str02 == title00 );
+
+  wstring str03 = title00;
+  size01 = str03.size();
+  wstring str04 = title02;
+  size02 = str04.size();
+  
+  str03.swap(str04);
+  VERIFY( str03.size() == size02 );
+  VERIFY( str03 == title02 );
+  VERIFY( str04.size() == size01 );
+  VERIFY( str04 == title00 );
+  
+  wstring str05 = title01;
+  size01 = str05.size();
+  wstring str06 = title02;
+  size02 = str06.size();
+  
+  str05.swap(str06);
+  VERIFY( str05.size() == size02 );
+  VERIFY( str05 == title02 );
+  VERIFY( str06.size() == size01 );
+  VERIFY( str06 == title01 );
+
+  wstring str07 = title01;
+  size01 = str07.size();
+  wstring str08 = title03;
+  size02 = str08.size();
+
+  str07.swap(str08);
+  VERIFY( str07.size() == size02 );
+  VERIFY( str07 == title03 );
+  VERIFY( str08.size() == size01 );
+  VERIFY( str08 == title01 );
+
+  wstring str09 = title03;
+  size01 = str09.size();
+  wstring str10 = title04;
+  size02 = str10.size();
+
+  str09.swap(str10);
+  VERIFY( str09.size() == size02 );
+  VERIFY( str09 == title04 );
+  VERIFY( str10.size() == size01 );
+  VERIFY( str10 == title03 );
+
+  wstring str11 = title04;
+  size01 = str11.size();
+  wstring str12 = title01;
+  size02 = str12.size();
+
+  str11.swap(str12);
+  VERIFY( str11.size() == size02 );
+  VERIFY( str11 == title01 );
+  VERIFY( str12.size() == size01 );
+  VERIFY( str12 == title04 );
+
+  wstring str13 = title03;
+  size01 = str13.size();
+  wstring str14 = title03;
+  size02 = str14.size();
+
+  str13.swap(str14);
+  VERIFY( str13.size() == size02 );
+  VERIFY( str13 == title03 );
+  VERIFY( str14.size() == size01 );
+  VERIFY( str14 == title03 );
+}
+
+int main()
+{ 
+  test01();
+  return 0;
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]