More tests for LWG#2156
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@253257 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -31,6 +31,21 @@ void test(const C& c)
|
|||||||
assert(c.at(4) == "four");
|
assert(c.at(4) == "four");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reserve_invariant(size_t n) // LWG #2156
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
std::unordered_map<size_t, size_t> c;
|
||||||
|
c.reserve(n);
|
||||||
|
size_t buckets = c.bucket_count();
|
||||||
|
for (size_t j = 0; j < i; ++j)
|
||||||
|
{
|
||||||
|
c[i] = i;
|
||||||
|
assert(buckets == c.bucket_count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -88,4 +103,5 @@ int main()
|
|||||||
test(c);
|
test(c);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
reserve_invariant(20);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,21 @@ void test(const C& c)
|
|||||||
assert(c.find(4)->second == "four");
|
assert(c.find(4)->second == "four");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reserve_invariant(size_t n) // LWG #2156
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
std::unordered_multimap<size_t, size_t> c;
|
||||||
|
c.reserve(n);
|
||||||
|
size_t buckets = c.bucket_count();
|
||||||
|
for (size_t j = 0; j < i; ++j)
|
||||||
|
{
|
||||||
|
c[i] = i;
|
||||||
|
assert(buckets == c.bucket_count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -90,4 +105,5 @@ int main()
|
|||||||
test(c);
|
test(c);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
reserve_invariant(20);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,21 @@ void test(const C& c)
|
|||||||
assert(c.count(4) == 1);
|
assert(c.count(4) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reserve_invariant(size_t n) // LWG #2156
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
std::unordered_multiset<size_t> c;
|
||||||
|
c.reserve(n);
|
||||||
|
size_t buckets = c.bucket_count();
|
||||||
|
for (size_t j = 0; j < i; ++j)
|
||||||
|
{
|
||||||
|
c.insert(i);
|
||||||
|
assert(buckets == c.bucket_count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -87,4 +102,5 @@ int main()
|
|||||||
test(c);
|
test(c);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
reserve_invariant(20);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,21 @@ void test(const C& c)
|
|||||||
assert(c.count(4) == 1);
|
assert(c.count(4) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reserve_invariant(size_t n) // LWG #2156
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
std::unordered_set<size_t> c;
|
||||||
|
c.reserve(n);
|
||||||
|
size_t buckets = c.bucket_count();
|
||||||
|
for (size_t j = 0; j < i; ++j)
|
||||||
|
{
|
||||||
|
c.insert(i);
|
||||||
|
assert(buckets == c.bucket_count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -87,4 +102,5 @@ int main()
|
|||||||
test(c);
|
test(c);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
reserve_invariant(20);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user