Skip to content

Commit

Permalink
Use MakeScalar from scalar.h
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrv committed Apr 6, 2023
1 parent a673b94 commit dbf4bb5
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions cpp/src/arrow/array/array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ class TestArray : public ::testing::Test {
MemoryPool* pool_;
};

template <class ScalarType>
std::shared_ptr<ScalarType> MakeScalar(typename ScalarType::ValueType value) {
return std::make_shared<ScalarType>(value);
}

TEST_F(TestArray, TestNullCount) {
// These are placeholders
auto data = std::make_shared<Buffer>(nullptr, 0);
Expand All @@ -110,11 +105,11 @@ TEST_F(TestArray, TestNullCount) {
RunEndEncodedBuilder ree_builder(pool_, std::make_shared<Int32Builder>(pool_),
std::make_shared<Int32Builder>(pool_),
run_end_encoded(int32(), int32()));
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<Int32Scalar>(2), 2));
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<int32_t>(2), 2));
ASSERT_OK(ree_builder.AppendNull());
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<Int32Scalar>(4), 3));
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<int32_t>(4), 3));
ASSERT_OK(ree_builder.AppendNulls(2));
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<Int32Scalar>(8), 5));
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<int32_t>(8), 5));
ASSERT_OK(ree_builder.AppendNulls(7));
ASSERT_OK_AND_ASSIGN(auto ree, ree_builder.Finish());

Expand All @@ -123,9 +118,9 @@ TEST_F(TestArray, TestNullCount) {
ASSERT_FALSE(ree->data()->MayHaveNulls());
ASSERT_TRUE(ree->data()->MayHaveLogicalNulls());

ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<Int32Scalar>(2), 2));
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<Int32Scalar>(4), 3));
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<Int32Scalar>(8), 5));
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<int32_t>(2), 2));
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<int32_t>(4), 3));
ASSERT_OK(ree_builder.AppendScalar(*MakeScalar<int32_t>(8), 5));
ASSERT_OK_AND_ASSIGN(auto ree_no_nulls, ree_builder.Finish());
ASSERT_EQ(0, ree_no_nulls->null_count());
ASSERT_EQ(0, ree_no_nulls->ComputeLogicalNullCount());
Expand Down

0 comments on commit dbf4bb5

Please sign in to comment.