Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JayjeetAtGithub committed Jul 22, 2024
1 parent 5989392 commit f23e624
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions cpp/tests/streams/lists_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023-2024, NVIDIA CORPORATION.
* Copyright (c) 2024, 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 Down Expand Up @@ -30,9 +30,6 @@
#include <cudf/lists/sorting.hpp>
#include <cudf/lists/stream_compaction.hpp>

using FCW = cudf::test::fixed_width_column_wrapper<int32_t>;
using LCW = cudf::test::lists_column_wrapper<int32_t>;

class ListTest : public cudf::test::BaseFixture {};

TEST_F(ListTest, ConcatenateRows)
Expand Down Expand Up @@ -219,42 +216,54 @@ TEST_F(ListTest, HaveOverlap)

TEST_F(ListTest, Explode)
{
FCW a{100, 200, 300};
LCW b{LCW{1, 2, 7}, LCW{5, 6}, LCW{0, 3}};
cudf::test::strings_column_wrapper c{"string0", "string1", "string2"};
cudf::table_view table({a, b, c});
cudf::explode(table, 1, cudf::test::get_default_stream());
cudf::test::fixed_width_column_wrapper<int32_t> list_col_a{100, 200, 300};
cudf::test::lists_column_wrapper<int32_t> list_col_b{
cudf::test::lists_column_wrapper<int32_t>{1, 2, 7},
cudf::test::lists_column_wrapper<int32_t>{5, 6},
cudf::test::lists_column_wrapper<int32_t>{0, 3}};
cudf::test::strings_column_wrapper list_col_c{"string0", "string1", "string2"};
cudf::table_view lists_table({list_col_a, list_col_b, list_col_c});
cudf::explode(lists_table, 1, cudf::test::get_default_stream());
}

TEST_F(ListTest, ExplodePosition)
{
FCW a{100, 200, 300};
LCW b{LCW{1, 2, 7}, LCW{5, 6}, LCW{0, 3}};
cudf::test::strings_column_wrapper c{"string0", "string1", "string2"};
cudf::table_view table({a, b, c});
cudf::explode_position(table, 1, cudf::test::get_default_stream());
cudf::test::fixed_width_column_wrapper<int32_t> list_col_a{100, 200, 300};
cudf::test::lists_column_wrapper<int32_t> list_col_b{
cudf::test::lists_column_wrapper<int32_t>{1, 2, 7},
cudf::test::lists_column_wrapper<int32_t>{5, 6},
cudf::test::lists_column_wrapper<int32_t>{0, 3}};
cudf::test::strings_column_wrapper list_col_c{"string0", "string1", "string2"};
cudf::table_view lists_table({list_col_a, list_col_b, list_col_c});
cudf::explode_position(lists_table, 1, cudf::test::get_default_stream());
}

TEST_F(ListTest, ExplodeOuter)
{
constexpr auto null = 0;
auto valids =
cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 2 == 0; });
LCW a{
LCW({1, null, 7}, valids), LCW({5, null, 0, null}, valids), LCW{}, LCW({0, null, 8}, valids)};
FCW b{100, 200, 300, 400};
cudf::table_view table({a, b});
cudf::explode_outer(table, 0, cudf::test::get_default_stream());
cudf::test::lists_column_wrapper<int32_t> list_col_a{
cudf::test::lists_column_wrapper<int32_t>({1, null, 7}, valids),
cudf::test::lists_column_wrapper<int32_t>({5, null, 0, null}, valids),
cudf::test::lists_column_wrapper<int32_t>{},
cudf::test::lists_column_wrapper<int32_t>({0, null, 8}, valids)};
cudf::test::fixed_width_column_wrapper<int32_t> list_col_b{100, 200, 300, 400};
cudf::table_view lists_table({list_col_a, list_col_b});
cudf::explode_outer(lists_table, 0, cudf::test::get_default_stream());
}

TEST_F(ListTest, ExplodeOuterPosition)
{
constexpr auto null = 0;
auto valids =
cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 2 == 0; });
LCW a{
LCW({1, null, 7}, valids), LCW({5, null, 0, null}, valids), LCW{}, LCW({0, null, 8}, valids)};
FCW b{100, 200, 300, 400};
cudf::table_view table({a, b});
cudf::explode_outer_position(table, 0, cudf::test::get_default_stream());
cudf::test::lists_column_wrapper<int32_t> list_col_a{
cudf::test::lists_column_wrapper<int32_t>({1, null, 7}, valids),
cudf::test::lists_column_wrapper<int32_t>({5, null, 0, null}, valids),
cudf::test::lists_column_wrapper<int32_t>{},
cudf::test::lists_column_wrapper<int32_t>({0, null, 8}, valids)};
cudf::test::fixed_width_column_wrapper<int32_t> list_col_b{100, 200, 300, 400};
cudf::table_view lists_table({list_col_a, list_col_b});
cudf::explode_outer_position(lists_table, 0, cudf::test::get_default_stream());
}

0 comments on commit f23e624

Please sign in to comment.