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)...)); \
45#define DEFINE_EVENT_WITH_NAME_MATCHER(__eventtype__) \
46 template <typename Matcher> \
47 auto A##__eventtype__##WithName(Matcher&& matcher) \
49 using EventType = Kokkos::utils::callbacks::__eventtype__; \
50 return ::testing::VariantWith<EventType>(::testing::Field(&EventType::name, std::forward<Matcher>(matcher))); \
64template <
typename T,
typename... Matchers>
68 template <
typename... Matchers_>
requires std::conjunction_v<std::is_same<std::remove_cvref_t<Matchers_>, Matchers>...>
70 :
matchers{std::forward<Matchers_>(matchers_)...} {}
72 template <
typename IterableType>
73 bool MatchAndExplain([[maybe_unused]]
const IterableType& arg, [[maybe_unused]]::testing::MatchResultListener*
const listener)
const
75 if constexpr(
sizeof...(Matchers) == 0) {
84 *out <<
"contains in order elements that match ";
90 *out <<
"does not contain in order elements that match ";
95 template <
size_t Idx,
typename IteratorType>
96 bool MatchAndExplainImpl(
const IteratorType it_first,
const IteratorType it_last, ::testing::MatchResultListener*
const listener)
const
98 if (it_first == it_last) {;
99 *listener <<
"does not contain in order an element that "
100 << ::testing::DescribeMatcher<T>(std::get<Idx>(
matchers),
false);
104 if (::testing::Matches(std::get<Idx>(
matchers))(*it_first)) {
105 if constexpr (Idx ==
sizeof...(Matchers) - 1) {
118 if constexpr (
sizeof...(Matchers) >= 2)
120 [&] <
size_t... Idxs>(std::index_sequence<Idxs...>) {
121 ((*out << ::testing::DescribeMatcher<T>(std::get<Idxs>(
matchers),
false) <<
", "), ...);
122 }(std::make_index_sequence<
sizeof...(Matchers) - 1>{});
124 if constexpr (
sizeof...(Matchers) >= 1)
125 *out << ::testing::DescribeMatcher<T>(std::get<
sizeof...(Matchers) - 1>(
matchers),
false);
135template <
typename T,
typename... Matchers>
137 return ::testing::MakePolymorphicMatcher(
impl::ContainsInOrderMatcher<T, std::remove_cvref_t<Matchers>...>(std::forward<Matchers>(matchers)...));
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)
Allocate-data event associated with Kokkos::Tools::Experimental::EventSet::allocate_data.
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-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...