@@ -134,6 +134,8 @@ TEST(ColumnArray, Slice) {
134
134
}
135
135
136
136
TEST (ColumnArray, Slice_2D) {
137
+ // Verify that ColumnArray::Slice on 2D Array produces a 2D Array of proper type, size and contents.
138
+ // Also check that slices can be of any size.
137
139
const std::vector<std::vector<std::vector<uint64_t >>> values = {
138
140
{{1u , 2u }, {3u }},
139
141
{{4u }, {5u , 6u , 7u }, {8u , 9u }, {}},
@@ -143,13 +145,20 @@ TEST(ColumnArray, Slice_2D) {
143
145
};
144
146
145
147
std::shared_ptr<ColumnArray> untyped_array = Create2DArray<ColumnUInt64>(values);
146
-
147
148
for (size_t i = 0 ; i < values.size () - 1 ; ++i) {
148
- auto slice = untyped_array->Slice (i, 1 )->AsStrict <ColumnArray>();
149
- EXPECT_EQ (1u , slice->Size ());
150
-
151
- for (size_t j = 0 ; j < values[i].size (); ++j) {
152
- EXPECT_TRUE (CompareRecursive (values[i][j], *slice->GetAsColumnTyped <ColumnArray>(0 )->GetAsColumnTyped <ColumnUInt64>(j)));
149
+ for (size_t slice_size = 0 ; slice_size < values.size () - i; ++slice_size) {
150
+ auto slice = untyped_array->Slice (i, slice_size)->AsStrict <ColumnArray>();
151
+ EXPECT_EQ (slice_size, slice->Size ());
152
+
153
+ for (size_t slice_row = 0 ; slice_row < slice_size; ++slice_row) {
154
+ SCOPED_TRACE (::testing::Message () << " i: " << i << " slice_size:" << slice_size << " row:" << slice_row);
155
+ auto val = slice->GetAsColumnTyped <ColumnArray>(slice_row);
156
+ ASSERT_EQ (values[i + slice_row].size (), val->Size ());
157
+
158
+ for (size_t j = 0 ; j < values[i + slice_row].size (); ++j) {
159
+ ASSERT_TRUE (CompareRecursive (values[i + slice_row][j], *val->GetAsColumnTyped <ColumnUInt64>(j)));
160
+ }
161
+ }
153
162
}
154
163
}
155
164
}
0 commit comments