mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 02:52:13 +00:00
Merge pull request #12276 from ClickHouse/test-pod-array
Added a test for PaddedPODArray just in case
This commit is contained in:
commit
51afbf8f8d
@ -44,3 +44,25 @@ TEST(Common, PODPushBackRawMany)
|
||||
EXPECT_EQ(15, chars.size());
|
||||
EXPECT_EQ(std::string("first0123456789"), std::string(chars.data(), chars.size()));
|
||||
}
|
||||
|
||||
TEST(Common, PODNoOverallocation)
|
||||
{
|
||||
/// Check that PaddedPODArray allocates for smaller number of elements than the power of two due to padding.
|
||||
/// NOTE: It's Ok to change these numbers if you will modify initial size or padding.
|
||||
|
||||
PaddedPODArray<char> chars;
|
||||
std::vector<size_t> capacities;
|
||||
|
||||
size_t prev_capacity = 0;
|
||||
for (size_t i = 0; i < 1000000; ++i)
|
||||
{
|
||||
chars.emplace_back();
|
||||
if (chars.capacity() != prev_capacity)
|
||||
{
|
||||
prev_capacity = chars.capacity();
|
||||
capacities.emplace_back(prev_capacity);
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_EQ(capacities, (std::vector<size_t>{4065, 8161, 16353, 32737, 65505, 131041, 262113, 524257, 1048545}));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user