LLVM 20.0.0git
Classes | Namespaces | Macros | Functions
Error.h File Reference
#include "llvm/Support/Error.h"
#include "llvm/Testing/Support/SupportHelpers.h"
#include "gmock/gmock.h"
#include <ostream>

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

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 
namespace  llvm::detail
 These are wrappers over isa* function that allow them to be used in generic algorithms such as llvm:all_of, llvm::none_of, etc.
 

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>'.
 
#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< M > llvm::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!"));
}
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define EXPECT_THAT_EXPECTED(Err, Matcher)
Helper macro for checking the result of an 'Expected<T>'.
Definition: Error.h:189

Definition at line 189 of file Error.h.