Skip to content

Commit 58e12cc

Browse files
committed
Fixed test for ColumnDecimal::GetItem
1 parent 25c7634 commit 58e12cc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ut/Column_ut.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,14 @@ TYPED_TEST(GenericColumnTest, Append) {
152152

153153
// To make some value types compatitable with Column::GetItem()
154154
template <typename ColumnType, typename ValueType>
155-
inline auto convertValueForGetItem(ValueType&& t) {
155+
inline auto convertValueForGetItem(const ColumnType& col, ValueType&& t) {
156156
using T = std::remove_cv_t<std::decay_t<ValueType>>;
157157

158-
if constexpr (std::is_same_v<T, clickhouse::UInt128>
158+
if constexpr (std::is_same_v<ColumnType, ColumnDecimal>) {
159+
// Since ColumnDecimal can hold 32, 64, 128-bit wide data and there is no way telling at run-time.
160+
const ItemView item = col.GetItem(0);
161+
return std::string_view(reinterpret_cast<const char*>(&t), item.data.size());
162+
} else if constexpr (std::is_same_v<T, clickhouse::UInt128>
159163
|| std::is_same_v<T, clickhouse::Int128>) {
160164
return std::string_view{reinterpret_cast<const char*>(&t), sizeof(T)};
161165
} else if constexpr (std::is_same_v<T, in_addr>) {
@@ -178,7 +182,7 @@ TYPED_TEST(GenericColumnTest, GetItem) {
178182
ASSERT_EQ(column->GetItem(0).type, column->GetType().GetCode());
179183

180184
for (size_t i = 0; i < values.size(); ++i) {
181-
const auto v = convertValueForGetItem<typename TestFixture::ColumnType>(values[i]);
185+
const auto v = convertValueForGetItem(*column, values[i]);
182186
const ItemView item = column->GetItem(i);
183187

184188
ASSERT_TRUE(CompareRecursive(item.get<decltype(v)>(), v));

0 commit comments

Comments
 (0)