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

Allow compilation with any GTest version 1.11+ #13153

Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 7 additions & 2 deletions cpp/include/cudf_test/cudf_gtest.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
* Copyright (c) 2019-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.
Expand All @@ -22,7 +22,7 @@

/**
* @file cudf_gtest.hpp
* @brief Work around for GTests emulation of variadic templates in
* @brief Work around for GTests( <=v1.10 ) emulation of variadic templates in
* @verbatim ::Testing::Types @endverbatim
*
* @note Instead of including `gtest/gtest.h`, all libcudf test files should
Expand All @@ -35,6 +35,10 @@
*/

// @cond
#if __has_include(<gtest/internal/gtest-type-util.h.pump>)
// gtest doesn't provide a version header so we need to
// use a file existence trick.
// gtest-type-util.h.pump only exists in versions < 1.11
#define Types Types_NOT_USED
#define Types0 Types0_NOT_USED
#define TypeList TypeList_NOT_USED
Expand Down Expand Up @@ -90,6 +94,7 @@ struct TypeList<Types<TYPES...>> {

} // namespace internal
} // namespace testing
#endif // gtest < 1.11
// @endcond

#include <gmock/gmock.h>
Expand Down
21 changes: 13 additions & 8 deletions cpp/include/cudf_test/type_list_utilities.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
* Copyright (c) 2019-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.
Expand Down Expand Up @@ -90,14 +90,19 @@ template <class... T, int D>
struct GetTypeImpl<Types<T...>, D> {
static_assert(D < sizeof...(T), "Out of bounds");

using type = typename GetTypeImpl<typename Types<T...>::Tail, D - 1>::type;
using type = decltype(std::get<D>(std::declval<std::tuple<T...>>()));
};

template <class... ARGS>
struct GetTypeImpl<Types<ARGS...>, 0> {
static_assert(sizeof...(ARGS) > 0, "Out of bounds");

using type = typename Types<ARGS...>::Head;
template <class T, class U, class V, class... ARGS>
struct GetTypeImpl<Types<T, U, V, ARGS...>, 2> {
using type = V;
};
template <class T, class U, class... ARGS>
struct GetTypeImpl<Types<T, U, ARGS...>, 1> {
using type = U;
};
template <class T, class... ARGS>
struct GetTypeImpl<Types<T, ARGS...>, 0> {
using type = T;
};
// @endcond

Expand Down
19 changes: 11 additions & 8 deletions cpp/tests/iterator/optional_iterator_test_numeric.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022, 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.
Expand All @@ -24,6 +24,16 @@

using TestingTypes = cudf::test::NumericTypes;

namespace cudf {
// To print meanvar for debug.
// Needs to be in the cudf namespace for ADL
template <typename T>
std::ostream& operator<<(std::ostream& os, cudf::meanvar<T> const& rhs)
{
return os << "[" << rhs.value << ", " << rhs.value_squared << ", " << rhs.count << "] ";
};
} // namespace cudf

template <typename T>
struct NumericOptionalIteratorTest : public IteratorTest<T> {
};
Expand All @@ -35,13 +45,6 @@ TYPED_TEST(NumericOptionalIteratorTest, nonull_optional_iterator)
}
TYPED_TEST(NumericOptionalIteratorTest, null_optional_iterator) { null_optional_iterator(*this); }

// to print meanvar for debug.
template <typename T>
std::ostream& operator<<(std::ostream& os, cudf::meanvar<T> const& rhs)
{
return os << "[" << rhs.value << ", " << rhs.value_squared << ", " << rhs.count << "] ";
};

// Transformers and Operators for optional_iterator test
template <typename ElementType>
struct transformer_optional_meanvar {
Expand Down
19 changes: 11 additions & 8 deletions cpp/tests/iterator/pair_iterator_test_numeric.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022, 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.
Expand All @@ -22,6 +22,16 @@

using TestingTypes = cudf::test::NumericTypes;

namespace cudf {
// To print meanvar for debug.
// Needs to be in the cudf namespace for ADL
template <typename T>
std::ostream& operator<<(std::ostream& os, cudf::meanvar<T> const& rhs)
{
return os << "[" << rhs.value << ", " << rhs.value_squared << ", " << rhs.count << "] ";
};
} // namespace cudf

template <typename T>
struct NumericPairIteratorTest : public IteratorTest<T> {
};
Expand All @@ -30,13 +40,6 @@ TYPED_TEST_SUITE(NumericPairIteratorTest, TestingTypes);
TYPED_TEST(NumericPairIteratorTest, nonull_pair_iterator) { nonull_pair_iterator(*this); }
TYPED_TEST(NumericPairIteratorTest, null_pair_iterator) { null_pair_iterator(*this); }

// to print meanvar for debug.
template <typename T>
std::ostream& operator<<(std::ostream& os, cudf::meanvar<T> const& rhs)
{
return os << "[" << rhs.value << ", " << rhs.value_squared << ", " << rhs.count << "] ";
};

// Transformers and Operators for pair_iterator test
template <typename ElementType>
struct transformer_pair_meanvar {
Expand Down