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 all 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
7 changes: 6 additions & 1 deletion cpp/include/cudf_test/cudf_gtest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -89,6 +93,7 @@ struct TypeList<Types<TYPES...>> {

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

#include <gmock/gmock.h>
Expand Down
12 changes: 5 additions & 7 deletions cpp/include/cudf_test/type_list_utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,12 @@ 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 raw_type = decltype(std::get<D>(std::declval<std::tuple<T...>>()));
using type = std::decay_t<raw_type>;
};

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... ARGS>
struct GetTypeImpl<Types<T, ARGS...>, 0> {
using type = T;
};
// @endcond

Expand Down
17 changes: 10 additions & 7 deletions cpp/tests/iterator/optional_iterator_test_numeric.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -34,13 +44,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
17 changes: 10 additions & 7 deletions cpp/tests/iterator/pair_iterator_test_numeric.cu
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@

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> {};

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