@@ -150,6 +150,41 @@ TYPED_TEST(GenericColumnTest, Append) {
150150 EXPECT_TRUE (CompareRecursive (values, *column));
151151}
152152
153+ // To make some value types compatitable with Column::GetItem()
154+ template <typename ColumnType, typename ValueType>
155+ inline auto convertValueForGetItem (ValueType&& t) {
156+ using T = std::remove_cv_t <std::decay_t <ValueType>>;
157+
158+ if constexpr (std::is_same_v<T, clickhouse::UInt128>
159+ || std::is_same_v<T, clickhouse::Int128>) {
160+ return std::string_view{reinterpret_cast <const char *>(&t), sizeof (T)};
161+ } else if constexpr (std::is_same_v<T, in_addr>) {
162+ return htonl (t.s_addr );
163+ } else if constexpr (std::is_same_v<T, in6_addr>) {
164+ return std::string_view (reinterpret_cast <const char *>(t.s6_addr ), 16 );
165+ } else if constexpr (std::is_same_v<ColumnType, ColumnDate>) {
166+ return static_cast <uint16_t >(t / std::time_t (86400 ));
167+ } else if constexpr (std::is_same_v<ColumnType, ColumnDateTime>) {
168+ return static_cast <uint32_t >(t);
169+ } else {
170+ return t;
171+ }
172+ }
173+
174+ TYPED_TEST (GenericColumnTest, GetItem) {
175+ auto [column, values] = this ->MakeColumnWithValues (100 );
176+
177+ ASSERT_EQ (values.size (), column->Size ());
178+ ASSERT_EQ (column->GetItem (0 ).type , column->GetType ().GetCode ());
179+
180+ for (size_t i = 0 ; i < values.size (); ++i) {
181+ const auto v = convertValueForGetItem<typename TestFixture::ColumnType>(values[i]);
182+ const ItemView item = column->GetItem (i);
183+
184+ ASSERT_TRUE (CompareRecursive (item.get <decltype (v)>(), v));
185+ }
186+ }
187+
153188TYPED_TEST (GenericColumnTest, Slice) {
154189 auto [column, values] = this ->MakeColumnWithValues (100 );
155190
0 commit comments