Skip to content

Commit

Permalink
Add test in C++ comparing with sliced and constructed MapArray
Browse files Browse the repository at this point in the history
  • Loading branch information
AlenkaF committed May 8, 2024
1 parent e371a4b commit 8503fd1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cpp/src/arrow/array/array_list_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ TEST_F(TestMapArray, ValidateErrorNullKey) {
}

TEST_F(TestMapArray, FromArrays) {
std::shared_ptr<Array> offsets1, offsets2, offsets3, offsets4, keys, items;
std::shared_ptr<Array> offsets1, offsets2, offsets3, offsets4, offsets5, keys, items;

std::vector<bool> offsets_is_valid3 = {true, false, true, true};
std::vector<bool> offsets_is_valid4 = {true, true, false, true};
Expand Down Expand Up @@ -1342,6 +1342,20 @@ TEST_F(TestMapArray, FromArrays) {
// Zero-length offsets
ASSERT_RAISES(Invalid, MapArray::FromArrays(offsets1->Slice(0, 0), keys, items, pool_));

// Offseted offsets
ASSERT_OK_AND_ASSIGN(auto map5,
MapArray::FromArrays(offsets1->Slice(1), keys, items, pool_));
ASSERT_OK(map5->Validate());

AssertArraysEqual(*expected1.Slice(1), *map5);

std::vector<MapType::offset_type> offset5_values = {2, 2, 6};
ArrayFromVector<OffsetType, offset_type>(offset5_values, &offsets5);
ASSERT_OK_AND_ASSIGN(auto map6, MapArray::FromArrays(offsets5, keys, items, pool_));
ASSERT_OK(map6->Validate());

AssertArraysEqual(*map5, *map6);

// Offsets not the right type
ASSERT_RAISES(TypeError, MapArray::FromArrays(keys, offsets1, items, pool_));

Expand Down

0 comments on commit 8503fd1

Please sign in to comment.