diff --git a/cpp/tests/copying/copy_tests.cu b/cpp/tests/copying/copy_tests.cu index e9249a6bd0e..03869c37adf 100644 --- a/cpp/tests/copying/copy_tests.cu +++ b/cpp/tests/copying/copy_tests.cu @@ -285,6 +285,85 @@ TYPED_TEST(CopyTest, CopyIfElseBadInputLength) } } +struct CopyEmptyNested : public cudf::test::BaseFixture { +}; + +TEST_F(CopyEmptyNested, CopyIfElseTestEmptyNestedColumns) +{ + // lists + { + cudf::test::lists_column_wrapper col{{{"abc", "def"}, {"xyz"}}}; + auto lhs = cudf::empty_like(col); + auto rhs = cudf::empty_like(col); + cudf::test::fixed_width_column_wrapper mask{}; + + auto expected = empty_like(col); + + auto out = cudf::copy_if_else(*lhs, *rhs, mask); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(out->view(), *expected); + } + + // structs + { + cudf::test::lists_column_wrapper _col0{{{"abc", "def"}, {"xyz"}}}; + auto col0 = cudf::empty_like(_col0); + cudf::test::fixed_width_column_wrapper col1; + + std::vector> cols; + cols.push_back(std::move(col0)); + cols.push_back(col1.release()); + cudf::test::structs_column_wrapper struct_col(std::move(cols)); + auto lhs = cudf::empty_like(struct_col); + auto rhs = cudf::empty_like(struct_col); + + cudf::test::fixed_width_column_wrapper mask{}; + + auto expected = cudf::empty_like(struct_col); + + auto out = cudf::copy_if_else(*lhs, *rhs, mask); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(out->view(), *expected); + } +} + +TEST_F(CopyEmptyNested, CopyIfElseTestEmptyNestedScalars) +{ + // lists + { + cudf::test::lists_column_wrapper _col{{{"abc", "def"}, {"xyz"}}}; + std::unique_ptr lhs = cudf::get_element(_col, 0); + std::unique_ptr rhs = cudf::get_element(_col, 0); + + cudf::test::fixed_width_column_wrapper mask{}; + + auto expected = empty_like(_col); + + auto out = cudf::copy_if_else(*lhs, *rhs, mask); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(out->view(), *expected); + } + + // structs + { + cudf::test::lists_column_wrapper col0{{{"abc", "def"}, {"xyz"}}}; + cudf::test::fixed_width_column_wrapper col1{1}; + + cudf::table_view tbl({col0, col1}); + cudf::struct_scalar lhs(tbl); + cudf::struct_scalar rhs(tbl); + + std::vector> cols; + cols.push_back(col0.release()); + cols.push_back(col1.release()); + cudf::test::structs_column_wrapper struct_col(std::move(cols)); + + cudf::test::fixed_width_column_wrapper mask{}; + + auto expected = cudf::empty_like(struct_col); + + auto out = cudf::copy_if_else(lhs, rhs, mask); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(out->view(), *expected); + } +} + template struct CopyTestNumeric : public cudf::test::BaseFixture { };