9#ifndef LLVM_TESTING_ADT_STRINGMAPENTRY_H_
10#define LLVM_TESTING_ADT_STRINGMAPENTRY_H_
14#include "gmock/gmock.h"
23 decltype(std::declval<std::ostream &>() << std::declval<T>());
31 OS <<
"{\"" <<
E.getKey().data() <<
"\": ";
33 decltype(
E.getValue())>::value) {
36 OS <<
"non-printable value";
43template <
typename StringMapEntryT>
45 :
public testing::MatcherInterface<StringMapEntryT> {
47 using ValueT =
typename std::remove_reference_t<StringMapEntryT>::ValueType;
49 template <
typename KeyMatcherT,
typename ValueMatcherT>
51 ValueMatcherT ValueMatcherArg)
53 testing::SafeMatcherCast<
const std::string &>(KeyMatcherArg)),
55 testing::SafeMatcherCast<
const ValueT &>(ValueMatcherArg)) {}
58 *OS <<
"has a string key that ";
59 KeyMatcher.DescribeTo(OS);
60 *OS <<
", and has a value that ";
61 ValueMatcher.DescribeTo(OS);
65 *OS <<
"has a string key that ";
66 KeyMatcher.DescribeNegationTo(OS);
67 *OS <<
", or has a value that ";
68 ValueMatcher.DescribeNegationTo(OS);
73 testing::MatchResultListener *ResultListener)
const override {
74 testing::StringMatchResultListener KeyListener;
75 if (!KeyMatcher.MatchAndExplain(Entry.getKey().data(), &KeyListener)) {
76 *ResultListener << (
"which has a string key " +
77 (KeyListener.str().empty() ?
"that doesn't match"
78 : KeyListener.str()));
81 testing::StringMatchResultListener ValueListener;
82 if (!ValueMatcher.MatchAndExplain(Entry.getValue(), &ValueListener)) {
83 *ResultListener << (
"which has a value " + (ValueListener.str().empty()
84 ?
"that doesn't match"
85 : ValueListener.str()));
88 *ResultListener <<
"which is a match";
93 const testing::Matcher<const std::string &> KeyMatcher;
94 const testing::Matcher<const ValueT &> ValueMatcher;
97template <
typename KeyMatcherT,
typename ValueMatcherT>
103 template <
typename StringMapEntryT>
104 operator testing::Matcher<StringMapEntryT>()
const {
105 return testing::Matcher<StringMapEntryT>(
110 const KeyMatcherT KM;
111 const ValueMatcherT VM;
118template <
typename KeyMatcherT,
typename ValueMatcherT>
119detail::StringMapEntryMatcher<KeyMatcherT, ValueMatcherT>
122 std::move(KM), std::move(VM));
This file defines the StringMapEntry class - it is intended to be a low dependency implementation det...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains library features backported from future STL versions.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringMapEntryMatcherImpl(KeyMatcherT KeyMatcherArg, ValueMatcherT ValueMatcherArg)
bool MatchAndExplain(StringMapEntryT Entry, testing::MatchResultListener *ResultListener) const override
void DescribeTo(std::ostream *OS) const override
void DescribeNegationTo(std::ostream *OS) const override
typename std::remove_reference_t< StringMapEntryT >::ValueType ValueT
StringMapEntryMatcher(KeyMatcherT KMArg, ValueMatcherT VMArg)
These are wrappers over isa* function that allow them to be used in generic algorithms such as llvm:a...
decltype(std::declval< std::ostream & >()<< std::declval< T >()) check_ostream
This is an optimization pass for GlobalISel generic memory operations.
detail::StringMapEntryMatcher< KeyMatcherT, ValueMatcherT > IsStringMapEntry(KeyMatcherT KM, ValueMatcherT VM)
Returns a gMock matcher that matches a StringMapEntry whose string key matches KeyMatcher,...
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
typename detail::detector< void, Op, Args... >::value_t is_detected
Detects if a given trait holds for some set of arguments 'Args'.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.