Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some gtests incorrectly coded in namespace cudf::test (part I) #11917

Merged
merged 7 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 18 additions & 25 deletions cpp/tests/bitmask/is_element_valid_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, NVIDIA CORPORATION.
* Copyright (c) 2021-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 @@ -23,15 +23,12 @@

#include <thrust/iterator/counting_iterator.h>

namespace cudf {
namespace test {

struct IsElementValidTest : public BaseFixture {
struct IsElementValidTest : public cudf::test::BaseFixture {
};

TEST_F(IsElementValidTest, IsElementValidBasic)
{
fixed_width_column_wrapper<int32_t> col({1, 1, 1, 1, 1}, {1, 0, 0, 0, 1});
cudf::test::fixed_width_column_wrapper<int32_t> col({1, 1, 1, 1, 1}, {1, 0, 0, 0, 1});
EXPECT_TRUE(cudf::detail::is_element_valid_sync(col, 0));
EXPECT_FALSE(cudf::detail::is_element_valid_sync(col, 1));
EXPECT_FALSE(cudf::detail::is_element_valid_sync(col, 2));
Expand All @@ -41,12 +38,12 @@ TEST_F(IsElementValidTest, IsElementValidBasic)

TEST_F(IsElementValidTest, IsElementValidLarge)
{
auto filter = [](auto i) { return static_cast<bool>(i % 3); };
auto val = thrust::make_counting_iterator(0);
auto valid = cudf::detail::make_counting_transform_iterator(0, filter);
size_type num_rows = 1000;
auto filter = [](auto i) { return static_cast<bool>(i % 3); };
auto val = thrust::make_counting_iterator(0);
auto valid = cudf::detail::make_counting_transform_iterator(0, filter);
cudf::size_type num_rows = 1000;

fixed_width_column_wrapper<int32_t> col(val, val + num_rows, valid);
cudf::test::fixed_width_column_wrapper<int32_t> col(val, val + num_rows, valid);

for (int i = 0; i < num_rows; i++) {
EXPECT_EQ(cudf::detail::is_element_valid_sync(col, i), filter(i));
Expand All @@ -55,16 +52,16 @@ TEST_F(IsElementValidTest, IsElementValidLarge)

TEST_F(IsElementValidTest, IsElementValidOffset)
{
fixed_width_column_wrapper<int32_t> col({1, 1, 1, 1, 1}, {1, 0, 0, 0, 1});
cudf::test::fixed_width_column_wrapper<int32_t> col({1, 1, 1, 1, 1}, {1, 0, 0, 0, 1});
{
auto offset_col = slice(col, {1, 5}).front();
auto offset_col = cudf::slice(col, {1, 5}).front();
EXPECT_FALSE(cudf::detail::is_element_valid_sync(offset_col, 0));
EXPECT_FALSE(cudf::detail::is_element_valid_sync(offset_col, 1));
EXPECT_FALSE(cudf::detail::is_element_valid_sync(offset_col, 2));
EXPECT_TRUE(cudf::detail::is_element_valid_sync(offset_col, 3));
}
{
auto offset_col = slice(col, {2, 5}).front();
auto offset_col = cudf::slice(col, {2, 5}).front();
EXPECT_FALSE(cudf::detail::is_element_valid_sync(offset_col, 0));
EXPECT_FALSE(cudf::detail::is_element_valid_sync(offset_col, 1));
EXPECT_TRUE(cudf::detail::is_element_valid_sync(offset_col, 2));
Expand All @@ -73,20 +70,16 @@ TEST_F(IsElementValidTest, IsElementValidOffset)

TEST_F(IsElementValidTest, IsElementValidOffsetLarge)
{
auto filter = [](auto i) { return static_cast<bool>(i % 3); };
size_type offset = 37;
auto val = thrust::make_counting_iterator(0);
auto valid = cudf::detail::make_counting_transform_iterator(0, filter);
size_type num_rows = 1000;
auto filter = [](auto i) { return static_cast<bool>(i % 3); };
cudf::size_type offset = 37;
auto val = thrust::make_counting_iterator(0);
auto valid = cudf::detail::make_counting_transform_iterator(0, filter);
cudf::size_type num_rows = 1000;

fixed_width_column_wrapper<int32_t> col(val, val + num_rows, valid);
auto offset_col = slice(col, {offset, num_rows}).front();
cudf::test::fixed_width_column_wrapper<int32_t> col(val, val + num_rows, valid);
auto offset_col = cudf::slice(col, {offset, num_rows}).front();

for (int i = 0; i < offset_col.size(); i++) {
EXPECT_EQ(cudf::detail::is_element_valid_sync(offset_col, i), filter(i + offset));
}
}

} // namespace test

} // namespace cudf
Loading