LLVM  14.0.0git
Classes | Namespaces | Macros | Functions
Error.h File Reference
#include "llvm/ADT/Optional.h"
#include "llvm/Support/Error.h"
#include "llvm/Testing/Support/SupportHelpers.h"
#include "gmock/gmock.h"
#include <ostream>
Include dependency graph for Error.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  llvm::detail::ValueMatchesMono< T >
 
class  llvm::detail::ValueMatchesPoly< M >
 
class  llvm::detail::ErrorMatchesMono< InfoT >
 
class  llvm::detail::ErrorMessageMatches
 

Namespaces

 llvm
 This is an optimization pass for GlobalISel generic memory operations.
 
 llvm::detail
 

Macros

#define EXPECT_THAT_ERROR(Err, Matcher)   EXPECT_THAT(llvm::detail::TakeError(Err), Matcher)
 
#define ASSERT_THAT_ERROR(Err, Matcher)   ASSERT_THAT(llvm::detail::TakeError(Err), Matcher)
 
#define EXPECT_THAT_EXPECTED(Err, Matcher)   EXPECT_THAT(llvm::detail::TakeExpected(Err), Matcher)
 Helper macro for checking the result of an 'Expected<T>'. More...
 
#define ASSERT_THAT_EXPECTED(Err, Matcher)   ASSERT_THAT(llvm::detail::TakeExpected(Err), Matcher)
 

Functions

ErrorHolder llvm::detail::TakeError (Error Err)
 
template<typename T >
ExpectedHolder< Tllvm::detail::TakeExpected (Expected< T > &Exp)
 
template<typename T >
ExpectedHolder< Tllvm::detail::TakeExpected (Expected< T > &&Exp)
 
 llvm::MATCHER (Succeeded, "")
 
 llvm::MATCHER (Failed, "")
 
template<typename InfoT >
testing::Matcher< const detail::ErrorHolder & > llvm::Failed ()
 
template<typename InfoT , typename M >
testing::Matcher< const detail::ErrorHolder & > llvm::Failed (M Matcher)
 
template<typename... M>
testing::Matcher< const detail::ErrorHolder & > llvm::FailedWithMessage (M... Matcher)
 
template<typename M >
testing::Matcher< const detail::ErrorHolder & > llvm::FailedWithMessageArray (M Matcher)
 
template<typename M >
detail::ValueMatchesPoly< Mllvm::HasValue (M Matcher)
 

Macro Definition Documentation

◆ ASSERT_THAT_ERROR

#define ASSERT_THAT_ERROR (   Err,
  Matcher 
)    ASSERT_THAT(llvm::detail::TakeError(Err), Matcher)

Definition at line 165 of file Error.h.

◆ ASSERT_THAT_EXPECTED

#define ASSERT_THAT_EXPECTED (   Err,
  Matcher 
)    ASSERT_THAT(llvm::detail::TakeExpected(Err), Matcher)

Definition at line 191 of file Error.h.

◆ EXPECT_THAT_ERROR

#define EXPECT_THAT_ERROR (   Err,
  Matcher 
)    EXPECT_THAT(llvm::detail::TakeError(Err), Matcher)

Definition at line 163 of file Error.h.

◆ EXPECT_THAT_EXPECTED

#define EXPECT_THAT_EXPECTED (   Err,
  Matcher 
)    EXPECT_THAT(llvm::detail::TakeExpected(Err), Matcher)

Helper macro for checking the result of an 'Expected<T>'.

// function to be tested
Expected<int> myDivide(int A, int B);
TEST(myDivideTests, GoodAndBad) {
// test good case
// if you only care about success or failure:
EXPECT_THAT_EXPECTED(myDivide(10, 5), Succeeded());
// if you also care about the value:
EXPECT_THAT_EXPECTED(myDivide(10, 5), HasValue(2));
// test the error case
EXPECT_THAT_EXPECTED(myDivide(10, 0), Failed());
// also check the error message
EXPECT_THAT_EXPECTED(myDivide(10, 0),
FailedWithMessage("B must not be zero!"));
}

Definition at line 189 of file Error.h.

llvm::FailedWithMessage
testing::Matcher< const detail::ErrorHolder & > FailedWithMessage(M... Matcher)
Definition: Error.h:209
llvm::Failed
testing::Matcher< const detail::ErrorHolder & > Failed()
Definition: Error.h:198
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A
* A
Definition: README_ALTIVEC.txt:89
llvm::HasValue
detail::ValueMatchesPoly< M > HasValue(M Matcher)
Definition: Error.h:221
EXPECT_THAT_EXPECTED
#define EXPECT_THAT_EXPECTED(Err, Matcher)
Helper macro for checking the result of an 'Expected<T>'.
Definition: Error.h:189