9 #ifndef LLVM_TESTING_SUPPORT_ERROR_H 10 #define LLVM_TESTING_SUPPORT_ERROR_H 16 #include "gmock/gmock.h" 33 :
public testing::MatcherInterface<const ExpectedHolder<T> &> {
39 testing::MatchResultListener *listener)
const override {
43 bool result = Matcher.MatchAndExplain(*Holder.
Exp, listener);
48 Matcher.DescribeNegationTo(listener->stream());
54 *OS <<
"succeeded with value (";
55 Matcher.DescribeTo(OS);
60 *OS <<
"did not succeed or value (";
61 Matcher.DescribeNegationTo(OS);
66 testing::Matcher<T> Matcher;
75 operator testing::Matcher<const ExpectedHolder<T> &>()
const {
84 template <
typename InfoT>
88 : Matcher(
std::move(Matcher)) {}
91 testing::MatchResultListener *listener)
const override {
95 if (Holder.
Infos.size() > 1) {
96 *listener <<
"multiple errors";
101 if (!
Info.isA<InfoT>()) {
102 *listener <<
"Error was not of given type";
109 return Matcher->MatchAndExplain(static_cast<InfoT &>(
Info), listener);
113 *OS <<
"failed with Error of given type";
115 *OS <<
" and the error ";
116 Matcher->DescribeTo(OS);
121 *OS <<
"succeeded or did not fail with the error of given type";
123 *OS <<
" or the error ";
124 Matcher->DescribeNegationTo(OS);
133 #define EXPECT_THAT_ERROR(Err, Matcher) \ 134 EXPECT_THAT(llvm::detail::TakeError(Err), Matcher) 135 #define ASSERT_THAT_ERROR(Err, Matcher) \ 136 ASSERT_THAT(llvm::detail::TakeError(Err), Matcher) 138 #define EXPECT_THAT_EXPECTED(Err, Matcher) \ 139 EXPECT_THAT(llvm::detail::TakeExpected(Err), Matcher) 140 #define ASSERT_THAT_EXPECTED(Err, Matcher) \ 141 ASSERT_THAT(llvm::detail::TakeExpected(Err), Matcher) 143 MATCHER(Succeeded,
"") {
return arg.Success(); }
146 template <
typename InfoT>
147 testing::Matcher<const detail::ErrorHolder &>
Failed() {
151 template <
typename InfoT,
typename M>
152 testing::Matcher<const detail::ErrorHolder &>
Failed(M Matcher) {
154 testing::SafeMatcherCast<InfoT &>(Matcher)));
157 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)