1#ifndef KOKKOS_UTILS_CALLBACKS_HELPERS_HPP
2#define KOKKOS_UTILS_CALLBACKS_HELPERS_HPP
4#include "gmock/gmock.h"
11#define TEST_F_WITH_CB_MGR(__test_fixture_name__, __test_name__) \
12 class __test_fixture_name__ : public ::testing::Test, \
13 public scoped::callbacks::Manager {}; \
14 TEST_F(__test_fixture_name__, __test_name__)
16#define DEFINE_EVENT_MATCHER(__eventtype__) \
17 template <typename... Matchers> \
18 auto A##__eventtype__(Matchers&&... matchers) \
20 using EventType = Kokkos::utils::callbacks::__eventtype__; \
21 if constexpr (sizeof...(Matchers) == 0) \
22 return ::testing::VariantWith<EventType>(::testing::_); \
24 return ::testing::VariantWith<EventType>(::testing::AllOf(std::forward<Matchers>(matchers)...)); \
47#define DEFINE_EVENT_WITH_NAME_MATCHER(__eventtype__) \
48 template <typename Matcher> \
49 auto A##__eventtype__##WithName(Matcher&& matcher) \
51 using EventType = Kokkos::utils::callbacks::__eventtype__; \
52 return ::testing::VariantWith<EventType>(::testing::Field(&EventType::name, std::forward<Matcher>(matcher))); \
66template <
typename T,
typename... Matchers>
70 template <
typename... Matchers_>
requires std::conjunction_v<std::is_same<std::remove_cvref_t<Matchers_>, Matchers>...>
72 :
matchers{std::forward<Matchers_>(matchers_)...} {}
74 template <
typename IterableType>
75 bool MatchAndExplain([[maybe_unused]]
const IterableType& arg, [[maybe_unused]]::testing::MatchResultListener*
const listener)
const
77 if constexpr(
sizeof...(Matchers) == 0) {
86 *out <<
"contains in order elements that match ";
92 *out <<
"does not contain in order elements that match ";
97 template <
size_t Idx,
typename IteratorType>
98 bool MatchAndExplainImpl(
const IteratorType it_first,
const IteratorType it_last, ::testing::MatchResultListener*
const listener)
const
100 if (it_first == it_last) {;
101 *listener <<
"does not contain in order an element that "
102 << ::testing::DescribeMatcher<T>(std::get<Idx>(
matchers),
false);
106 if (::testing::Matches(std::get<Idx>(
matchers))(*it_first)) {
107 if constexpr (Idx ==
sizeof...(Matchers) - 1) {
120 if constexpr (
sizeof...(Matchers) >= 2)
122 [&] <
size_t... Idxs>(std::index_sequence<Idxs...>) {
123 ((*out << ::testing::DescribeMatcher<T>(std::get<Idxs>(
matchers),
false) <<
", "), ...);
124 }(std::make_index_sequence<
sizeof...(Matchers) - 1>{});
126 if constexpr (
sizeof...(Matchers) >= 1)
127 *out << ::testing::DescribeMatcher<T>(std::get<
sizeof...(Matchers) - 1>(
matchers),
false);
137template <
typename T,
typename... Matchers>
139 return ::testing::MakePolymorphicMatcher(
impl::ContainsInOrderMatcher<T, std::remove_cvref_t<Matchers>...>(std::forward<Matchers>(matchers)...));
154 return ::testing::AllOf(
157 ::testing::Field(&Kokkos_Profiling_SpaceHandle::name, ::testing::StrEq(descr.kpsh.name))
161 ::testing::StrEq(std::move(descr.name))
165 ::testing::Eq(descr.size)
180 return ::testing::AllOf(
bool MatchAndExplainImpl(const IteratorType it_first, const IteratorType it_last, ::testing::MatchResultListener *const listener) const
bool MatchAndExplain(const IterableType &arg, ::testing::MatchResultListener *const listener) const
void DescribeTo(std::ostream *out) const
void DescribeNegationTo(std::ostream *out) const
void DescribeInnerMatchersImpl(std::ostream *out) const
std::tuple< Matchers... > matchers
ContainsInOrderMatcher(Matchers_ &&... matchers_)
#define DEFINE_EVENT_MATCHER(__eventtype__)
#define DEFINE_EVENT_WITH_NAME_MATCHER(__eventtype__)
auto ContainsInOrder(Matchers &&... matchers)
Helper struct to hold descriptors of a data allocation.
Kokkos_Profiling_SpaceHandle kpsh
Allocate-data event associated with Kokkos::Tools::Experimental::EventSet::allocate_data.
Begin-deep-copy event associated with Kokkos::Tools::Experimental::EventSet::begin_deep_copy.
Begin-fence event associated with Kokkos::Tools::Experimental::EventSet::begin_fence.
Begin-parallel-reduce event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_red...
Begin-parallel-scan event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_scan.
Create-profile-section event associated with Kokkos::Tools::Experimental::EventSet::create_profile_se...
Deallocate-data event associated with Kokkos::Tools::Experimental::EventSet::deallocate_data.
Destroy-profile-section event associated with Kokkos::Tools::Experimental::EventSet::destroy_profile_...
End-deep-copy event associated with Kokkos::Tools::Experimental::EventSet::end_deep_copy.
End-fence event associated with Kokkos::Tools::Experimental::EventSet::end_fence.
End-parallel-for event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_for.
End-parallel-reduce event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_reduce.
End-parallel-scan event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_scan.
Pop-region event associated with Kokkos::Tools::Experimental::EventSet::pop_region.
Profile event associated with Kokkos::Tools::Experimental::EventSet::profile_event.
Push-region event associated with Kokkos::Tools::Experimental::EventSet::push_region.
Start-profile-section event associated with Kokkos::Tools::Experimental::EventSet::start_profile_sect...
Stop-profile-section event associated with Kokkos::Tools::Experimental::EventSet::stop_profile_sectio...