10 #ifndef LLVM_TESTING_SUPPORT_ERROR_H 11 #define LLVM_TESTING_SUPPORT_ERROR_H 17 #include "gmock/gmock.h" 34 :
public testing::MatcherInterface<const ExpectedHolder<T> &> {
40 testing::MatchResultListener *listener)
const override {
44 bool result = Matcher.MatchAndExplain(*Holder.
Exp, listener);
49 Matcher.DescribeNegationTo(listener->stream());
55 *OS <<
"succeeded with value (";
56 Matcher.DescribeTo(OS);
61 *OS <<
"did not succeed or value (";
62 Matcher.DescribeNegationTo(OS);
67 testing::Matcher<T> Matcher;
76 operator testing::Matcher<const ExpectedHolder<T> &>()
const {
85 template <
typename InfoT>
89 : Matcher(
std::move(Matcher)) {}
92 testing::MatchResultListener *listener)
const override {
96 if (Holder.
Infos.size() > 1) {
97 *listener <<
"multiple errors";
102 if (!
Info.isA<InfoT>()) {
103 *listener <<
"Error was not of given type";
110 return Matcher->MatchAndExplain(static_cast<InfoT &>(
Info), listener);
114 *OS <<
"failed with Error of given type";
116 *OS <<
" and the error ";
117 Matcher->DescribeTo(OS);
122 *OS <<
"succeeded or did not fail with the error of given type";
124 *OS <<
" or the error ";
125 Matcher->DescribeNegationTo(OS);
134 #define EXPECT_THAT_ERROR(Err, Matcher) \ 135 EXPECT_THAT(llvm::detail::TakeError(Err), Matcher) 136 #define ASSERT_THAT_ERROR(Err, Matcher) \ 137 ASSERT_THAT(llvm::detail::TakeError(Err), Matcher) 139 #define EXPECT_THAT_EXPECTED(Err, Matcher) \ 140 EXPECT_THAT(llvm::detail::TakeExpected(Err), Matcher) 141 #define ASSERT_THAT_EXPECTED(Err, Matcher) \ 142 ASSERT_THAT(llvm::detail::TakeExpected(Err), Matcher) 144 MATCHER(Succeeded,
"") {
return arg.Success(); }
147 template <
typename InfoT>
148 testing::Matcher<const detail::ErrorHolder &>
Failed() {
152 template <
typename InfoT,
typename M>
153 testing::Matcher<const detail::ErrorHolder &>
Failed(M Matcher) {
155 testing::SafeMatcherCast<InfoT &>(Matcher)));
158 template <
typename M>
ValueMatchesPoly(const M &Matcher)
ErrorHolder TakeError(Error Err)
void DescribeNegationTo(std::ostream *OS) const override
This class represents lattice values for constants.
ExpectedHolder< T > TakeExpected(Expected< T > &Exp)
detail::ValueMatchesPoly< M > HasValue(M Matcher)
Error takeError()
Take ownership of the stored error.
void DescribeNegationTo(std::ostream *OS) const override
void DescribeTo(std::ostream *OS) const override
Tagged union holding either a T or a Error.
Analysis containing CSE Info
std::vector< std::shared_ptr< ErrorInfoBase > > Infos
bool MatchAndExplain(const ErrorHolder &Holder, testing::MatchResultListener *listener) const override
void DescribeTo(std::ostream *OS) const override
testing::Matcher< const detail::ErrorHolder & > Failed()
bool MatchAndExplain(const ExpectedHolder< T > &Holder, testing::MatchResultListener *listener) const override
ValueMatchesMono(const testing::Matcher< T > &Matcher)
ErrorMatchesMono(Optional< testing::Matcher< InfoT &>> Matcher)