Skip to content

Commit

Permalink
ARROW-9483: [C++] Reorganize testing headers
Browse files Browse the repository at this point in the history
Include less headers transitively from `gtest_util.h`.
Remove `gtest_common.h`, use `RandomArrayGenerator` instead.
  • Loading branch information
pitrou committed Jan 3, 2022
1 parent c6143a2 commit 7bf7020
Show file tree
Hide file tree
Showing 142 changed files with 857 additions and 779 deletions.
3 changes: 2 additions & 1 deletion cpp/src/arrow/adapters/orc/adapter_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
#include "arrow/util/decimal.h"
#include "arrow/util/range.h"
#include "arrow/util/string_view.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_data_inline.h"

#include "orc/Exceptions.hh"
#include "orc/MemoryPool.hh"
#include "orc/OrcFile.hh"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/array_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#include "arrow/type_fwd.h"
#include "arrow/type_traits.h"
#include "arrow/util/logging.h"
#include "arrow/visit_array_inline.h"
#include "arrow/visitor.h"
#include "arrow/visitor_inline.h"

namespace arrow {

Expand Down
13 changes: 6 additions & 7 deletions cpp/src/arrow/array/array_binary_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@
#include "arrow/buffer.h"
#include "arrow/memory_pool.h"
#include "arrow/status.h"
#include "arrow/testing/gtest_common.h"
#include "arrow/testing/builder.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/testing/util.h"
#include "arrow/type.h"
#include "arrow/type_traits.h"
#include "arrow/util/bit_util.h"
#include "arrow/util/bitmap_builders.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/string_view.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_data_inline.h"

namespace arrow {

Expand Down Expand Up @@ -403,17 +404,14 @@ TYPED_TEST(TestUTF8Array, TestValidateUTF8) { this->TestValidateUTF8(); }
// String builder tests

template <typename T>
class TestStringBuilder : public TestBuilder {
class TestStringBuilder : public ::testing::Test {
public:
using TypeClass = T;
using offset_type = typename TypeClass::offset_type;
using ArrayType = typename TypeTraits<TypeClass>::ArrayType;
using BuilderType = typename TypeTraits<TypeClass>::BuilderType;

void SetUp() {
TestBuilder::SetUp();
builder_.reset(new BuilderType(pool_));
}
void SetUp() { builder_.reset(new BuilderType(pool_)); }

void Done() {
std::shared_ptr<Array> out;
Expand Down Expand Up @@ -671,6 +669,7 @@ class TestStringBuilder : public TestBuilder {
}

protected:
MemoryPool* pool_ = default_memory_pool();
std::unique_ptr<BuilderType> builder_;
std::shared_ptr<ArrayType> result_;
};
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/array_dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "arrow/util/checked_cast.h"
#include "arrow/util/int_util.h"
#include "arrow/util/logging.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_type_inline.h"

namespace arrow {

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/array/array_dict_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "arrow/chunked_array.h"
#include "arrow/status.h"
#include "arrow/table.h"
#include "arrow/testing/builder.h"
#include "arrow/testing/extension_type.h"
#include "arrow/testing/gtest_common.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/testing/util.h"
#include "arrow/type.h"
Expand Down Expand Up @@ -69,7 +69,7 @@ std::shared_ptr<Array> DictExtensionFromJSON(const std::shared_ptr<DataType>& ty
// Dictionary tests

template <typename Type>
class TestDictionaryBuilder : public TestBuilder {};
class TestDictionaryBuilder : public ::testing::Test {};

typedef ::testing::Types<Int8Type, UInt8Type, Int16Type, UInt16Type, Int32Type,
UInt32Type, Int64Type, UInt64Type, FloatType, DoubleType>
Expand Down Expand Up @@ -1016,7 +1016,7 @@ void AssertIndexByteWidth(const std::shared_ptr<DataType>& value_type =
typedef ::testing::Types<Int8Type, Int16Type, Int32Type, Int64Type> IndexTypes;

template <typename Type>
class TestDictionaryBuilderIndexByteWidth : public TestBuilder {};
class TestDictionaryBuilderIndexByteWidth : public ::testing::Test {};

TYPED_TEST_SUITE(TestDictionaryBuilderIndexByteWidth, IndexTypes);

Expand Down
23 changes: 11 additions & 12 deletions cpp/src/arrow/array/array_list_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "arrow/array/validate.h"
#include "arrow/buffer.h"
#include "arrow/status.h"
#include "arrow/testing/gtest_common.h"
#include "arrow/testing/builder.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/type.h"
#include "arrow/util/bit_util.h"
Expand All @@ -47,7 +47,7 @@ using ListTypes = ::testing::Types<ListType, LargeListType>;
// List tests

template <typename T>
class TestListArray : public TestBuilder {
class TestListArray : public ::testing::Test {
public:
using TypeClass = T;
using offset_type = typename TypeClass::offset_type;
Expand All @@ -58,8 +58,6 @@ class TestListArray : public TestBuilder {
using OffsetBuilderType = typename TypeTraits<TypeClass>::OffsetBuilderType;

void SetUp() {
TestBuilder::SetUp();

value_type_ = int16();
type_ = std::make_shared<T>(value_type_);

Expand Down Expand Up @@ -523,6 +521,8 @@ class TestListArray : public TestBuilder {
}

protected:
MemoryPool* pool_ = default_memory_pool();
std::shared_ptr<DataType> type_;
std::shared_ptr<DataType> value_type_;

std::shared_ptr<BuilderType> builder_;
Expand Down Expand Up @@ -572,14 +572,12 @@ TYPED_TEST(TestListArray, TestOverflowCheck) { this->TestOverflowCheck(); }
// ----------------------------------------------------------------------
// Map tests

class TestMapArray : public TestBuilder {
class TestMapArray : public ::testing::Test {
public:
using offset_type = typename MapType::offset_type;
using OffsetType = typename TypeTraits<MapType>::OffsetType;

void SetUp() {
TestBuilder::SetUp();

key_type_ = utf8();
value_type_ = int32();
type_ = map(key_type_, value_type_);
Expand All @@ -596,7 +594,8 @@ class TestMapArray : public TestBuilder {
}

protected:
std::shared_ptr<DataType> value_type_, key_type_;
MemoryPool* pool_ = default_memory_pool();
std::shared_ptr<DataType> type_, value_type_, key_type_;

std::shared_ptr<MapBuilder> builder_;
std::shared_ptr<MapArray> result_;
Expand Down Expand Up @@ -977,11 +976,9 @@ TEST_F(TestMapArray, ValueBuilder) {
// ----------------------------------------------------------------------
// FixedSizeList tests

class TestFixedSizeListArray : public TestBuilder {
class TestFixedSizeListArray : public ::testing::Test {
public:
void SetUp() {
TestBuilder::SetUp();

value_type_ = int32();
type_ = fixed_size_list(value_type_, list_size());

Expand All @@ -998,7 +995,9 @@ class TestFixedSizeListArray : public TestBuilder {

protected:
static constexpr int32_t list_size() { return 2; }
std::shared_ptr<DataType> value_type_;

MemoryPool* pool_ = default_memory_pool();
std::shared_ptr<DataType> type_, value_type_;

std::shared_ptr<FixedSizeListBuilder> builder_;
std::shared_ptr<FixedSizeListArray> result_;
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/array/array_struct_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "arrow/array/builder_nested.h"
#include "arrow/chunked_array.h"
#include "arrow/status.h"
#include "arrow/testing/gtest_common.h"
#include "arrow/testing/builder.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/type.h"
#include "arrow/util/checked_cast.h"
Expand Down Expand Up @@ -305,11 +305,9 @@ TEST(StructArray, FlattenOfSlice) {

// ----------------------------------------------------------------------------------
// Struct test
class TestStructBuilder : public TestBuilder {
class TestStructBuilder : public ::testing::Test {
public:
void SetUp() {
TestBuilder::SetUp();

auto int32_type = int32();
auto char_type = int8();
auto list_type = list(char_type);
Expand Down Expand Up @@ -337,6 +335,8 @@ class TestStructBuilder : public TestBuilder {
protected:
std::vector<std::shared_ptr<Field>> value_fields_;

MemoryPool* pool_ = default_memory_pool();
std::shared_ptr<DataType> type_;
std::shared_ptr<StructBuilder> builder_;
std::shared_ptr<StructArray> result_;
};
Expand Down
10 changes: 8 additions & 2 deletions cpp/src/arrow/array/array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
#include "arrow/result.h"
#include "arrow/scalar.h"
#include "arrow/status.h"
#include "arrow/testing/builder.h"
#include "arrow/testing/extension_type.h"
#include "arrow/testing/gtest_common.h"
#include "arrow/testing/gtest_compat.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/testing/random.h"
Expand All @@ -60,7 +60,7 @@
#include "arrow/util/decimal.h"
#include "arrow/util/macros.h"
#include "arrow/util/range.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_data_inline.h"

// This file is compiled together with array-*-test.cc into a single
// executable array-test.
Expand Down Expand Up @@ -840,6 +840,12 @@ TEST(TestPrimitiveArray, CtorNoValidityBitmap) {
ASSERT_EQ(arr.data()->null_count, 0);
}

class TestBuilder : public ::testing::Test {
protected:
MemoryPool* pool_ = default_memory_pool();
std::shared_ptr<DataType> type_;
};

TEST_F(TestBuilder, TestReserve) {
UInt8Builder builder(pool_);

Expand Down
1 change: 1 addition & 0 deletions cpp/src/arrow/array/array_union_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "arrow/array/builder_union.h"
// TODO ipc shouldn't be included here
#include "arrow/ipc/test_common.h"
#include "arrow/testing/builder.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/testing/util.h"
#include "arrow/type.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/builder_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "arrow/scalar.h"
#include "arrow/status.h"
#include "arrow/util/logging.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_type_inline.h"

namespace arrow {

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/builder_dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "arrow/util/checked_cast.h"
#include "arrow/util/hashing.h"
#include "arrow/util/logging.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_type_inline.h"

namespace arrow {

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/builder_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
#include "arrow/status.h"
#include "arrow/type.h"
#include "arrow/type_traits.h"
#include "arrow/util/bit_block_counter.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/decimal.h"
#include "arrow/util/macros.h"
#include "arrow/util/visibility.h"
#include "arrow/visitor_inline.h"

namespace arrow {

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/array/concatenate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <utility>
#include <vector>

#include "arrow/array/array_base.h"
#include "arrow/array.h"
#include "arrow/array/builder_primitive.h"
#include "arrow/array/data.h"
#include "arrow/array/util.h"
Expand All @@ -41,7 +41,7 @@
#include "arrow/util/int_util.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/logging.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_type_inline.h"

namespace arrow {

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/concatenate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "arrow/array/concatenate.h"
#include "arrow/buffer.h"
#include "arrow/status.h"
#include "arrow/testing/gtest_common.h"
#include "arrow/testing/builder.h"
#include "arrow/testing/random.h"
#include "arrow/testing/util.h"
#include "arrow/type.h"
Expand Down
1 change: 0 additions & 1 deletion cpp/src/arrow/array/dict_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "arrow/util/hashing.h"
#include "arrow/util/logging.h"
#include "arrow/util/string_view.h"
#include "arrow/visitor_inline.h"

namespace arrow {
namespace internal {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/diff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "arrow/util/string.h"
#include "arrow/util/string_view.h"
#include "arrow/vendored/datetime.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_type_inline.h"

namespace arrow {

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/diff_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "arrow/array/diff.h"
#include "arrow/compute/api.h"
#include "arrow/status.h"
#include "arrow/testing/gtest_common.h"
#include "arrow/testing/builder.h"
#include "arrow/testing/random.h"
#include "arrow/testing/util.h"
#include "arrow/type.h"
Expand Down
6 changes: 2 additions & 4 deletions cpp/src/arrow/array/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
#include <utility>
#include <vector>

#include "arrow/array/array_base.h"
#include "arrow/array/array_dict.h"
#include "arrow/array/array_primitive.h"
#include "arrow/array.h"
#include "arrow/array/builder_base.h"
#include "arrow/array/concatenate.h"
#include "arrow/buffer.h"
Expand All @@ -45,7 +43,7 @@
#include "arrow/util/decimal.h"
#include "arrow/util/endian.h"
#include "arrow/util/logging.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_type_inline.h"

namespace arrow {

Expand Down
4 changes: 3 additions & 1 deletion cpp/src/arrow/array/validate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
#include "arrow/util/bit_util.h"
#include "arrow/util/bitmap_ops.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/decimal.h"
#include "arrow/util/int_util_internal.h"
#include "arrow/util/logging.h"
#include "arrow/util/utf8.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_data_inline.h"
#include "arrow/visit_type_inline.h"

namespace arrow {
namespace internal {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "arrow/util/checked_cast.h"
#include "arrow/util/hashing.h"
#include "arrow/util/make_unique.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_type_inline.h"

namespace arrow {

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/c/bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "arrow/util/small_vector.h"
#include "arrow/util/string_view.h"
#include "arrow/util/value_parsing.h"
#include "arrow/visitor_inline.h"
#include "arrow/visit_type_inline.h"

namespace arrow {

Expand Down
Loading

0 comments on commit 7bf7020

Please sign in to comment.