mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #40129 from kitaisreal/pod-array-assign-empty-array-fix
PODArray assign empty array fix
This commit is contained in:
commit
098436f012
@ -703,10 +703,9 @@ public:
|
|||||||
|
|
||||||
size_t bytes_to_copy = this->byte_size(required_capacity);
|
size_t bytes_to_copy = this->byte_size(required_capacity);
|
||||||
if (bytes_to_copy)
|
if (bytes_to_copy)
|
||||||
{
|
|
||||||
memcpy(this->c_start, reinterpret_cast<const void *>(&*from_begin), bytes_to_copy);
|
memcpy(this->c_start, reinterpret_cast<const void *>(&*from_begin), bytes_to_copy);
|
||||||
this->c_end = this->c_start + bytes_to_copy;
|
|
||||||
}
|
this->c_end = this->c_start + bytes_to_copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ISO C++ has strict ambiguity rules, thus we cannot apply TAllocatorParams here.
|
// ISO C++ has strict ambiguity rules, thus we cannot apply TAllocatorParams here.
|
||||||
|
@ -484,6 +484,35 @@ TEST(Common, PODArrayInsertFromItself)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Common, PODArrayAssign)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
PaddedPODArray<UInt64> array;
|
||||||
|
array.push_back(1);
|
||||||
|
array.push_back(2);
|
||||||
|
|
||||||
|
array.assign({1, 2, 3});
|
||||||
|
|
||||||
|
ASSERT_EQ(array.size(), 3);
|
||||||
|
ASSERT_EQ(array, PaddedPODArray<UInt64>({1, 2, 3}));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
PaddedPODArray<UInt64> array;
|
||||||
|
array.push_back(1);
|
||||||
|
array.push_back(2);
|
||||||
|
|
||||||
|
array.assign({});
|
||||||
|
|
||||||
|
ASSERT_TRUE(array.empty());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
PaddedPODArray<UInt64> array;
|
||||||
|
array.assign({});
|
||||||
|
|
||||||
|
ASSERT_TRUE(array.empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST(Common, PODNoOverallocation)
|
TEST(Common, PODNoOverallocation)
|
||||||
{
|
{
|
||||||
/// Check that PaddedPODArray allocates for smaller number of elements than the power of two due to padding.
|
/// Check that PaddedPODArray allocates for smaller number of elements than the power of two due to padding.
|
||||||
|
Loading…
Reference in New Issue
Block a user