Commit d22ff006 authored by Chang Kyu Lee's avatar Chang Kyu Lee Committed by Facebook GitHub Bot

ConcurrentHashMap: Add reserve test

Summary: Adds a test for ConcurrentHashMap::reserve().

Reviewed By: magedm

Differential Revision: D25853643

fbshipit-source-id: 39404105c88d6dc38cdd0b399c646affad1b26e0
parent ed6fa93c
...@@ -196,6 +196,26 @@ TYPED_TEST_P(ConcurrentHashMapTest, MapResizeTest) { ...@@ -196,6 +196,26 @@ TYPED_TEST_P(ConcurrentHashMapTest, MapResizeTest) {
foomap.reserve(0); foomap.reserve(0);
} }
TYPED_TEST_P(ConcurrentHashMapTest, ReserveTest) {
CHM<uint64_t, uint64_t> foomap;
int64_t insert_count = 0;
int64_t actual_count = 0;
for (int64_t i = 0; i < 1000; i++) {
if (i % 100 == 0) {
foomap.reserve(i + 100);
}
foomap.insert(std::make_pair(i, i));
insert_count++;
}
for (auto it = foomap.begin(); it != foomap.cend(); ++it) {
actual_count++;
}
EXPECT_EQ(insert_count, actual_count);
}
// Ensure we can insert objects without copy constructors. // Ensure we can insert objects without copy constructors.
TYPED_TEST_P(ConcurrentHashMapTest, MapNoCopiesTest) { TYPED_TEST_P(ConcurrentHashMapTest, MapNoCopiesTest) {
struct Uncopyable { struct Uncopyable {
...@@ -944,6 +964,7 @@ REGISTER_TYPED_TEST_CASE_P( ...@@ -944,6 +964,7 @@ REGISTER_TYPED_TEST_CASE_P(
MoveTest, MoveTest,
EmplaceTest, EmplaceTest,
MapResizeTest, MapResizeTest,
ReserveTest,
MapNoCopiesTest, MapNoCopiesTest,
MapMovableKeysTest, MapMovableKeysTest,
MapUpdateTest, MapUpdateTest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment