[libcxx] r233641 - Make the new tests better; make sure that we're testing the case where no reallocation has to happen

Marshall Clow mclow.lists at gmail.com
Mon Mar 30 16:26:16 PDT 2015


Author: marshall
Date: Mon Mar 30 18:26:16 2015
New Revision: 233641

URL: http://llvm.org/viewvc/llvm-project?rev=233641&view=rev
Log:
Make the new tests better; make sure that we're testing the case where no reallocation has to happen

Modified:
    libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
    libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp

Modified: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp?rev=233641&r1=233640&r2=233641&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp Mon Mar 30 18:26:16 2015
@@ -35,7 +35,8 @@ int main()
     {
     typedef std::vector<int> V;
     V d1;
-    V d2(10); // no reallocation during assign.
+    V d2;
+    d2.reserve(10);  // no reallocation during assign.
     test(d1);
     test(d2);
     }
@@ -44,7 +45,8 @@ int main()
     {
     typedef std::vector<int, min_allocator<int>> V;
     V d1;
-    V d2(10); // no reallocation during assign.
+    V d2;
+    d2.reserve(10);  // no reallocation during assign.
     test(d1);
     test(d2);
     }

Modified: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp?rev=233641&r1=233640&r2=233641&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp Mon Mar 30 18:26:16 2015
@@ -14,6 +14,7 @@
 #include <vector>
 #include <algorithm>
 #include <cassert>
+#include <iostream>
 
 #include "min_allocator.h"
 #include "asan_testing.h"
@@ -23,7 +24,9 @@ bool is6(int x) { return x == 6; }
 template <typename Vec>
 void test ( Vec &v )
 {
+    std::cout << "Size, cap: " << v.size() << " " << v.capacity() << std::endl;
     v.assign(5, 6);
+    std::cout << "Size, cap: " << v.size() << " " << v.capacity() << std::endl;
     assert(v.size() == 5);
     assert(is_contiguous_container_asan_correct(v)); 
     assert(std::all_of(v.begin(), v.end(), is6));
@@ -34,7 +37,8 @@ int main()
     {
     typedef std::vector<int> V;
     V d1;
-    V d2(10);  // no reallocation during assign.
+    V d2;
+    d2.reserve(10);  // no reallocation during assign.
     test(d1);
     test(d2);
     }
@@ -43,7 +47,8 @@ int main()
     {
     typedef std::vector<int, min_allocator<int>> V;
     V d1;
-    V d2(10);  // no reallocation during assign.
+    V d2;
+    d2.reserve(10);  // no reallocation during assign.
     test(d1);
     test(d2);
     }





More information about the cfe-commits mailing list