Skip to content

Commit

Permalink
Change expect_strings_empty into expect_column_empty libcudf test uti…
Browse files Browse the repository at this point in the history
…lity (#11873)

Moves the `cudf::test::expect_strings_empty` utility from `cpp/tests/strings` to more generic function `cudf::test::expect_column_empty` 

Reference #11734

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Vukasin Milovanovic (https://github.com/vuule)
  - Tobias Ribizel (https://github.com/upsj)

URL: #11873
  • Loading branch information
davidwendt authored Oct 12, 2022
1 parent 387192c commit ccbd852
Show file tree
Hide file tree
Showing 37 changed files with 187 additions and 262 deletions.
1 change: 0 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,6 @@ add_library(
tests/utilities/base_fixture.cpp
tests/utilities/column_utilities.cu
tests/utilities/table_utilities.cu
tests/strings/utilities.cpp
)

set_target_properties(
Expand Down
7 changes: 7 additions & 0 deletions cpp/include/cudf_test/column_utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ bool expect_columns_equivalent(cudf::column_view const& lhs,
debug_output_level verbosity = debug_output_level::FIRST_ERROR,
size_type fp_ulps = cudf::test::default_ulp);

/**
* @brief Verifies the given column is empty
*
* @param col The column to check
*/
void expect_column_empty(cudf::column_view const& col);

/**
* @brief Verifies the bitwise equality of two device memory buffers.
*
Expand Down
15 changes: 7 additions & 8 deletions cpp/tests/copying/detail_gather_tests.cu
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tests/strings/utilities.h>

#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_lists.hpp>

#include <cudf/column/column_view.hpp>
#include <cudf/copying.hpp>
Expand All @@ -24,13 +30,6 @@
#include <cudf/table/table_view.hpp>
#include <cudf/utilities/default_stream.hpp>

#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_lists.hpp>

#include <rmm/device_uvector.hpp>

#include <thrust/execution_policy.h>
Expand Down
17 changes: 8 additions & 9 deletions cpp/tests/copying/gather_list_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tests/strings/utilities.h>

#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_lists.hpp>

#include <cudf/column/column_view.hpp>
#include <cudf/copying.hpp>
Expand All @@ -23,13 +29,6 @@
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>

#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_lists.hpp>

template <typename T>
class GatherTestListTyped : public cudf::test::BaseFixture {
};
Expand Down
16 changes: 8 additions & 8 deletions cpp/tests/copying/gather_str_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_view.hpp>
#include <cudf/copying.hpp>
#include <cudf/detail/gather.hpp>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/table_utilities.hpp>
#include <tests/strings/utilities.h>

#include <cudf/column/column_view.hpp>
#include <cudf/copying.hpp>
#include <cudf/detail/gather.hpp>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>

class GatherTestStr : public cudf::test::BaseFixture {
};
Expand Down Expand Up @@ -135,7 +135,7 @@ TEST_F(GatherTestStr, GatherEmptyMapStringsColumn)
gather_map,
cudf::out_of_bounds_policy::NULLIFY,
cudf::detail::negative_index_policy::NOT_ALLOWED);
cudf::test::expect_strings_empty(results->get_column(0).view());
cudf::test::expect_column_empty(results->get_column(0).view());
}

TEST_F(GatherTestStr, GatherZeroSizeStringsColumn)
Expand Down
15 changes: 7 additions & 8 deletions cpp/tests/copying/gather_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,13 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tests/strings/utilities.h>

#include <cudf/column/column_view.hpp>
#include <cudf/copying.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>

#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
Expand All @@ -28,6 +21,12 @@
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_lists.hpp>

#include <cudf/column/column_view.hpp>
#include <cudf/copying.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>

template <typename T>
class GatherTest : public cudf::test::BaseFixture {
};
Expand Down
14 changes: 6 additions & 8 deletions cpp/tests/copying/scatter_list_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/

#include <tests/strings/utilities.h>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_lists.hpp>

#include <cudf/column/column_view.hpp>
#include <cudf/copying.hpp>
Expand All @@ -24,13 +29,6 @@
#include <cudf/table/table_view.hpp>
#include <cudf/utilities/default_stream.hpp>

#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_lists.hpp>

template <typename T>
class TypedScatterListsTest : public cudf::test::BaseFixture {
};
Expand Down
9 changes: 4 additions & 5 deletions cpp/tests/lists/extract_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
* limitations under the License.
*/

#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/lists/extract.hpp>

#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/iterator_utilities.hpp>
#include <cudf_test/type_lists.hpp>
#include <tests/strings/utilities.h>

#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/lists/extract.hpp>

#include <rmm/cuda_stream_view.hpp>

Expand Down
7 changes: 3 additions & 4 deletions cpp/tests/reshape/interleave_columns_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,13 +14,12 @@
* limitations under the License.
*/

#include <cudf/column/column_factories.hpp>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/iterator_utilities.hpp>
#include <cudf_test/type_lists.hpp>
#include <tests/strings/utilities.h>

#include <cudf/column/column_factories.hpp>
#include <cudf/reshape.hpp>

using namespace cudf::test::iterators;
Expand Down Expand Up @@ -195,7 +194,7 @@ TEST_F(InterleaveStringsColumnsTest, ZeroSizedColumns)
cudf::column_view col0(cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0);

auto results = cudf::interleave_columns(cudf::table_view{{col0}});
cudf::test::expect_strings_empty(results->view());
cudf::test::expect_column_empty(results->view());
}

TEST_F(InterleaveStringsColumnsTest, SingleColumn)
Expand Down
12 changes: 5 additions & 7 deletions cpp/tests/strings/array_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

#include <tests/strings/utilities.h>

#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
Expand Down Expand Up @@ -53,7 +51,7 @@ TEST_F(StringsColumnTest, SortZeroSizeStringsColumn)
cudf::column_view zero_size_strings_column(
cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0);
auto results = cudf::sort(cudf::table_view({zero_size_strings_column}));
cudf::test::expect_strings_empty(results->view().column(0));
cudf::test::expect_column_empty(results->view().column(0));
}

class SliceParmsTest : public StringsColumnTest,
Expand Down Expand Up @@ -123,7 +121,7 @@ TEST_F(StringsColumnTest, SliceZeroSizeStringsColumn)
cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0);
auto strings_view = cudf::strings_column_view(zero_size_strings_column);
auto results = cudf::strings::detail::copy_slice(strings_view, 1, 2);
cudf::test::expect_strings_empty(results->view());
cudf::test::expect_column_empty(results->view());
}

