Hi

    No problem detected now that we really test std::deque shrink_to_fit implementation.

    libstdc++: Add std::deque<>::shrink_to_fit test

    The existing test is currently testing std::vector. Make it test std::deque.

    libstdc++-v3/ChangeLog:

            * testsuite/23_containers/deque/capacity/shrink_to_fit.cc: Adapt test
            to check std::deque shrink_to_fit method.

Tested under Linux x64.

Ok to commit ?

François
diff --git 
a/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc 
b/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc
index 7cb67079214..57e66de70f4 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc
@@ -1,4 +1,5 @@
 // { dg-do run { target c++11 } }
+// { dg-add-options no_pch }
 
 // 2010-01-08  Paolo Carlini  <paolo.carl...@oracle.com>
 
@@ -19,18 +20,32 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-#include <vector>
+#define _GLIBCXX_DEQUE_BUF_SIZE sizeof(int) * 3
+
+#include <deque>
 #include <testsuite_hooks.h>
+#include <replacement_memory_operators.h>
 
 // libstdc++/42573
 void test01()
 {
-  std::vector<int> d(100);
+  __gnu_test::counter::reset();
+
+  std::deque<int> d;
   d.push_back(1);
   d.push_back(1);
-  // VERIFY( d.size() < d.capacity() );
+  d.push_back(1);
+  d.pop_front();
+  VERIFY( d.size() == 2 );
+  // 1 node array allocation + 2 node allocation = 3.
+  VERIFY( __gnu_test::counter::count() == 3 );
+  VERIFY( __gnu_test::counter::get()._M_increments == 3 );
+
   d.shrink_to_fit();
-  // VERIFY( d.size() == d.capacity() );
+  VERIFY( d.size() == 2 );
+  // 1 node array allocation + 1 node allocation = 2.
+  VERIFY( __gnu_test::counter::count() == __cpp_exceptions ? 2 : 3 );
+  VERIFY( __gnu_test::counter::get()._M_increments == 3 + (__cpp_exceptions ? 
2 : 0) );
 }
 
 int main()

Reply via email to