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]

[patch] Two small libstdc++ testsuite tweaks


For the custom pointer type in testsuite_allocator.h to satisfy the
RandomAccessIterator requirements it needs operator[], so this adds
it.

I'm not sure what 21_strings/basic_string/operators/char/1.cc was
testing originally, but we might as well verify the string contents
that the comments say we should get.

Tested powerpc64-linux, committed to trunk.
commit 5f8c6e72e56ecd9f69b6b5b59cdaa3d9b3fd7665
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Sep 10 19:56:28 2015 +0100

    	* testsuite/util/testsuite_allocator.h (PointerBase::operator[]): Add.

diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h
index 090e591..ebe7de0 100644
--- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -575,6 +575,7 @@ namespace __gnu_test
 
       T& operator*() const { return *value; }
       T* operator->() const { return value; }
+      T& operator[](difference_type n) const { return value[n]; }
 
       Derived& operator++() { ++value; return derived(); }
       Derived operator++(int) { Derived tmp(derived()); ++value; return tmp; }

commit d681f2458f4db6fc44f4e697e0f4bfac6455d1e2
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Sep 10 19:55:17 2015 +0100

    	* testsuite/21_strings/basic_string/operators/char/1.cc: Verify the
    	string contents.

diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc
index e52ab54..a43d7f8 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc
@@ -36,9 +36,11 @@ int test01(void)
   str1 = std::string("8-chars_") + "8-chars_";
   str1.c_str();
   // printf("1:%s\n", str1.c_str());
+  VERIFY( str1 == "8-chars_8-chars_" );
   str2 = str1 + "7-chars";
   // printf("2:%s\n", str1.c_str()); //str1 is gone
   str1.c_str();
+  VERIFY( str1 == "8-chars_8-chars_" );
   return 0;
 }
 

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