TEST_F(StringsColumnTest, Gather)
Expand Down Expand Up @@ -151,7 +149,7 @@ TEST_F(StringsColumnTest, GatherZeroSizeStringsColumn)
cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0);
cudf::column_view map_view(cudf::data_type{cudf::type_id::INT32}, 0, nullptr, nullptr, 0);
auto results = cudf::gather(cudf::table_view{{zero_size_strings_column}}, map_view)->release();
cudf::test::expect_strings_empty(results.front()->view());
cudf::test::expect_column_empty(results.front()->view());
}

TEST_F(StringsColumnTest, GatherTooBig)
Expand Down Expand Up @@ -204,12 +202,12 @@ TEST_F(StringsColumnTest, ScatterZeroSizeStringsColumn)
cudf::column_view scatter_map(cudf::data_type{cudf::type_id::INT8}, 0, nullptr, nullptr, 0);

auto results = cudf::scatter(cudf::table_view({source}), scatter_map, cudf::table_view({target}));
cudf::test::expect_strings_empty(results->view().column(0));
cudf::test::expect_column_empty(results->view().column(0));

cudf::string_scalar scalar("");
auto scalar_source = std::vector<std::reference_wrapper<const cudf::scalar>>({scalar});
results = cudf::scatter(scalar_source, scatter_map, cudf::table_view({target}));
cudf::test::expect_strings_empty(results->view().column(0));
cudf::test::expect_column_empty(results->view().column(0));
}

TEST_F(StringsColumnTest, OffsetsBeginEnd)
Expand Down
10 changes: 5 additions & 5 deletions cpp/tests/strings/booleans_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION.
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,12 +14,12 @@
* limitations under the License.
*/

#include <cudf/strings/convert/convert_booleans.hpp>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <tests/strings/utilities.h>

#include <cudf/strings/convert/convert_booleans.hpp>
#include <cudf/strings/strings_column_view.hpp>

#include <thrust/iterator/transform_iterator.h>

Expand Down Expand Up @@ -69,7 +69,7 @@ TEST_F(StringsConvertTest, ZeroSizeStringsColumnBoolean)
{
cudf::column_view zero_size_column(cudf::data_type{cudf::type_id::BOOL8}, 0, nullptr, nullptr, 0);
auto results = cudf::strings::from_booleans(zero_size_column);
cudf::test::expect_strings_empty(results->view());
cudf::test::expect_column_empty(results->view());
}

TEST_F(StringsConvertTest, ZeroSizeBooleansColumn)
Expand Down
21 changes: 10 additions & 11 deletions cpp/tests/strings/case_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION.
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,15 @@
* limitations under the License.
*/

#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>

#include <cudf/column/column.hpp>
#include <cudf/strings/capitalize.hpp>
#include <cudf/strings/case.hpp>
#include <cudf/strings/strings_column_view.hpp>

#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <tests/strings/utilities.h>

#include <thrust/iterator/transform_iterator.h>

#include <vector>
Expand Down Expand Up @@ -211,19 +210,19 @@ TEST_F(StringsCaseTest, EmptyStringsColumn)
auto strings_view = cudf::strings_column_view(zero_size_strings_column);

auto results = cudf::strings::to_lower(strings_view);
cudf::test::expect_strings_empty(results->view());
cudf::test::expect_column_empty(results->view());

results = cudf::strings::to_upper(strings_view);
cudf::test::expect_strings_empty(results->view());
cudf::test::expect_column_empty(results->view());

results = cudf::strings::swapcase(strings_view);
cudf::test::expect_strings_empty(results->view());
cudf::test::expect_column_empty(results->view());

results = cudf::strings::capitalize(strings_view);
cudf::test::expect_strings_empty(results->view());
cudf::test::expect_column_empty(results->view());

results = cudf::strings::title(strings_view);
cudf::test::expect_strings_empty(results->view());
cudf::test::expect_column_empty(results->view());
}

TEST_F(StringsCaseTest, ErrorTest)
Expand Down
Loading

0 comments on commit ccbd852

Please sign in to comment.