From d9ad58cd76e35b062094305b1d6ace2e6ea3e42c Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Wed, 22 Mar 2023 17:50:45 -0400 Subject: [PATCH] Rework gtests SequenceTest to remove using namepace cudf (#12985) Remove the `using namespace cudf;` from the top of the source file to make it easier to follow. Seemed an unnecessary usage and violated the spirit of #12784 Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Bradley Dice (https://github.com/bdice) - Nghia Truong (https://github.com/ttnghia) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/cudf/pull/12985 --- cpp/tests/filling/sequence_tests.cpp | 86 +++++++++++++--------------- 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/cpp/tests/filling/sequence_tests.cpp b/cpp/tests/filling/sequence_tests.cpp index 383a69affa1..1f55cdf3df0 100644 --- a/cpp/tests/filling/sequence_tests.cpp +++ b/cpp/tests/filling/sequence_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include #include #include @@ -23,11 +21,7 @@ #include #include -#include -#include - -using namespace cudf; -using namespace cudf::test; +#include template class SequenceTypedTestFixture : public cudf::test::BaseFixture { @@ -44,13 +38,13 @@ TYPED_TEST(SequenceTypedTestFixture, Incrementing) { using T = TypeParam; - numeric_scalar init(0); - numeric_scalar step(1); + cudf::numeric_scalar init(0); + cudf::numeric_scalar step(1); - size_type num_els = 10; + cudf::size_type num_els = 10; T expected[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - fixed_width_column_wrapper expected_w(expected, expected + num_els); + cudf::test::fixed_width_column_wrapper expected_w(expected, expected + num_els); auto result = cudf::sequence(num_els, init, step); @@ -61,13 +55,13 @@ TYPED_TEST(SequenceTypedTestFixture, Decrementing) { using T = TypeParam; - numeric_scalar init(0); - numeric_scalar step(-5); + cudf::numeric_scalar init(0); + cudf::numeric_scalar step(-5); - size_type num_els = 10; + cudf::size_type num_els = 10; T expected[] = {0, -5, -10, -15, -20, -25, -30, -35, -40, -45}; - fixed_width_column_wrapper expected_w(expected, expected + num_els); + cudf::test::fixed_width_column_wrapper expected_w(expected, expected + num_els); auto result = cudf::sequence(num_els, init, step); @@ -78,13 +72,13 @@ TYPED_TEST(SequenceTypedTestFixture, EmptyOutput) { using T = TypeParam; - numeric_scalar init(0); - numeric_scalar step(-5); + cudf::numeric_scalar init(0); + cudf::numeric_scalar step(-5); - size_type num_els = 0; + cudf::size_type num_els = 0; T expected[] = {}; - fixed_width_column_wrapper expected_w(expected, expected + num_els); + cudf::test::fixed_width_column_wrapper expected_w(expected, expected + num_els); auto result = cudf::sequence(num_els, init, step); @@ -93,31 +87,31 @@ TYPED_TEST(SequenceTypedTestFixture, EmptyOutput) TEST_F(SequenceTestFixture, BadTypes) { - string_scalar string_init("zero"); - string_scalar string_step("???"); + cudf::string_scalar string_init("zero"); + cudf::string_scalar string_step("???"); EXPECT_THROW(cudf::sequence(10, string_init, string_step), cudf::logic_error); - numeric_scalar bool_init(true); - numeric_scalar bool_step(false); + cudf::numeric_scalar bool_init(true); + cudf::numeric_scalar bool_step(false); EXPECT_THROW(cudf::sequence(10, bool_init, bool_step), cudf::logic_error); - timestamp_scalar ts_init(duration_s{10}, true); - timestamp_scalar ts_step(duration_s{10}, true); + cudf::timestamp_scalar ts_init(cudf::duration_s{10}, true); + cudf::timestamp_scalar ts_step(cudf::duration_s{10}, true); EXPECT_THROW(cudf::sequence(10, ts_init, ts_step), cudf::logic_error); } TEST_F(SequenceTestFixture, MismatchedInputs) { - numeric_scalar init(0); - numeric_scalar step(-5); + cudf::numeric_scalar init(0); + cudf::numeric_scalar step(-5); EXPECT_THROW(cudf::sequence(10, init, step), cudf::logic_error); - numeric_scalar init2(0); - numeric_scalar step2(-5); + cudf::numeric_scalar init2(0); + cudf::numeric_scalar step2(-5); EXPECT_THROW(cudf::sequence(10, init2, step2), cudf::logic_error); - numeric_scalar init3(0); - numeric_scalar step3(-5); + cudf::numeric_scalar init3(0); + cudf::numeric_scalar step3(-5); EXPECT_THROW(cudf::sequence(10, init3, step3), cudf::logic_error); } @@ -125,12 +119,12 @@ TYPED_TEST(SequenceTypedTestFixture, DefaultStep) { using T = TypeParam; - numeric_scalar init(0); + cudf::numeric_scalar init(0); - size_type num_els = 10; + cudf::size_type num_els = 10; T expected[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - fixed_width_column_wrapper expected_w(expected, expected + num_els); + cudf::test::fixed_width_column_wrapper expected_w(expected, expected + num_els); auto result = cudf::sequence(num_els, init); @@ -140,11 +134,11 @@ TYPED_TEST(SequenceTypedTestFixture, DefaultStep) TEST_F(SequenceTestFixture, DateSequenceBasic) { // Timestamp generated using https://www.epochconverter.com/ - timestamp_scalar init(1629852896L, true); // 2021-08-25 00:54:56 GMT - size_type size{5}; - size_type months{1}; + cudf::timestamp_scalar init(1629852896L, true); // 2021-08-25 00:54:56 GMT + cudf::size_type size{5}; + cudf::size_type months{1}; - fixed_width_column_wrapper expected{ + cudf::test::fixed_width_column_wrapper expected{ 1629852896L, // 2021-08-25 00:54:56 GMT 1632531296L, // 2021-09-25 00:54:56 GMT 1635123296L, // 2021-10-25 00:54:56 GMT @@ -160,11 +154,11 @@ TEST_F(SequenceTestFixture, DateSequenceBasic) TEST_F(SequenceTestFixture, DateSequenceLeapYear) { // Timestamp generated using https://www.epochconverter.com/ - timestamp_scalar init(951876379L, true); // 2000-02-29 02:06:19 GMT - size_type size{5}; - size_type months{12}; + cudf::timestamp_scalar init(951876379L, true); // 2000-02-29 02:06:19 GMT + cudf::size_type size{5}; + cudf::size_type months{12}; - fixed_width_column_wrapper expected{ + cudf::test::fixed_width_column_wrapper expected{ 951876379L, // 2000-02-29 02:06:19 GMT Leap Year 983412379L, // 2001-02-28 02:06:19 GMT 1014948379L, // 2002-02-28 02:06:19 GMT @@ -179,9 +173,9 @@ TEST_F(SequenceTestFixture, DateSequenceLeapYear) TEST_F(SequenceTestFixture, DateSequenceBadTypes) { - numeric_scalar init(951876379, true); - size_type size = 5; - size_type months = 12; + cudf::numeric_scalar init(951876379, true); + cudf::size_type size = 5; + cudf::size_type months = 12; EXPECT_THROW(calendrical_month_sequence(size, init, months), cudf::logic_error); }