diff --git a/cpp/tests/bitmask/is_element_valid_tests.cpp b/cpp/tests/bitmask/is_element_valid_tests.cpp index 383448c0dd8..888d0103f03 100644 --- a/cpp/tests/bitmask/is_element_valid_tests.cpp +++ b/cpp/tests/bitmask/is_element_valid_tests.cpp @@ -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. @@ -23,15 +23,12 @@ #include -namespace cudf { -namespace test { - -struct IsElementValidTest : public BaseFixture { +struct IsElementValidTest : public cudf::test::BaseFixture { }; TEST_F(IsElementValidTest, IsElementValidBasic) { - fixed_width_column_wrapper col({1, 1, 1, 1, 1}, {1, 0, 0, 0, 1}); + cudf::test::fixed_width_column_wrapper 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)); @@ -41,12 +38,12 @@ TEST_F(IsElementValidTest, IsElementValidBasic) TEST_F(IsElementValidTest, IsElementValidLarge) { - auto filter = [](auto i) { return static_cast(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(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 col(val, val + num_rows, valid); + cudf::test::fixed_width_column_wrapper 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)); @@ -55,16 +52,16 @@ TEST_F(IsElementValidTest, IsElementValidLarge) TEST_F(IsElementValidTest, IsElementValidOffset) { - fixed_width_column_wrapper col({1, 1, 1, 1, 1}, {1, 0, 0, 0, 1}); + cudf::test::fixed_width_column_wrapper 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)); @@ -73,20 +70,16 @@ TEST_F(IsElementValidTest, IsElementValidOffset) TEST_F(IsElementValidTest, IsElementValidOffsetLarge) { - auto filter = [](auto i) { return static_cast(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(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 col(val, val + num_rows, valid); - auto offset_col = slice(col, {offset, num_rows}).front(); + cudf::test::fixed_width_column_wrapper 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 diff --git a/cpp/tests/hashing/hash_test.cpp b/cpp/tests/hashing/hash_test.cpp index baa7ba07ee4..c1a73761e8d 100644 --- a/cpp/tests/hashing/hash_test.cpp +++ b/cpp/tests/hashing/hash_test.cpp @@ -24,37 +24,35 @@ #include #include -using cudf::test::fixed_width_column_wrapper; -using cudf::test::strings_column_wrapper; -using namespace cudf::test; -using namespace cudf::test::iterators; - -constexpr debug_output_level verbosity{debug_output_level::ALL_ERRORS}; +constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; class HashTest : public cudf::test::BaseFixture { }; TEST_F(HashTest, MultiValue) { - strings_column_wrapper const strings_col({"", - "The quick brown fox", - "jumps over the lazy dog.", - "All work and no play makes Jack a dull boy", - R"(!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~)"}); + cudf::test::strings_column_wrapper const strings_col( + {"", + "The quick brown fox", + "jumps over the lazy dog.", + "All work and no play makes Jack a dull boy", + R"(!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~)"}); using limits = std::numeric_limits; - fixed_width_column_wrapper const ints_col({0, 100, -100, limits::min(), limits::max()}); + cudf::test::fixed_width_column_wrapper const ints_col( + {0, 100, -100, limits::min(), limits::max()}); // Different truth values should be equal - fixed_width_column_wrapper const bools_col1({0, 1, 1, 1, 0}); - fixed_width_column_wrapper const bools_col2({0, 1, 2, 255, 0}); + cudf::test::fixed_width_column_wrapper const bools_col1({0, 1, 1, 1, 0}); + cudf::test::fixed_width_column_wrapper const bools_col2({0, 1, 2, 255, 0}); using ts = cudf::timestamp_s; - fixed_width_column_wrapper const secs_col({ts::duration::zero(), - static_cast(100), - static_cast(-100), - ts::duration::min(), - ts::duration::max()}); + cudf::test::fixed_width_column_wrapper const secs_col( + {ts::duration::zero(), + static_cast(100), + static_cast(-100), + ts::duration::min(), + ts::duration::max()}); auto const input1 = cudf::table_view({strings_col, ints_col, bools_col1, secs_col}); auto const input2 = cudf::table_view({strings_col, ints_col, bools_col2, secs_col}); @@ -69,45 +67,49 @@ TEST_F(HashTest, MultiValue) TEST_F(HashTest, MultiValueNulls) { // Nulls with different values should be equal - strings_column_wrapper const strings_col1({"", - "The quick brown fox", - "jumps over the lazy dog.", - "All work and no play makes Jack a dull boy", - R"(!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~)"}, - {0, 1, 1, 0, 1}); - strings_column_wrapper const strings_col2({"different but null", - "The quick brown fox", - "jumps over the lazy dog.", - "I am Jack's complete lack of null value", - R"(!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~)"}, - {0, 1, 1, 0, 1}); + cudf::test::strings_column_wrapper const strings_col1( + {"", + "The quick brown fox", + "jumps over the lazy dog.", + "All work and no play makes Jack a dull boy", + R"(!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~)"}, + {0, 1, 1, 0, 1}); + cudf::test::strings_column_wrapper const strings_col2( + {"different but null", + "The quick brown fox", + "jumps over the lazy dog.", + "I am Jack's complete lack of null value", + R"(!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~)"}, + {0, 1, 1, 0, 1}); // Nulls with different values should be equal using limits = std::numeric_limits; - fixed_width_column_wrapper const ints_col1({0, 100, -100, limits::min(), limits::max()}, - {1, 0, 0, 1, 1}); - fixed_width_column_wrapper const ints_col2({0, -200, 200, limits::min(), limits::max()}, - {1, 0, 0, 1, 1}); + cudf::test::fixed_width_column_wrapper const ints_col1( + {0, 100, -100, limits::min(), limits::max()}, {1, 0, 0, 1, 1}); + cudf::test::fixed_width_column_wrapper const ints_col2( + {0, -200, 200, limits::min(), limits::max()}, {1, 0, 0, 1, 1}); // Nulls with different values should be equal // Different truth values should be equal - fixed_width_column_wrapper const bools_col1({0, 1, 0, 1, 1}, {1, 1, 0, 0, 1}); - fixed_width_column_wrapper const bools_col2({0, 2, 1, 0, 255}, {1, 1, 0, 0, 1}); + cudf::test::fixed_width_column_wrapper const bools_col1({0, 1, 0, 1, 1}, {1, 1, 0, 0, 1}); + cudf::test::fixed_width_column_wrapper const bools_col2({0, 2, 1, 0, 255}, {1, 1, 0, 0, 1}); // Nulls with different values should be equal using ts = cudf::timestamp_s; - fixed_width_column_wrapper const secs_col1({ts::duration::zero(), - static_cast(100), - static_cast(-100), - ts::duration::min(), - ts::duration::max()}, - {1, 0, 0, 1, 1}); - fixed_width_column_wrapper const secs_col2({ts::duration::zero(), - static_cast(-200), - static_cast(200), - ts::duration::min(), - ts::duration::max()}, - {1, 0, 0, 1, 1}); + cudf::test::fixed_width_column_wrapper const secs_col1( + {ts::duration::zero(), + static_cast(100), + static_cast(-100), + ts::duration::min(), + ts::duration::max()}, + {1, 0, 0, 1, 1}); + cudf::test::fixed_width_column_wrapper const secs_col2( + {ts::duration::zero(), + static_cast(-200), + static_cast(200), + ts::duration::min(), + ts::duration::max()}, + {1, 0, 0, 1, 1}); auto const input1 = cudf::table_view({strings_col1, ints_col1, bools_col1, secs_col1}); auto const input2 = cudf::table_view({strings_col2, ints_col2, bools_col2, secs_col2}); @@ -355,7 +357,7 @@ TYPED_TEST_SUITE(HashTestTyped, cudf::test::FixedWidthTypes); TYPED_TEST(HashTestTyped, Equality) { - fixed_width_column_wrapper const col{0, 127, 1, 2, 8}; + cudf::test::fixed_width_column_wrapper const col{0, 127, 1, 2, 8}; auto const input = cudf::table_view({col}); // Hash of same input should be equal @@ -377,8 +379,8 @@ TYPED_TEST(HashTestTyped, EqualityNulls) using T = TypeParam; // Nulls with different values should be equal - fixed_width_column_wrapper const col1({0, 127, 1, 2, 8}, {0, 1, 1, 1, 1}); - fixed_width_column_wrapper const col2({1, 127, 1, 2, 8}, {0, 1, 1, 1, 1}); + cudf::test::fixed_width_column_wrapper const col1({0, 127, 1, 2, 8}, {0, 1, 1, 1, 1}); + cudf::test::fixed_width_column_wrapper const col2({1, 127, 1, 2, 8}, {0, 1, 1, 1, 1}); auto const input1 = cudf::table_view({col1}); auto const input2 = cudf::table_view({col2}); @@ -410,10 +412,11 @@ TYPED_TEST(HashTestFloatTyped, TestExtremes) T nan = std::numeric_limits::quiet_NaN(); T inf = std::numeric_limits::infinity(); - fixed_width_column_wrapper const col({T(0.0), T(100.0), T(-100.0), min, max, nan, inf, -inf}); - fixed_width_column_wrapper const col_neg_zero( + cudf::test::fixed_width_column_wrapper const col( + {T(0.0), T(100.0), T(-100.0), min, max, nan, inf, -inf}); + cudf::test::fixed_width_column_wrapper const col_neg_zero( {T(-0.0), T(100.0), T(-100.0), min, max, nan, inf, -inf}); - fixed_width_column_wrapper const col_neg_nan( + cudf::test::fixed_width_column_wrapper const col_neg_nan( {T(0.0), T(100.0), T(-100.0), min, max, -nan, inf, -inf}); auto const table_col = cudf::table_view({col}); @@ -505,76 +508,77 @@ TEST_F(SparkMurmurHash3Test, MultiValueWithSeeds) println(s"combined => ${df.select(hash(col("*"))).collect.mkString(",")}") */ - fixed_width_column_wrapper const hash_structs_expected( + cudf::test::fixed_width_column_wrapper const hash_structs_expected( {-105406170, 90479889, -678041645, 1667387937, 301478567}); - fixed_width_column_wrapper const hash_strings_expected( + cudf::test::fixed_width_column_wrapper const hash_strings_expected( {142593372, 1217302703, -715697185, -2061143941, -111635966}); - fixed_width_column_wrapper const hash_doubles_expected( + cudf::test::fixed_width_column_wrapper const hash_doubles_expected( {-1670924195, -853646085, -1281358385, 1897734433, -508695674}); - fixed_width_column_wrapper const hash_timestamps_expected( + cudf::test::fixed_width_column_wrapper const hash_timestamps_expected( {-1670924195, 1114849490, 904948192, -1832979433, 1752430209}); - fixed_width_column_wrapper const hash_decimal64_expected( + cudf::test::fixed_width_column_wrapper const hash_decimal64_expected( {-1670924195, 1114849490, 904948192, 1962370902, -1795328666}); - fixed_width_column_wrapper const hash_longs_expected( + cudf::test::fixed_width_column_wrapper const hash_longs_expected( {-1670924195, 1114849490, 904948192, -853646085, -1604625029}); - fixed_width_column_wrapper const hash_floats_expected( + cudf::test::fixed_width_column_wrapper const hash_floats_expected( {933211791, 723455942, -349261430, -1225560532, -338752985}); - fixed_width_column_wrapper const hash_dates_expected( + cudf::test::fixed_width_column_wrapper const hash_dates_expected( {933211791, 751823303, -1080202046, -1906567553, -1503850410}); - fixed_width_column_wrapper const hash_decimal32_expected( + cudf::test::fixed_width_column_wrapper const hash_decimal32_expected( {-1670924195, 1114849490, 904948192, -1454351396, -193774131}); - fixed_width_column_wrapper const hash_ints_expected( + cudf::test::fixed_width_column_wrapper const hash_ints_expected( {933211791, 751823303, -1080202046, 723455942, 133916647}); - fixed_width_column_wrapper const hash_shorts_expected( + cudf::test::fixed_width_column_wrapper const hash_shorts_expected( {933211791, 751823303, -1080202046, -1871935946, 1249274084}); - fixed_width_column_wrapper const hash_bytes_expected( + cudf::test::fixed_width_column_wrapper const hash_bytes_expected( {933211791, 751823303, -1080202046, 1110053733, 1135925485}); - fixed_width_column_wrapper const hash_bools_expected( + cudf::test::fixed_width_column_wrapper const hash_bools_expected( {933211791, -559580957, -559580957, -559580957, 933211791}); - fixed_width_column_wrapper const hash_decimal128_expected( + cudf::test::fixed_width_column_wrapper const hash_decimal128_expected( {-783713497, -295670906, 1398487324, -52622807, -1359749815}); - fixed_width_column_wrapper const hash_combined_expected( + cudf::test::fixed_width_column_wrapper const hash_combined_expected( {401603227, 588162166, 552160517, 1132537411, -326043017}); using double_limits = std::numeric_limits; using long_limits = std::numeric_limits; using float_limits = std::numeric_limits; using int_limits = std::numeric_limits; - fixed_width_column_wrapper a_col{0, 100, -100, 0x1234'5678, -0x7654'3210}; - strings_column_wrapper b_col{"a", "bc", "def", "ghij", "klmno"}; - fixed_width_column_wrapper x_col{ + cudf::test::fixed_width_column_wrapper a_col{0, 100, -100, 0x1234'5678, -0x7654'3210}; + cudf::test::strings_column_wrapper b_col{"a", "bc", "def", "ghij", "klmno"}; + cudf::test::fixed_width_column_wrapper x_col{ 0.f, 100.f, -100.f, float_limits::infinity(), -float_limits::infinity()}; - fixed_width_column_wrapper y_col{ + cudf::test::fixed_width_column_wrapper y_col{ 0L, 100L, -100L, 0x0123'4567'89ab'cdefL, -0x0123'4567'89ab'cdefL}; - structs_column_wrapper c_col{{x_col, y_col}}; - structs_column_wrapper const structs_col{{a_col, b_col, c_col}}; - - strings_column_wrapper const strings_col({"", - "The quick brown fox", - "jumps over the lazy dog.", - "All work and no play makes Jack a dull boy", - "!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~\ud720\ud721"}); - fixed_width_column_wrapper const doubles_col( + cudf::test::structs_column_wrapper c_col{{x_col, y_col}}; + cudf::test::structs_column_wrapper const structs_col{{a_col, b_col, c_col}}; + + cudf::test::strings_column_wrapper const strings_col( + {"", + "The quick brown fox", + "jumps over the lazy dog.", + "All work and no play makes Jack a dull boy", + "!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~\ud720\ud721"}); + cudf::test::fixed_width_column_wrapper const doubles_col( {0., -0., -double_limits::quiet_NaN(), double_limits::lowest(), double_limits::max()}); - fixed_width_column_wrapper const timestamps_col( - {0L, 100L, -100L, long_limits::min() / 1000000, long_limits::max() / 1000000}); - fixed_point_column_wrapper const decimal64_col( + cudf::test::fixed_width_column_wrapper const + timestamps_col({0L, 100L, -100L, long_limits::min() / 1000000, long_limits::max() / 1000000}); + cudf::test::fixed_point_column_wrapper const decimal64_col( {0L, 100L, -100L, -999999999999999999L, 999999999999999999L}, numeric::scale_type{-7}); - fixed_width_column_wrapper const longs_col( + cudf::test::fixed_width_column_wrapper const longs_col( {0L, 100L, -100L, long_limits::min(), long_limits::max()}); - fixed_width_column_wrapper const floats_col( + cudf::test::fixed_width_column_wrapper const floats_col( {0.f, -0.f, -float_limits::quiet_NaN(), float_limits::lowest(), float_limits::max()}); - fixed_width_column_wrapper dates_col( + cudf::test::fixed_width_column_wrapper dates_col( {0, 100, -100, int_limits::min() / 100, int_limits::max() / 100}); - fixed_point_column_wrapper const decimal32_col({0, 100, -100, -999999999, 999999999}, - numeric::scale_type{-3}); - fixed_width_column_wrapper const ints_col( + cudf::test::fixed_point_column_wrapper const decimal32_col( + {0, 100, -100, -999999999, 999999999}, numeric::scale_type{-3}); + cudf::test::fixed_width_column_wrapper const ints_col( {0, 100, -100, int_limits::min(), int_limits::max()}); - fixed_width_column_wrapper const shorts_col({0, 100, -100, -32768, 32767}); - fixed_width_column_wrapper const bytes_col({0, 100, -100, -128, 127}); - fixed_width_column_wrapper const bools_col1({0, 1, 1, 1, 0}); - fixed_width_column_wrapper const bools_col2({0, 1, 2, 255, 0}); - fixed_point_column_wrapper<__int128_t> const decimal128_col( + cudf::test::fixed_width_column_wrapper const shorts_col({0, 100, -100, -32768, 32767}); + cudf::test::fixed_width_column_wrapper const bytes_col({0, 100, -100, -128, 127}); + cudf::test::fixed_width_column_wrapper const bools_col1({0, 1, 1, 1, 0}); + cudf::test::fixed_width_column_wrapper const bools_col2({0, 1, 2, 255, 0}); + cudf::test::fixed_point_column_wrapper<__int128_t> const decimal128_col( {static_cast<__int128>(0), static_cast<__int128>(100), static_cast<__int128>(-1), @@ -644,14 +648,15 @@ TEST_F(SparkMurmurHash3Test, StringsWithSeed) // .map(org.apache.spark.sql.catalyst.expressions.Murmur3HashFunction.hash( // _, org.apache.spark.sql.types.StringType, 314))) - fixed_width_column_wrapper const hash_strings_expected_seed_314( + cudf::test::fixed_width_column_wrapper const hash_strings_expected_seed_314( {1467149710, 723257560, -1620282500, -2001858707, 1588473657}); - strings_column_wrapper const strings_col({"", - "The quick brown fox", - "jumps over the lazy dog.", - "All work and no play makes Jack a dull boy", - "!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~\ud720\ud721"}); + cudf::test::strings_column_wrapper const strings_col( + {"", + "The quick brown fox", + "jumps over the lazy dog.", + "All work and no play makes Jack a dull boy", + "!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~\ud720\ud721"}); constexpr auto hasher = cudf::hash_id::HASH_SPARK_MURMUR3; auto const hash_strings = cudf::hash(cudf::table_view({strings_col}), hasher, 314); @@ -691,27 +696,28 @@ TEST_F(SparkMurmurHash3Test, ListValues) df2.show(false) */ - auto const null = -1; - auto nested_list = cudf::test::lists_column_wrapper({{}, - {1}, - {1, 2}, - {1, 2, 3}, - {1, 2}, - {3}, - {1}, - {2, 3}, - {1}, - {{null, 2, 3}, nulls_at({0})}, - {1, 2}, - {3}, - {{null}, nulls_at({0})}, - {1, 2}, - {}, - {3}}, - nulls_at({0, 14})); + auto const null = -1; + auto nested_list = + cudf::test::lists_column_wrapper({{}, + {1}, + {1, 2}, + {1, 2, 3}, + {1, 2}, + {3}, + {1}, + {2, 3}, + {1}, + {{null, 2, 3}, cudf::test::iterators::nulls_at({0})}, + {1, 2}, + {3}, + {{null}, cudf::test::iterators::nulls_at({0})}, + {1, 2}, + {}, + {3}}, + cudf::test::iterators::nulls_at({0, 14})); auto offsets = cudf::test::fixed_width_column_wrapper{0, 0, 0, 1, 2, 3, 4, 6, 8, 10, 13, 16}; - auto list_validity = nulls_at({0}); + auto list_validity = cudf::test::iterators::nulls_at({0}); auto list_validity_buffer = cudf::test::detail::make_null_mask(list_validity, list_validity + 11); auto list_column = cudf::make_lists_column(11, offsets.release(), @@ -766,11 +772,18 @@ TEST_F(SparkMurmurHash3Test, StructOfListValues) */ auto const null = -1; - auto col1 = cudf::test::lists_column_wrapper( - {{}, {0}, {{1, null}, nulls_at({1})}, {{1, null}, nulls_at({1})}, {}, {} /*NULL*/, {2, 3}}, - nulls_at({5})); + auto col1 = + cudf::test::lists_column_wrapper({{}, + {0}, + {{1, null}, cudf::test::iterators::nulls_at({1})}, + {{1, null}, cudf::test::iterators::nulls_at({1})}, + {}, + {} /*NULL*/, + {2, 3}}, + cudf::test::iterators::nulls_at({5})); auto col2 = cudf::test::lists_column_wrapper( - {{}, {0}, {} /*NULL*/, {}, {{null, 1}, nulls_at({0})}, {1}, {4, 5}}, nulls_at({2})); + {{}, {0}, {} /*NULL*/, {}, {{null, 1}, cudf::test::iterators::nulls_at({0})}, {1}, {4, 5}}, + cudf::test::iterators::nulls_at({2})); auto struct_column = cudf::test::structs_column_wrapper{{col1, col2}}; auto expect = cudf::test::fixed_width_column_wrapper{ @@ -813,12 +826,15 @@ TEST_F(SparkMurmurHash3Test, ListOfStructValues) */ auto const null = -1; - auto col1 = fixed_width_column_wrapper({0, null, null, 1, null, null, 2, 2, null, 2, 4}, - nulls_at({1, 2, 4, 5, 8})); - auto col2 = fixed_width_column_wrapper({0, null, null, null, 1, 1, 3, 3, null, 3, 5}, - nulls_at({1, 2, 3, 8})); - auto struct_column = structs_column_wrapper{{col1, col2}, {1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1}}; - auto offsets = fixed_width_column_wrapper{0, 1, 2, 3, 4, 5, 7, 9, 11}; + auto col1 = cudf::test::fixed_width_column_wrapper( + {0, null, null, 1, null, null, 2, 2, null, 2, 4}, + cudf::test::iterators::nulls_at({1, 2, 4, 5, 8})); + auto col2 = cudf::test::fixed_width_column_wrapper( + {0, null, null, null, 1, 1, 3, 3, null, 3, 5}, cudf::test::iterators::nulls_at({1, 2, 3, 8})); + auto struct_column = + cudf::test::structs_column_wrapper{{col1, col2}, {1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1}}; + auto offsets = + cudf::test::fixed_width_column_wrapper{0, 1, 2, 3, 4, 5, 7, 9, 11}; auto list_nullmask = std::vector(1, 8); auto list_validity_buffer = cudf::test::detail::make_null_mask(list_nullmask.begin(), list_nullmask.end()); @@ -847,7 +863,7 @@ class MD5HashTest : public cudf::test::BaseFixture { TEST_F(MD5HashTest, MultiValue) { - strings_column_wrapper const strings_col( + cudf::test::strings_column_wrapper const strings_col( {"", "A 60 character string to test MD5's message padding algorithm", "A very long (greater than 128 bytes/char string) to test a multi hash-step data point in the " @@ -855,24 +871,27 @@ TEST_F(MD5HashTest, MultiValue) "All work and no play makes Jack a dull boy", R"(!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~)"}); - strings_column_wrapper const md5_string_results1({"d41d8cd98f00b204e9800998ecf8427e", - "682240021651ae166d08fe2a014d5c09", - "3669d5225fddbb34676312ca3b78bbd9", - "c61a4185135eda043f35e92c3505e180", - "52da74c75cb6575d25be29e66bd0adde"}); + cudf::test::strings_column_wrapper const md5_string_results1( + {"d41d8cd98f00b204e9800998ecf8427e", + "682240021651ae166d08fe2a014d5c09", + "3669d5225fddbb34676312ca3b78bbd9", + "c61a4185135eda043f35e92c3505e180", + "52da74c75cb6575d25be29e66bd0adde"}); - strings_column_wrapper const md5_string_results2({"d41d8cd98f00b204e9800998ecf8427e", - "e5a5682e82278e78dbaad9a689df7a73", - "4121ab1bb6e84172fd94822645862ae9", - "28970886501efe20164213855afe5850", - "6bc1b872103cc6a02d882245b8516e2e"}); + cudf::test::strings_column_wrapper const md5_string_results2( + {"d41d8cd98f00b204e9800998ecf8427e", + "e5a5682e82278e78dbaad9a689df7a73", + "4121ab1bb6e84172fd94822645862ae9", + "28970886501efe20164213855afe5850", + "6bc1b872103cc6a02d882245b8516e2e"}); using limits = std::numeric_limits; - fixed_width_column_wrapper const ints_col({0, 100, -100, limits::min(), limits::max()}); + cudf::test::fixed_width_column_wrapper const ints_col( + {0, 100, -100, limits::min(), limits::max()}); // Different truth values should be equal - fixed_width_column_wrapper const bools_col1({0, 1, 1, 1, 0}); - fixed_width_column_wrapper const bools_col2({0, 1, 2, 255, 0}); + cudf::test::fixed_width_column_wrapper const bools_col1({0, 1, 1, 1, 0}); + cudf::test::fixed_width_column_wrapper const bools_col2({0, 1, 2, 255, 0}); auto const string_input1 = cudf::table_view({strings_col}); auto const string_input2 = cudf::table_view({strings_col, strings_col}); @@ -894,7 +913,7 @@ TEST_F(MD5HashTest, MultiValue) TEST_F(MD5HashTest, MultiValueNulls) { // Nulls with different values should be equal - strings_column_wrapper const strings_col1( + cudf::test::strings_column_wrapper const strings_col1( {"", "Different but null!", "A very long (greater than 128 bytes/char string) to test a multi hash-step data point in the " @@ -902,7 +921,7 @@ TEST_F(MD5HashTest, MultiValueNulls) "All work and no play makes Jack a dull boy", R"(!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~)"}, {1, 0, 0, 1, 0}); - strings_column_wrapper const strings_col2( + cudf::test::strings_column_wrapper const strings_col2( {"", "A 60 character string to test MD5's message padding algorithm", "Very different... but null", @@ -912,15 +931,15 @@ TEST_F(MD5HashTest, MultiValueNulls) // Nulls with different values should be equal using limits = std::numeric_limits; - fixed_width_column_wrapper const ints_col1({0, 100, -100, limits::min(), limits::max()}, - {1, 0, 0, 1, 1}); - fixed_width_column_wrapper const ints_col2({0, -200, 200, limits::min(), limits::max()}, - {1, 0, 0, 1, 1}); + cudf::test::fixed_width_column_wrapper const ints_col1( + {0, 100, -100, limits::min(), limits::max()}, {1, 0, 0, 1, 1}); + cudf::test::fixed_width_column_wrapper const ints_col2( + {0, -200, 200, limits::min(), limits::max()}, {1, 0, 0, 1, 1}); // Nulls with different values should be equal // Different truth values should be equal - fixed_width_column_wrapper const bools_col1({0, 1, 0, 1, 1}, {1, 1, 0, 0, 1}); - fixed_width_column_wrapper const bools_col2({0, 2, 1, 0, 255}, {1, 1, 0, 0, 1}); + cudf::test::fixed_width_column_wrapper const bools_col1({0, 1, 0, 1, 1}, {1, 1, 0, 0, 1}); + cudf::test::fixed_width_column_wrapper const bools_col2({0, 2, 1, 0, 255}, {1, 1, 0, 0, 1}); auto const input1 = cudf::table_view({strings_col1, ints_col1, bools_col1}); auto const input2 = cudf::table_view({strings_col2, ints_col2, bools_col2}); @@ -936,7 +955,7 @@ TEST_F(MD5HashTest, StringListsNulls) { auto validity = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i != 0; }); - strings_column_wrapper const strings_col( + cudf::test::strings_column_wrapper const strings_col( {"", "A 60 character string to test MD5's message padding algorithm", "A very long (greater than 128 bytes/char string) to test a multi hash-step data point in the " @@ -944,7 +963,7 @@ TEST_F(MD5HashTest, StringListsNulls) "All work and no play makes Jack a dull boy", R"(!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~)"}); - lists_column_wrapper strings_list_col( + cudf::test::lists_column_wrapper strings_list_col( {{""}, {{"NULL", "A 60 character string to test MD5's message padding algorithm"}, validity}, {"A very long (greater than 128 bytes/char string) to test a multi hash-step data point in " @@ -971,7 +990,7 @@ TYPED_TEST_SUITE(MD5HashTestTyped, cudf::test::NumericTypes); TYPED_TEST(MD5HashTestTyped, Equality) { - fixed_width_column_wrapper const col({0, 127, 1, 2, 8}); + cudf::test::fixed_width_column_wrapper const col({0, 127, 1, 2, 8}); auto const input = cudf::table_view({col}); // Hash of same input should be equal @@ -987,8 +1006,8 @@ TYPED_TEST(MD5HashTestTyped, EqualityNulls) using T = TypeParam; // Nulls with different values should be equal - fixed_width_column_wrapper const col1({0, 127, 1, 2, 8}, {0, 1, 1, 1, 1}); - fixed_width_column_wrapper const col2({1, 127, 1, 2, 8}, {0, 1, 1, 1, 1}); + cudf::test::fixed_width_column_wrapper const col1({0, 127, 1, 2, 8}, {0, 1, 1, 1, 1}); + cudf::test::fixed_width_column_wrapper const col2({1, 127, 1, 2, 8}, {0, 1, 1, 1, 1}); auto const input1 = cudf::table_view({col1}); auto const input2 = cudf::table_view({col2}); @@ -1002,15 +1021,15 @@ TYPED_TEST(MD5HashTestTyped, EqualityNulls) TEST_F(MD5HashTest, TestBoolListsWithNulls) { - fixed_width_column_wrapper const col1({0, 255, 255, 16, 27, 18, 100, 1, 2}, - {1, 0, 0, 0, 1, 1, 1, 0, 0}); - fixed_width_column_wrapper const col2({0, 255, 255, 32, 81, 68, 3, 101, 4}, - {1, 0, 0, 1, 0, 1, 0, 1, 0}); - fixed_width_column_wrapper const col3({0, 255, 255, 64, 49, 42, 5, 6, 102}, - {1, 0, 0, 1, 1, 0, 0, 0, 1}); + cudf::test::fixed_width_column_wrapper const col1({0, 255, 255, 16, 27, 18, 100, 1, 2}, + {1, 0, 0, 0, 1, 1, 1, 0, 0}); + cudf::test::fixed_width_column_wrapper const col2({0, 255, 255, 32, 81, 68, 3, 101, 4}, + {1, 0, 0, 1, 0, 1, 0, 1, 0}); + cudf::test::fixed_width_column_wrapper const col3({0, 255, 255, 64, 49, 42, 5, 6, 102}, + {1, 0, 0, 1, 1, 0, 0, 0, 1}); auto validity = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i != 1; }); - lists_column_wrapper const list_col( + cudf::test::lists_column_wrapper const list_col( {{0, 0, 0}, {1}, {}, {{1, 1, 1}, validity}, {1, 1}, {1, 1}, {1}, {1}, {1}}, validity); auto const input1 = cudf::table_view({col1, col2, col3}); @@ -1027,22 +1046,23 @@ template class MD5HashListTestTyped : public cudf::test::BaseFixture { }; -using NumericTypesNoBools = Concat; +using NumericTypesNoBools = + cudf::test::Concat; TYPED_TEST_SUITE(MD5HashListTestTyped, NumericTypesNoBools); TYPED_TEST(MD5HashListTestTyped, TestListsWithNulls) { using T = TypeParam; - fixed_width_column_wrapper const col1({0, 255, 255, 16, 27, 18, 100, 1, 2}, - {1, 0, 0, 0, 1, 1, 1, 0, 0}); - fixed_width_column_wrapper const col2({0, 255, 255, 32, 81, 68, 3, 101, 4}, - {1, 0, 0, 1, 0, 1, 0, 1, 0}); - fixed_width_column_wrapper const col3({0, 255, 255, 64, 49, 42, 5, 6, 102}, - {1, 0, 0, 1, 1, 0, 0, 0, 1}); + cudf::test::fixed_width_column_wrapper const col1({0, 255, 255, 16, 27, 18, 100, 1, 2}, + {1, 0, 0, 0, 1, 1, 1, 0, 0}); + cudf::test::fixed_width_column_wrapper const col2({0, 255, 255, 32, 81, 68, 3, 101, 4}, + {1, 0, 0, 1, 0, 1, 0, 1, 0}); + cudf::test::fixed_width_column_wrapper const col3({0, 255, 255, 64, 49, 42, 5, 6, 102}, + {1, 0, 0, 1, 1, 0, 0, 0, 1}); auto validity = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i != 1; }); - lists_column_wrapper const list_col( + cudf::test::lists_column_wrapper const list_col( {{0, 0, 0}, {127}, {}, {{32, 127, 64}, validity}, {27, 49}, {18, 68}, {100}, {101}, {102}}, validity); @@ -1070,8 +1090,9 @@ TYPED_TEST(MD5HashTestFloatTyped, TestExtremes) T nan = std::numeric_limits::quiet_NaN(); T inf = std::numeric_limits::infinity(); - fixed_width_column_wrapper const col1({T(0.0), T(100.0), T(-100.0), min, max, nan, inf, -inf}); - fixed_width_column_wrapper const col2( + cudf::test::fixed_width_column_wrapper const col1( + {T(0.0), T(100.0), T(-100.0), min, max, nan, inf, -inf}); + cudf::test::fixed_width_column_wrapper const col2( {T(-0.0), T(100.0), T(-100.0), min, max, -nan, inf, -inf}); auto const input1 = cudf::table_view({col1}); @@ -1091,9 +1112,9 @@ TYPED_TEST(MD5HashTestFloatTyped, TestListExtremes) T nan = std::numeric_limits::quiet_NaN(); T inf = std::numeric_limits::infinity(); - lists_column_wrapper const col1( + cudf::test::lists_column_wrapper const col1( {{T(0.0)}, {T(100.0), T(-100.0)}, {min, max, nan}, {inf, -inf}}); - lists_column_wrapper const col2( + cudf::test::lists_column_wrapper const col2( {{T(-0.0)}, {T(100.0), T(-100.0)}, {min, max, -nan}, {inf, -inf}}); auto const input1 = cudf::table_view({col1}); diff --git a/cpp/tests/interop/dlpack_test.cpp b/cpp/tests/interop/dlpack_test.cpp index da9f80cf3d7..2862590d05f 100644 --- a/cpp/tests/interop/dlpack_test.cpp +++ b/cpp/tests/interop/dlpack_test.cpp @@ -24,8 +24,6 @@ #include -using namespace cudf::test; - struct dlpack_deleter { void operator()(DLManagedTensor* tensor) { tensor->deleter(tensor); } }; @@ -61,7 +59,7 @@ void validate_dtype(DLDataType const& dtype) EXPECT_EQ(sizeof(T) * 8, dtype.bits); } -class DLPackUntypedTests : public BaseFixture { +class DLPackUntypedTests : public cudf::test::BaseFixture { }; TEST_F(DLPackUntypedTests, EmptyTableToDlpack) @@ -73,8 +71,8 @@ TEST_F(DLPackUntypedTests, EmptyTableToDlpack) TEST_F(DLPackUntypedTests, EmptyColsToDlpack) { - fixed_width_column_wrapper col1({}); - fixed_width_column_wrapper col2({}); + cudf::test::fixed_width_column_wrapper col1({}); + cudf::test::fixed_width_column_wrapper col2({}); cudf::table_view input({col1, col2}); unique_managed_tensor tensor(cudf::to_dlpack(input)); validate_dtype(tensor->dl_tensor.dtype); @@ -97,30 +95,30 @@ TEST_F(DLPackUntypedTests, NullTensorFromDlpack) TEST_F(DLPackUntypedTests, MultipleTypesToDlpack) { - fixed_width_column_wrapper col1({1, 2, 3, 4}); - fixed_width_column_wrapper col2({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col1({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col2({1, 2, 3, 4}); cudf::table_view input({col1, col2}); EXPECT_THROW(cudf::to_dlpack(input), cudf::logic_error); } TEST_F(DLPackUntypedTests, InvalidNullsToDlpack) { - fixed_width_column_wrapper col1({1, 2, 3, 4}); - fixed_width_column_wrapper col2({1, 2, 3, 4}, {1, 0, 1, 1}); + cudf::test::fixed_width_column_wrapper col1({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col2({1, 2, 3, 4}, {1, 0, 1, 1}); cudf::table_view input({col1, col2}); EXPECT_THROW(cudf::to_dlpack(input), cudf::logic_error); } TEST_F(DLPackUntypedTests, StringTypeToDlpack) { - strings_column_wrapper col({"foo", "bar", "baz"}); + cudf::test::strings_column_wrapper col({"foo", "bar", "baz"}); cudf::table_view input({col}); EXPECT_THROW(cudf::to_dlpack(input), cudf::logic_error); } TEST_F(DLPackUntypedTests, UnsupportedDeviceTypeFromDlpack) { - fixed_width_column_wrapper col({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}); cudf::table_view input({col}); unique_managed_tensor tensor(cudf::to_dlpack(input)); @@ -131,7 +129,7 @@ TEST_F(DLPackUntypedTests, UnsupportedDeviceTypeFromDlpack) TEST_F(DLPackUntypedTests, InvalidDeviceIdFromDlpack) { - fixed_width_column_wrapper col({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}); cudf::table_view input({col}); unique_managed_tensor tensor(cudf::to_dlpack(input)); @@ -142,7 +140,7 @@ TEST_F(DLPackUntypedTests, InvalidDeviceIdFromDlpack) TEST_F(DLPackUntypedTests, UnsupportedDimsFromDlpack) { - fixed_width_column_wrapper col({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}); cudf::table_view input({col}); unique_managed_tensor tensor(cudf::to_dlpack(input)); @@ -153,7 +151,7 @@ TEST_F(DLPackUntypedTests, UnsupportedDimsFromDlpack) TEST_F(DLPackUntypedTests, TooManyRowsFromDlpack) { - fixed_width_column_wrapper col({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}); cudf::table_view input({col}); unique_managed_tensor tensor(cudf::to_dlpack(input)); @@ -165,8 +163,8 @@ TEST_F(DLPackUntypedTests, TooManyRowsFromDlpack) TEST_F(DLPackUntypedTests, TooManyColsFromDlpack) { - fixed_width_column_wrapper col1({1, 2, 3, 4}); - fixed_width_column_wrapper col2({5, 6, 7, 8}); + cudf::test::fixed_width_column_wrapper col1({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col2({5, 6, 7, 8}); cudf::table_view input({col1, col2}); unique_managed_tensor tensor(cudf::to_dlpack(input)); @@ -178,7 +176,7 @@ TEST_F(DLPackUntypedTests, TooManyColsFromDlpack) TEST_F(DLPackUntypedTests, InvalidTypeFromDlpack) { - fixed_width_column_wrapper col({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}); cudf::table_view input({col}); unique_managed_tensor tensor(cudf::to_dlpack(input)); @@ -189,7 +187,7 @@ TEST_F(DLPackUntypedTests, InvalidTypeFromDlpack) TEST_F(DLPackUntypedTests, UnsupportedIntBitsizeFromDlpack) { - fixed_width_column_wrapper col({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}); cudf::table_view input({col}); unique_managed_tensor tensor(cudf::to_dlpack(input)); @@ -200,7 +198,7 @@ TEST_F(DLPackUntypedTests, UnsupportedIntBitsizeFromDlpack) TEST_F(DLPackUntypedTests, UnsupportedFloatBitsizeFromDlpack) { - fixed_width_column_wrapper col({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}); cudf::table_view input({col}); unique_managed_tensor tensor(cudf::to_dlpack(input)); @@ -211,7 +209,7 @@ TEST_F(DLPackUntypedTests, UnsupportedFloatBitsizeFromDlpack) TEST_F(DLPackUntypedTests, UnsupportedLanesFromDlpack) { - fixed_width_column_wrapper col({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}); cudf::table_view input({col}); unique_managed_tensor tensor(cudf::to_dlpack(input)); @@ -335,20 +333,20 @@ TEST_F(DLPackUntypedTests, UnsupportedStridedColMajor2DTensorFromDlpack) } template -class DLPackTimestampTests : public BaseFixture { +class DLPackTimestampTests : public cudf::test::BaseFixture { }; -TYPED_TEST_SUITE(DLPackTimestampTests, ChronoTypes); +TYPED_TEST_SUITE(DLPackTimestampTests, cudf::test::ChronoTypes); TYPED_TEST(DLPackTimestampTests, ChronoTypesToDlpack) { - fixed_width_column_wrapper col({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}); cudf::table_view input({col}); EXPECT_THROW(cudf::to_dlpack(input), cudf::logic_error); } template -class DLPackNumericTests : public BaseFixture { +class DLPackNumericTests : public cudf::test::BaseFixture { }; // The list of supported types comes from DLDataType_to_data_type() in cpp/src/dlpack/dlpack.cpp @@ -360,7 +358,7 @@ TYPED_TEST_SUITE(DLPackNumericTests, SupportedTypes); TYPED_TEST(DLPackNumericTests, ToDlpack1D) { // Test nullable column with no nulls - fixed_width_column_wrapper col({1, 2, 3, 4}, {1, 1, 1, 1}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}, {1, 1, 1, 1}); auto const col_view = static_cast(col); EXPECT_FALSE(col_view.has_nulls()); EXPECT_TRUE(col_view.nullable()); @@ -389,9 +387,11 @@ TYPED_TEST(DLPackNumericTests, ToDlpack2D) using T = TypeParam; auto const col1_tmp = cudf::test::make_type_param_vector({1, 2, 3, 4}); auto const col2_tmp = cudf::test::make_type_param_vector({4, 5, 6, 7}); - std::vector> cols; - cols.push_back(fixed_width_column_wrapper(col1_tmp.cbegin(), col1_tmp.cend())); - cols.push_back(fixed_width_column_wrapper(col2_tmp.cbegin(), col2_tmp.cend())); + std::vector> cols; + cols.push_back( + cudf::test::fixed_width_column_wrapper(col1_tmp.cbegin(), col1_tmp.cend())); + cols.push_back( + cudf::test::fixed_width_column_wrapper(col2_tmp.cbegin(), col2_tmp.cend())); std::vector col_views; std::transform(cols.begin(), cols.end(), std::back_inserter(col_views), [](auto const& col) { @@ -427,7 +427,7 @@ TYPED_TEST(DLPackNumericTests, ToDlpack2D) TYPED_TEST(DLPackNumericTests, FromDlpack1D) { // Use to_dlpack to generate an input tensor - fixed_width_column_wrapper col({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4}); cudf::table_view input({col}); unique_managed_tensor tensor(cudf::to_dlpack(input)); @@ -442,9 +442,9 @@ TYPED_TEST(DLPackNumericTests, FromDlpack2D) using T = TypeParam; auto const col1 = cudf::test::make_type_param_vector({1, 2, 3, 4}); auto const col2 = cudf::test::make_type_param_vector({4, 5, 6, 7}); - std::vector> cols; - cols.push_back(fixed_width_column_wrapper(col1.cbegin(), col1.cend())); - cols.push_back(fixed_width_column_wrapper(col2.cbegin(), col2.cend())); + std::vector> cols; + cols.push_back(cudf::test::fixed_width_column_wrapper(col1.cbegin(), col1.cend())); + cols.push_back(cudf::test::fixed_width_column_wrapper(col2.cbegin(), col2.cend())); std::vector col_views; std::transform(cols.begin(), cols.end(), std::back_inserter(col_views), [](auto const& col) { @@ -479,8 +479,8 @@ TYPED_TEST(DLPackNumericTests, FromDlpackCpu) thrust::host_vector host_vector(data.begin(), data.end()); tensor.dl_tensor.data = host_vector.data(); - fixed_width_column_wrapper col1({1, 2, 3, 4}); - fixed_width_column_wrapper col2({5, 6, 7, 8}); + cudf::test::fixed_width_column_wrapper col1({1, 2, 3, 4}); + cudf::test::fixed_width_column_wrapper col2({5, 6, 7, 8}); cudf::table_view expected({col1, col2}); auto result = cudf::from_dlpack(&tensor); diff --git a/cpp/tests/lists/explode_tests.cpp b/cpp/tests/lists/explode_tests.cpp index fd22932916f..1a20a88df96 100644 --- a/cpp/tests/lists/explode_tests.cpp +++ b/cpp/tests/lists/explode_tests.cpp @@ -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. @@ -22,9 +22,8 @@ #include #include -using namespace cudf::test; -using FCW = fixed_width_column_wrapper; -using LCW = lists_column_wrapper; +using FCW = cudf::test::fixed_width_column_wrapper; +using LCW = cudf::test::lists_column_wrapper; class ExplodeTest : public cudf::test::BaseFixture { }; @@ -78,11 +77,11 @@ TEST_F(ExplodeTest, Basics) FCW a{100, 200, 300}; LCW b{LCW{1, 2, 7}, LCW{5, 6}, LCW{0, 3}}; - strings_column_wrapper c{"string0", "string1", "string2"}; + cudf::test::strings_column_wrapper c{"string0", "string1", "string2"}; FCW expected_a{100, 100, 100, 200, 200, 300, 300}; FCW expected_b{1, 2, 7, 5, 6, 0, 3}; - strings_column_wrapper expected_c{ + cudf::test::strings_column_wrapper expected_c{ "string0", "string0", "string0", "string1", "string1", "string2", "string2"}; cudf::table_view t({a, b, c}); @@ -347,14 +346,14 @@ TEST_F(ExplodeTest, NestedStructs) LCW{LCW{5, 6}}, LCW{LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}}); FCW b1({100, 200, 300}); - strings_column_wrapper b2{"100", "200", "300"}; - structs_column_wrapper b({b1, b2}); + cudf::test::strings_column_wrapper b2{"100", "200", "300"}; + cudf::test::structs_column_wrapper b({b1, b2}); LCW expected_a{ LCW({1, null}, valids), LCW{7, 6, 5}, LCW{5, 6}, LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}; FCW expected_b1{100, 100, 200, 300, 300, 300}; - strings_column_wrapper expected_b2{"100", "100", "200", "300", "300", "300"}; - structs_column_wrapper expected_b({expected_b1, expected_b2}); + cudf::test::strings_column_wrapper expected_b2{"100", "100", "200", "300", "300", "300"}; + cudf::test::structs_column_wrapper expected_b({expected_b1, expected_b2}); cudf::table_view t({a, b}); cudf::table_view expected({expected_a, expected_b}); @@ -435,15 +434,16 @@ TEST_F(ExplodeTest, ListOfStructsWithEmpties) // concatenated auto final_col = cudf::concatenate(std::vector({*row0, *row1, *row2, *row3, *row4})); - auto s = strings_column_wrapper({"a", "b", "c", "d", "e"}).release(); + auto s = cudf::test::strings_column_wrapper({"a", "b", "c", "d", "e"}).release(); cudf::table_view t({final_col->view(), s->view()}); - auto ret = cudf::explode(t, 0); - auto expected_numeric_col = fixed_width_column_wrapper{{1, null, null}, {1, 0, 0}}; + auto ret = cudf::explode(t, 0); + auto expected_numeric_col = + cudf::test::fixed_width_column_wrapper{{1, null, null}, {1, 0, 0}}; - auto expected_a = structs_column_wrapper{{expected_numeric_col}, {1, 1, 0}}.release(); - auto expected_b = strings_column_wrapper({"a", "b", "c"}).release(); + auto expected_a = cudf::test::structs_column_wrapper{{expected_numeric_col}, {1, 1, 0}}.release(); + auto expected_b = cudf::test::strings_column_wrapper({"a", "b", "c"}).release(); cudf::table_view expected({expected_a->view(), expected_b->view()}); @@ -464,10 +464,11 @@ TYPED_TEST(ExplodeTypedTest, ListOfStructs) // [{25, "25"}, {30, "30"}] 400 // [{15, "15"}, {20, "20"}] 500 - auto numeric_col = - fixed_width_column_wrapper{{70, 75, 50, 55, 35, 45, 25, 30, 15, 20}}; - strings_column_wrapper string_col{"70", "75", "50", "55", "35", "45", "25", "30", "15", "20"}; - auto struct_col = structs_column_wrapper{{numeric_col, string_col}}.release(); + auto numeric_col = cudf::test::fixed_width_column_wrapper{ + {70, 75, 50, 55, 35, 45, 25, 30, 15, 20}}; + cudf::test::strings_column_wrapper string_col{ + "70", "75", "50", "55", "35", "45", "25", "30", "15", "20"}; + auto struct_col = cudf::test::structs_column_wrapper{{numeric_col, string_col}}.release(); auto a = cudf::make_lists_column( 5, FCW{0, 2, 4, 6, 8, 10}.release(), std::move(struct_col), cudf::UNKNOWN_NULL_COUNT, {}); @@ -476,12 +477,13 @@ TYPED_TEST(ExplodeTypedTest, ListOfStructs) cudf::table_view t({a->view(), b}); auto ret = cudf::explode(t, 0); - auto expected_numeric_col = - fixed_width_column_wrapper{{70, 75, 50, 55, 35, 45, 25, 30, 15, 20}}; - strings_column_wrapper expected_string_col{ + auto expected_numeric_col = cudf::test::fixed_width_column_wrapper{ + {70, 75, 50, 55, 35, 45, 25, 30, 15, 20}}; + cudf::test::strings_column_wrapper expected_string_col{ "70", "75", "50", "55", "35", "45", "25", "30", "15", "20"}; - auto expected_a = structs_column_wrapper{{expected_numeric_col, expected_string_col}}.release(); + auto expected_a = + cudf::test::structs_column_wrapper{{expected_numeric_col, expected_string_col}}.release(); FCW expected_b{100, 100, 200, 200, 300, 300, 400, 400, 500, 500}; cudf::table_view expected({expected_a->view(), expected_b}); @@ -570,11 +572,11 @@ TEST_F(ExplodeOuterTest, Basics) FCW a{100, 200, 300}; LCW b{LCW{1, 2, 7}, LCW{5, 6}, LCW{0, 3}}; - strings_column_wrapper c{"string0", "string1", "string2"}; + cudf::test::strings_column_wrapper c{"string0", "string1", "string2"}; FCW expected_a{100, 100, 100, 200, 200, 300, 300}; FCW expected_b{1, 2, 7, 5, 6, 0, 3}; - strings_column_wrapper expected_c{ + cudf::test::strings_column_wrapper expected_c{ "string0", "string0", "string0", "string1", "string1", "string2", "string2"}; cudf::table_view t({a, b, c}); @@ -992,14 +994,14 @@ TEST_F(ExplodeOuterTest, NestedStructs) LCW{LCW{5, 6}}, LCW{LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}}); FCW b1({100, 200, 300}); - strings_column_wrapper b2{"100", "200", "300"}; - structs_column_wrapper b({b1, b2}); + cudf::test::strings_column_wrapper b2{"100", "200", "300"}; + cudf::test::structs_column_wrapper b({b1, b2}); LCW expected_a{ LCW({1, null}, valids), LCW{7, 6, 5}, LCW{5, 6}, LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}; FCW expected_b1{100, 100, 200, 300, 300, 300}; - strings_column_wrapper expected_b2{"100", "100", "200", "300", "300", "300"}; - structs_column_wrapper expected_b({expected_b1, expected_b2}); + cudf::test::strings_column_wrapper expected_b2{"100", "100", "200", "300", "300", "300"}; + cudf::test::structs_column_wrapper expected_b({expected_b1, expected_b2}); cudf::table_view t({a, b}); cudf::table_view expected({expected_a, expected_b}); @@ -1080,17 +1082,18 @@ TEST_F(ExplodeOuterTest, ListOfStructsWithEmpties) // concatenated auto final_col = cudf::concatenate(std::vector({*row0, *row1, *row2, *row3, *row4})); - auto s = strings_column_wrapper({"a", "b", "c", "d", "e"}).release(); + auto s = cudf::test::strings_column_wrapper({"a", "b", "c", "d", "e"}).release(); cudf::table_view t({final_col->view(), s->view()}); auto ret = cudf::explode_outer(t, 0); auto expected_numeric_col = - fixed_width_column_wrapper{{1, null, null, null, null}, {1, 0, 0, 0, 0}}; + cudf::test::fixed_width_column_wrapper{{1, null, null, null, null}, {1, 0, 0, 0, 0}}; - auto expected_a = structs_column_wrapper{{expected_numeric_col}, {1, 1, 0, 0, 0}}.release(); - auto expected_b = strings_column_wrapper({"a", "b", "c", "d", "e"}).release(); + auto expected_a = + cudf::test::structs_column_wrapper{{expected_numeric_col}, {1, 1, 0, 0, 0}}.release(); + auto expected_b = cudf::test::strings_column_wrapper({"a", "b", "c", "d", "e"}).release(); cudf::table_view expected({expected_a->view(), expected_b->view()}); @@ -1111,10 +1114,11 @@ TYPED_TEST(ExplodeOuterTypedTest, ListOfStructs) // [{25, "25"}, {30, "30"}] 400 // [{15, "15"}, {20, "20"}] 500 - auto numeric_col = - fixed_width_column_wrapper{{70, 75, 50, 55, 35, 45, 25, 30, 15, 20}}; - strings_column_wrapper string_col{"70", "75", "50", "55", "35", "45", "25", "30", "15", "20"}; - auto struct_col = structs_column_wrapper{{numeric_col, string_col}}.release(); + auto numeric_col = cudf::test::fixed_width_column_wrapper{ + {70, 75, 50, 55, 35, 45, 25, 30, 15, 20}}; + cudf::test::strings_column_wrapper string_col{ + "70", "75", "50", "55", "35", "45", "25", "30", "15", "20"}; + auto struct_col = cudf::test::structs_column_wrapper{{numeric_col, string_col}}.release(); auto a = cudf::make_lists_column( 5, FCW{0, 2, 4, 6, 8, 10}.release(), std::move(struct_col), cudf::UNKNOWN_NULL_COUNT, {}); @@ -1123,12 +1127,13 @@ TYPED_TEST(ExplodeOuterTypedTest, ListOfStructs) cudf::table_view t({a->view(), b}); auto ret = cudf::explode_outer(t, 0); - auto expected_numeric_col = - fixed_width_column_wrapper{{70, 75, 50, 55, 35, 45, 25, 30, 15, 20}}; - strings_column_wrapper expected_string_col{ + auto expected_numeric_col = cudf::test::fixed_width_column_wrapper{ + {70, 75, 50, 55, 35, 45, 25, 30, 15, 20}}; + cudf::test::strings_column_wrapper expected_string_col{ "70", "75", "50", "55", "35", "45", "25", "30", "15", "20"}; - auto expected_a = structs_column_wrapper{{expected_numeric_col, expected_string_col}}.release(); + auto expected_a = + cudf::test::structs_column_wrapper{{expected_numeric_col, expected_string_col}}.release(); FCW expected_b{100, 100, 200, 200, 300, 300, 400, 400, 500, 500}; cudf::table_view expected({expected_a->view(), expected_b}); diff --git a/cpp/tests/reshape/byte_cast_tests.cpp b/cpp/tests/reshape/byte_cast_tests.cpp index f29b3a7980f..6eafc9a2759 100644 --- a/cpp/tests/reshape/byte_cast_tests.cpp +++ b/cpp/tests/reshape/byte_cast_tests.cpp @@ -21,21 +21,20 @@ #include #include -using namespace cudf::test; - class ByteCastTest : public cudf::test::BaseFixture { }; TEST_F(ByteCastTest, int16ValuesWithSplit) { using limits = std::numeric_limits; - fixed_width_column_wrapper const int16_col( + cudf::test::fixed_width_column_wrapper const int16_col( {short(0), short(100), short(-100), limits::min(), limits::max()}); - lists_column_wrapper const int16_expected( + cudf::test::lists_column_wrapper const int16_expected( {{0x00, 0x00}, {0x64, 0x00}, {0x9c, 0xff}, {0x00, 0x80}, {0xff, 0x7f}}); - lists_column_wrapper const int16_expected_slice1( + cudf::test::lists_column_wrapper const int16_expected_slice1( {{0x00, 0x00}, {0x00, 0x64}, {0xff, 0x9c}}); - lists_column_wrapper const int16_expected_slice2({{0x80, 0x00}, {0x7f, 0xff}}); + cudf::test::lists_column_wrapper const int16_expected_slice2( + {{0x80, 0x00}, {0x7f, 0xff}}); std::vector splits({3}); std::vector split_column = cudf::split(int16_col, splits); @@ -54,23 +53,23 @@ TEST_F(ByteCastTest, int16ValuesWithNulls) auto odd_validity = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 2; }); - fixed_width_column_wrapper const int16_col( + cudf::test::fixed_width_column_wrapper const int16_col( {short(0), short(100), short(-100), limits::min(), limits::max()}, {0, 1, 0, 1, 0}); /* CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT compares underlying values even when specified as null, * resulting in erroneous test failures. The commented out data tests the case where underlying * values are different, but are both null. */ // auto int16_data = - // fixed_width_column_wrapper{0xee, 0xff, 0x00, 0x64, 0xee, 0xff, 0x80, 0x00, 0xee, - // 0xff}; - auto int16_data = - fixed_width_column_wrapper{0x00, 0x00, 0x00, 0x64, 0xff, 0x9c, 0x80, 0x00, 0x7f, 0xff}; + // cudf::test::fixed_width_column_wrapper{0xee, 0xff, 0x00, 0x64, 0xee, 0xff, 0x80, + // 0x00, 0xee, 0xff}; + auto int16_data = cudf::test::fixed_width_column_wrapper{ + 0x00, 0x00, 0x00, 0x64, 0xff, 0x9c, 0x80, 0x00, 0x7f, 0xff}; auto int16_expected = cudf::make_lists_column( 5, - std::move(fixed_width_column_wrapper{0, 2, 4, 6, 8, 10}.release()), + std::move(cudf::test::fixed_width_column_wrapper{0, 2, 4, 6, 8, 10}.release()), std::move(int16_data.release()), 3, - detail::make_null_mask(odd_validity, odd_validity + 5)); + cudf::test::detail::make_null_mask(odd_validity, odd_validity + 5)); auto const output_int16 = cudf::byte_cast(int16_col, cudf::flip_endianness::YES); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(output_int16->view(), int16_expected->view()); @@ -79,17 +78,19 @@ TEST_F(ByteCastTest, int16ValuesWithNulls) TEST_F(ByteCastTest, int32Values) { using limits = std::numeric_limits; - fixed_width_column_wrapper const int32_col({0, 100, -100, limits::min(), limits::max()}); - lists_column_wrapper const int32_expected_flipped({{0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x64}, - {0xff, 0xff, 0xff, 0x9c}, - {0x80, 0x00, 0x00, 0x00}, - {0x7f, 0xff, 0xff, 0xff}}); - lists_column_wrapper const int32_expected({{0x00, 0x00, 0x00, 0x00}, - {0x64, 0x00, 0x00, 0x00}, - {0x9c, 0xff, 0xff, 0xff}, - {0x00, 0x00, 0x00, 0x80}, - {0xff, 0xff, 0xff, 0x7f}}); + cudf::test::fixed_width_column_wrapper const int32_col( + {0, 100, -100, limits::min(), limits::max()}); + cudf::test::lists_column_wrapper const int32_expected_flipped( + {{0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x64}, + {0xff, 0xff, 0xff, 0x9c}, + {0x80, 0x00, 0x00, 0x00}, + {0x7f, 0xff, 0xff, 0xff}}); + cudf::test::lists_column_wrapper const int32_expected({{0x00, 0x00, 0x00, 0x00}, + {0x64, 0x00, 0x00, 0x00}, + {0x9c, 0xff, 0xff, 0xff}, + {0x00, 0x00, 0x00, 0x80}, + {0xff, 0xff, 0xff, 0x7f}}); auto const output_int32_flipped = cudf::byte_cast(int32_col, cudf::flip_endianness::YES); auto const output_int32 = cudf::byte_cast(int32_col, cudf::flip_endianness::NO); @@ -103,23 +104,24 @@ TEST_F(ByteCastTest, int32ValuesWithNulls) auto even_validity = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return (i + 1) % 2; }); - fixed_width_column_wrapper const int32_col({0, 100, -100, limits::min(), limits::max()}, - {1, 0, 1, 0, 1}); + cudf::test::fixed_width_column_wrapper const int32_col( + {0, 100, -100, limits::min(), limits::max()}, {1, 0, 1, 0, 1}); /* Data commented out below explained by comment in int16ValuesWithNulls test */ // auto int32_data = - // fixed_width_column_wrapper{0x00, 0x00, 0x00, 0x00, 0xcc, 0xdd, 0xee, 0xff, 0xff, - // 0xff, + // cudf::test::fixed_width_column_wrapper{0x00, 0x00, 0x00, 0x00, 0xcc, 0xdd, 0xee, + // 0xff, 0xff, 0xff, // 0xff, 0x9c, 0xcc, 0xdd, 0xee, 0xff, 0x7f, 0xff, 0xff, // 0xff}; - auto int32_data = - fixed_width_column_wrapper{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0xff, 0xff, - 0xff, 0x9c, 0x80, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff}; + auto int32_data = cudf::test::fixed_width_column_wrapper{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0xff, 0xff, + 0xff, 0x9c, 0x80, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff}; auto int32_expected = cudf::make_lists_column( 5, - std::move(fixed_width_column_wrapper{0, 4, 8, 12, 16, 20}.release()), + std::move( + cudf::test::fixed_width_column_wrapper{0, 4, 8, 12, 16, 20}.release()), std::move(int32_data.release()), 2, - detail::make_null_mask(even_validity, even_validity + 5)); + cudf::test::detail::make_null_mask(even_validity, even_validity + 5)); auto const output_int32 = cudf::byte_cast(int32_col, cudf::flip_endianness::YES); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(output_int32->view(), int32_expected->view()); @@ -128,19 +130,19 @@ TEST_F(ByteCastTest, int32ValuesWithNulls) TEST_F(ByteCastTest, int64ValuesWithSplit) { using limits = std::numeric_limits; - fixed_width_column_wrapper const int64_col( + cudf::test::fixed_width_column_wrapper const int64_col( {long(0), long(100), long(-100), limits::min(), limits::max()}); - lists_column_wrapper const int64_expected_flipped( + cudf::test::lists_column_wrapper const int64_expected_flipped( {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64}, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9c}, {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}); - lists_column_wrapper const int64_expected_slice1( + cudf::test::lists_column_wrapper const int64_expected_slice1( {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x9c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}); - lists_column_wrapper const int64_expected_slice2( + cudf::test::lists_column_wrapper const int64_expected_slice2( {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80}, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}}); @@ -161,23 +163,24 @@ TEST_F(ByteCastTest, int64ValuesWithNulls) auto odd_validity = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 2; }); - fixed_width_column_wrapper const int64_col( + cudf::test::fixed_width_column_wrapper const int64_col( {long(0), long(100), long(-100), limits::min(), limits::max()}, {0, 1, 0, 1, 0}); /* Data commented out below explained by comment in int16ValuesWithNulls test */ - // auto int64_data = fixed_width_column_wrapper{ + // auto int64_data = cudf::test::fixed_width_column_wrapper{ // 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00, 0x64, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x80, 0x00, 0x00, 0x00, // 0x00, 0x00, 0x00, 0x00, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; - auto int64_data = fixed_width_column_wrapper{ + auto int64_data = cudf::test::fixed_width_column_wrapper{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; auto int64_expected = cudf::make_lists_column( 5, - std::move(fixed_width_column_wrapper{0, 8, 16, 24, 32, 40}.release()), + std::move( + cudf::test::fixed_width_column_wrapper{0, 8, 16, 24, 32, 40}.release()), std::move(int64_data.release()), 3, - detail::make_null_mask(odd_validity, odd_validity + 5)); + cudf::test::detail::make_null_mask(odd_validity, odd_validity + 5)); auto const output_int64 = cudf::byte_cast(int64_col, cudf::flip_endianness::YES); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(output_int64->view(), int64_expected->view()); @@ -188,26 +191,26 @@ TEST_F(ByteCastTest, fp32ValuesWithSplit) using limits = std::numeric_limits; float nan = limits::quiet_NaN(); float inf = limits::infinity(); - fixed_width_column_wrapper const fp32_col( + cudf::test::fixed_width_column_wrapper const fp32_col( {float(0.0), float(100.0), float(-100.0), limits::min(), limits::max(), nan, -nan, inf, -inf}); - lists_column_wrapper const fp32_expected({{0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0xc8, 0x42}, - {0x00, 0x00, 0xc8, 0xc2}, - {0x00, 0x00, 0x80, 0x00}, - {0xff, 0xff, 0x7f, 0x7f}, - {0x00, 0x00, 0xc0, 0x7f}, - {0x00, 0x00, 0xc0, 0xff}, - {0x00, 0x00, 0x80, 0x7f}, - {0x00, 0x00, 0x80, 0xff}}); - lists_column_wrapper const fp32_expected_slice1({{0x00, 0x00, 0x00, 0x00}, - {0x42, 0xc8, 0x00, 0x00}, - {0xc2, 0xc8, 0x00, 0x00}, - {0x00, 0x80, 0x00, 0x00}, - {0x7f, 0x7f, 0xff, 0xff}}); - lists_column_wrapper const fp32_expected_slice2({{0x7f, 0xc0, 0x00, 0x00}, - {0xff, 0xc0, 0x00, 0x00}, - {0x7f, 0x80, 0x00, 0x00}, - {0xff, 0x80, 0x00, 0x00}}); + cudf::test::lists_column_wrapper const fp32_expected({{0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0xc8, 0x42}, + {0x00, 0x00, 0xc8, 0xc2}, + {0x00, 0x00, 0x80, 0x00}, + {0xff, 0xff, 0x7f, 0x7f}, + {0x00, 0x00, 0xc0, 0x7f}, + {0x00, 0x00, 0xc0, 0xff}, + {0x00, 0x00, 0x80, 0x7f}, + {0x00, 0x00, 0x80, 0xff}}); + cudf::test::lists_column_wrapper const fp32_expected_slice1({{0x00, 0x00, 0x00, 0x00}, + {0x42, 0xc8, 0x00, 0x00}, + {0xc2, 0xc8, 0x00, 0x00}, + {0x00, 0x80, 0x00, 0x00}, + {0x7f, 0x7f, 0xff, 0xff}}); + cudf::test::lists_column_wrapper const fp32_expected_slice2({{0x7f, 0xc0, 0x00, 0x00}, + {0xff, 0xc0, 0x00, 0x00}, + {0x7f, 0x80, 0x00, 0x00}, + {0xff, 0x80, 0x00, 0x00}}); std::vector splits({5}); std::vector split_column = cudf::split(fp32_col, splits); @@ -226,23 +229,24 @@ TEST_F(ByteCastTest, fp32ValuesWithNulls) auto even_validity = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return (i + 1) % 2; }); - fixed_width_column_wrapper const fp32_col( + cudf::test::fixed_width_column_wrapper const fp32_col( {float(0.0), float(100.0), float(-100.0), limits::min(), limits::max()}, {1, 0, 1, 0, 1}); /* Data commented out below explained by comment in int16ValuesWithNulls test */ // auto fp32_data = - // fixed_width_column_wrapper{0x00, 0x00, 0x00, 0x00, 0xcc, 0xdd, 0xee, 0xff, 0xc2, - // 0xc8, + // cudf::test::fixed_width_column_wrapper{0x00, 0x00, 0x00, 0x00, 0xcc, 0xdd, 0xee, + // 0xff, 0xc2, 0xc8, // 0x00, 0x00, 0xcc, 0xdd, 0xee, 0xff, 0x7f, 0x7f, 0xff, // 0xff}; - auto fp32_data = - fixed_width_column_wrapper{0x00, 0x00, 0x00, 0x00, 0x42, 0xc8, 0x00, 0x00, 0xc2, 0xc8, - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x7f, 0x7f, 0xff, 0xff}; + auto fp32_data = cudf::test::fixed_width_column_wrapper{ + 0x00, 0x00, 0x00, 0x00, 0x42, 0xc8, 0x00, 0x00, 0xc2, 0xc8, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x7f, 0x7f, 0xff, 0xff}; auto fp32_expected = cudf::make_lists_column( 5, - std::move(fixed_width_column_wrapper{0, 4, 8, 12, 16, 20}.release()), + std::move( + cudf::test::fixed_width_column_wrapper{0, 4, 8, 12, 16, 20}.release()), std::move(fp32_data.release()), 2, - detail::make_null_mask(even_validity, even_validity + 5)); + cudf::test::detail::make_null_mask(even_validity, even_validity + 5)); auto const output_fp32 = cudf::byte_cast(fp32_col, cudf::flip_endianness::YES); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(output_fp32->view(), fp32_expected->view()); @@ -253,16 +257,16 @@ TEST_F(ByteCastTest, fp64ValuesWithSplit) using limits = std::numeric_limits; double nan = limits::quiet_NaN(); double inf = limits::infinity(); - fixed_width_column_wrapper const fp64_col({double(0.0), - double(100.0), - double(-100.0), - limits::min(), - limits::max(), - nan, - -nan, - inf, - -inf}); - lists_column_wrapper const fp64_flipped_expected( + cudf::test::fixed_width_column_wrapper const fp64_col({double(0.0), + double(100.0), + double(-100.0), + limits::min(), + limits::max(), + nan, + -nan, + inf, + -inf}); + cudf::test::lists_column_wrapper const fp64_flipped_expected( {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x40, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0xc0, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, @@ -272,13 +276,13 @@ TEST_F(ByteCastTest, fp64ValuesWithSplit) {0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}); - lists_column_wrapper const fp64_expected_slice1( + cudf::test::lists_column_wrapper const fp64_expected_slice1( {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x40}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0xc0}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00}, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0x7f}}); - lists_column_wrapper const fp64_expected_slice2( + cudf::test::lists_column_wrapper const fp64_expected_slice2( {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f}, @@ -301,23 +305,24 @@ TEST_F(ByteCastTest, fp64ValuesWithNulls) auto odd_validity = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 2; }); - fixed_width_column_wrapper const fp64_col( + cudf::test::fixed_width_column_wrapper const fp64_col( {double(0.0), double(100.0), double(-100.0), limits::min(), limits::max()}, {0, 1, 0, 1, 0}); /* Data commented out below explained by comment in int16ValuesWithNulls test */ - // auto fp64_data = fixed_width_column_wrapper{ + // auto fp64_data = cudf::test::fixed_width_column_wrapper{ // 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x40, 0x59, 0x00, 0x00, 0x00, 0x00, // 0x00, 0x00, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x10, 0x00, 0x00, // 0x00, 0x00, 0x00, 0x00, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; - auto fp64_data = fixed_width_column_wrapper{ + auto fp64_data = cudf::test::fixed_width_column_wrapper{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; auto fp64_expected = cudf::make_lists_column( 5, - std::move(fixed_width_column_wrapper{0, 8, 16, 24, 32, 40}.release()), + std::move( + cudf::test::fixed_width_column_wrapper{0, 8, 16, 24, 32, 40}.release()), std::move(fp64_data.release()), 3, - detail::make_null_mask(odd_validity, odd_validity + 5)); + cudf::test::detail::make_null_mask(odd_validity, odd_validity + 5)); auto const output_fp64 = cudf::byte_cast(fp64_col, cudf::flip_endianness::YES); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(output_fp64->view(), fp64_expected->view()); @@ -325,9 +330,9 @@ TEST_F(ByteCastTest, fp64ValuesWithNulls) TEST_F(ByteCastTest, StringValues) { - strings_column_wrapper const strings_col( + cudf::test::strings_column_wrapper const strings_col( {"", "The quick", " brown fox...", "!\"#$%&\'()*+,-./", "0123456789:;<=>?@", "[\\]^_`{|}~"}); - lists_column_wrapper const strings_expected( + cudf::test::lists_column_wrapper const strings_expected( {{}, {0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b}, {0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20, 0x66, 0x6f, 0x78, 0x2e, 0x2e, 0x2e}, diff --git a/cpp/tests/reshape/tile_tests.cpp b/cpp/tests/reshape/tile_tests.cpp index e605fd7a84b..86dcc431633 100644 --- a/cpp/tests/reshape/tile_tests.cpp +++ b/cpp/tests/reshape/tile_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 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. @@ -24,10 +24,8 @@ #include #include -using namespace cudf::test; - template -struct TileTest : public BaseFixture { +struct TileTest : public cudf::test::BaseFixture { }; TYPED_TEST_SUITE(TileTest, cudf::test::AllTypes); @@ -47,7 +45,7 @@ TYPED_TEST(TileTest, NoRows) { using T = TypeParam; - fixed_width_column_wrapper in_a({}); + cudf::test::fixed_width_column_wrapper in_a({}); cudf::table_view in(std::vector{in_a}); auto expected = in; @@ -61,10 +59,10 @@ TYPED_TEST(TileTest, OneColumn) { using T = TypeParam; - fixed_width_column_wrapper in_a({-1, 0, 1}); + cudf::test::fixed_width_column_wrapper in_a({-1, 0, 1}); cudf::table_view in(std::vector{in_a}); - fixed_width_column_wrapper expected_a({-1, 0, 1, -1, 0, 1}); + cudf::test::fixed_width_column_wrapper expected_a({-1, 0, 1, -1, 0, 1}); cudf::table_view expected(std::vector{expected_a}); auto actual = cudf::tile(in, 2); @@ -76,10 +74,11 @@ TYPED_TEST(TileTest, OneColumnNullable) { using T = TypeParam; - fixed_width_column_wrapper in_a({-1, 0, 1}, {1, 0, 0}); + cudf::test::fixed_width_column_wrapper in_a({-1, 0, 1}, {1, 0, 0}); cudf::table_view in(std::vector{in_a}); - fixed_width_column_wrapper expected_a({-1, 0, 1, -1, 0, 1}, {1, 0, 0, 1, 0, 0}); + cudf::test::fixed_width_column_wrapper expected_a({-1, 0, 1, -1, 0, 1}, + {1, 0, 0, 1, 0, 0}); cudf::table_view expected(std::vector{expected_a}); auto actual = cudf::tile(in, 2); @@ -91,7 +90,7 @@ TYPED_TEST(TileTest, OneColumnNegativeCount) { using T = TypeParam; - fixed_width_column_wrapper in_a({-1, 0, 1}, {1, 0, 0}); + cudf::test::fixed_width_column_wrapper in_a({-1, 0, 1}, {1, 0, 0}); cudf::table_view in(std::vector{in_a}); EXPECT_THROW(cudf::tile(in, -1), cudf::logic_error); @@ -101,13 +100,13 @@ TYPED_TEST(TileTest, OneColumnZeroCount) { using T = TypeParam; - fixed_width_column_wrapper in_a({-1, 0, 1}, {1, 0, 0}); + cudf::test::fixed_width_column_wrapper in_a({-1, 0, 1}, {1, 0, 0}); cudf::table_view in(std::vector{in_a}); std::vector vals{}; std::vector mask{}; - fixed_width_column_wrapper expected_a(vals.begin(), vals.end(), mask.begin()); + cudf::test::fixed_width_column_wrapper expected_a(vals.begin(), vals.end(), mask.begin()); cudf::table_view expected(std::vector{expected_a});