This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: [patch] Some testsuite cleanup


On 28/07/16 22:06 +0100, Jonathan Wakely wrote:
When I added _Temporary_object to vector recently I updated the
construct/destroy counts in this test to match, but the changes only
apply for C++11 and later. This makes the test pass whether run as
C++98 or C++11 and later.

  Fix std::vector test to pass in C++98 mode
      * testsuite/23_containers/vector/check_construct_destroy.cc: Account
      for different construct/destroy counts in C++98 mode.

The same change is needed for a __gnu_cxx::hash_set test, because that
container uses std::vector internally:

   Fix __gnu_cxx::hash_set test to pass in C++98 mode
* testsuite/backward/hash_set/check_construct_destroy.cc: Account
       for different construct/destroy counts in C++98 mode.

Tested x86_64-linux, committed to trunk.


commit efb4d741206e916e7457ee90867d2de3501d2a06
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Aug 1 13:40:20 2016 +0100

    Fix __gnu_cxx::hash_set test to pass in C++98 mode
    
    	* testsuite/backward/hash_set/check_construct_destroy.cc: Account
    	for different construct/destroy counts in C++98 mode.

diff --git a/libstdc++-v3/testsuite/backward/hash_set/check_construct_destroy.cc b/libstdc++-v3/testsuite/backward/hash_set/check_construct_destroy.cc
index 5740fe1..821cb29 100644
--- a/libstdc++-v3/testsuite/backward/hash_set/check_construct_destroy.cc
+++ b/libstdc++-v3/testsuite/backward/hash_set/check_construct_destroy.cc
@@ -39,48 +39,50 @@ int main()
 
   int buckets;
 
-  // Add 1 to all counts, because the std::vector used internally by the
-  // hashtable creates and destroys a temporary object using the allocator.
+  // For C++11 and later add 1 to all counts, because the std::vector used
+  // internally by the hashtable creates and destroys a temporary object
+  // using its allocator.
+  const int extra = __cplusplus >= 201102L ? 1 : 0;
 
   tracker_allocator_counter::reset();
   {
     Container c;
     buckets = c.bucket_count();
-    ok = check_construct_destroy("empty container", buckets+1, 1) && ok;
+    ok = check_construct_destroy("empty container", buckets+extra, extra) && ok;
   }
-  ok = check_construct_destroy("empty container", buckets+1, buckets+1) && ok;
+  ok = check_construct_destroy("empty container", buckets+extra, buckets+extra) && ok;
 
 
   tracker_allocator_counter::reset();
   {
     Container c(arr10, arr10 + 10);
-    ok = check_construct_destroy("Construct from range", buckets+10+1, 1) && ok;
+    ok = check_construct_destroy("Construct from range", buckets+10+extra, extra) && ok;
   }
-  ok = check_construct_destroy("Construct from range", buckets+10+1, buckets+10+1) && ok;
+  ok = check_construct_destroy("Construct from range", buckets+10+extra, buckets+10+extra) && ok;
 
   tracker_allocator_counter::reset();
   {
     Container c(arr10, arr10 + 10);
     c.insert(arr10a[0]);
-    ok = check_construct_destroy("Insert element", buckets+11+1, 1) && ok;
+    ok = check_construct_destroy("Insert element", buckets+11+extra, extra) && ok;
   }
-  ok = check_construct_destroy("Insert element", buckets+11+1, buckets+11+1) && ok;
+  ok = check_construct_destroy("Insert element", buckets+11+extra, buckets+11+extra) && ok;
 
   tracker_allocator_counter::reset();
   {
     Container c(arr10, arr10 + 10);
     c.insert(arr10a, arr10a+3);
-    ok = check_construct_destroy("Insert short range", buckets+13+1, 1) && ok;
+    ok = check_construct_destroy("Insert short range", buckets+13+extra, extra) && ok;
   }
-  ok = check_construct_destroy("Insert short range", buckets+13+1, buckets+13+1) && ok;
+  ok = check_construct_destroy("Insert short range", buckets+13+extra, buckets+13+extra) && ok;
 
   tracker_allocator_counter::reset();
   {
     Container c(arr10, arr10 + 10);
     c.insert(arr10a, arr10a+10);
-    ok = check_construct_destroy("Insert long range", buckets+20+1, 1) && ok;
+    ok = check_construct_destroy("Insert long range", buckets+20+extra, extra) && ok;
   }
-  ok = check_construct_destroy("Insert long range", buckets+20+1, buckets+20+1) && ok;
+  ok = check_construct_destroy("Insert long range", buckets+20+extra, buckets+20+extra) && ok;
 
   return ok ? 0 : 1;
 }

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