Make the new tests better; make sure that we're testing the case where no reallocation has to happen
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@233641 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
86319f01df
commit
3accbf03e2
@ -35,7 +35,8 @@ int main()
|
|||||||
{
|
{
|
||||||
typedef std::vector<int> V;
|
typedef std::vector<int> V;
|
||||||
V d1;
|
V d1;
|
||||||
V d2(10); // no reallocation during assign.
|
V d2;
|
||||||
|
d2.reserve(10); // no reallocation during assign.
|
||||||
test(d1);
|
test(d1);
|
||||||
test(d2);
|
test(d2);
|
||||||
}
|
}
|
||||||
@ -44,7 +45,8 @@ int main()
|
|||||||
{
|
{
|
||||||
typedef std::vector<int, min_allocator<int>> V;
|
typedef std::vector<int, min_allocator<int>> V;
|
||||||
V d1;
|
V d1;
|
||||||
V d2(10); // no reallocation during assign.
|
V d2;
|
||||||
|
d2.reserve(10); // no reallocation during assign.
|
||||||
test(d1);
|
test(d1);
|
||||||
test(d2);
|
test(d2);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
#include "asan_testing.h"
|
#include "asan_testing.h"
|
||||||
@ -23,7 +24,9 @@ bool is6(int x) { return x == 6; }
|
|||||||
template <typename Vec>
|
template <typename Vec>
|
||||||
void test ( Vec &v )
|
void test ( Vec &v )
|
||||||
{
|
{
|
||||||
|
std::cout << "Size, cap: " << v.size() << " " << v.capacity() << std::endl;
|
||||||
v.assign(5, 6);
|
v.assign(5, 6);
|
||||||
|
std::cout << "Size, cap: " << v.size() << " " << v.capacity() << std::endl;
|
||||||
assert(v.size() == 5);
|
assert(v.size() == 5);
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
assert(is_contiguous_container_asan_correct(v));
|
||||||
assert(std::all_of(v.begin(), v.end(), is6));
|
assert(std::all_of(v.begin(), v.end(), is6));
|
||||||
@ -34,7 +37,8 @@ int main()
|
|||||||
{
|
{
|
||||||
typedef std::vector<int> V;
|
typedef std::vector<int> V;
|
||||||
V d1;
|
V d1;
|
||||||
V d2(10); // no reallocation during assign.
|
V d2;
|
||||||
|
d2.reserve(10); // no reallocation during assign.
|
||||||
test(d1);
|
test(d1);
|
||||||
test(d2);
|
test(d2);
|
||||||
}
|
}
|
||||||
@ -43,7 +47,8 @@ int main()
|
|||||||
{
|
{
|
||||||
typedef std::vector<int, min_allocator<int>> V;
|
typedef std::vector<int, min_allocator<int>> V;
|
||||||
V d1;
|
V d1;
|
||||||
V d2(10); // no reallocation during assign.
|
V d2;
|
||||||
|
d2.reserve(10); // no reallocation during assign.
|
||||||
test(d1);
|
test(d1);
|
||||||
test(d2);
|
test(d2);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user