Skip to content

Commit

Permalink
add empty test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwendt committed Sep 26, 2024
1 parent 8762aed commit bd08864
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cpp/src/strings/search/findall.cu
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ struct find_re_fn {
auto const d_str = d_strings.element<string_view>(idx);

auto const result = prog.find(thread_idx, d_str, d_str.begin());
if (!result.has_value()) { return -1; }
return result.value().first;
return result.has_value() ? result.value().first : -1;
}
};
} // namespace
Expand All @@ -153,10 +152,8 @@ std::unique_ptr<column> find_re(strings_column_view const& input,
mr);
if (input.is_empty()) { return results; }

auto d_results = results->mutable_view().data<size_type>();

auto d_prog = regex_device_builder::create_prog_device(prog, stream);

auto d_results = results->mutable_view().data<size_type>();
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
auto const d_strings = column_device_view::create(input.parent(), stream);
launch_transform_kernel(find_re_fn{*d_strings}, *d_prog, d_results, input.size(), stream);

Expand Down
13 changes: 13 additions & 0 deletions cpp/tests/strings/findall_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,16 @@ TEST_F(StringsFindallTests, FindTest)
cudf::test::fixed_width_column_wrapper<cudf::size_type>({0, 3, 3, -1, 1, 0, -1, 15}, valids);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected);
}

TEST_F(StringsFindallTests, EmptyTest)
{
cudf::test::strings_column_wrapper input;
auto sv = cudf::strings_column_view(input);

auto pattern = std::string("\\w+");

auto prog = cudf::strings::regex_program::create(pattern);
auto results = cudf::strings::find_re(sv, *prog);
auto expected = cudf::test::fixed_width_column_wrapper<cudf::size_type>();
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected);
}

0 comments on commit bd08864

Please sign in to comment.