9#include "llvm/Support/Errc.h"
10#include "llvm/Support/Error.h"
11#include "gmock/gmock.h"
12#include "gtest/gtest.h"
19TEST(ErrorTest, Overloads) {
20 EXPECT_EQ(
"foo", llvm::toString(
error(
"foo")));
23 handleAllErrors(
error(
"foo"), [&](
const llvm::ErrorInfoBase &EI) {
24 EXPECT_EQ(llvm::inconvertibleErrorCode(), EI.convertToErrorCode());
27 EXPECT_EQ(
"foo 42", llvm::toString(
error(
"foo {0}", 42)));
28 handleAllErrors(
error(
"foo {0}", 42), [&](
const llvm::ErrorInfoBase &EI) {
29 EXPECT_EQ(llvm::inconvertibleErrorCode(), EI.convertToErrorCode());
32 EXPECT_EQ(
"foo", llvm::toString(
error(llvm::errc::invalid_argument,
"foo")));
33 EXPECT_EQ(llvm::errc::invalid_argument,
34 llvm::errorToErrorCode(
error(llvm::errc::invalid_argument,
"foo")));
37 llvm::toString(
error(llvm::errc::invalid_argument,
"foo {0}", 42)));
38 EXPECT_EQ(llvm::errc::invalid_argument,
39 llvm::errorToErrorCode(
40 error(llvm::errc::invalid_argument,
"foo {0}", 42)));
43TEST(ErrorTest, Lifetimes) {
44 std::optional<llvm::Error> Err;
47 std::string S =
"hello, world";
48 Err =
error(
"S={0}", llvm::StringRef(S));
51 EXPECT_EQ(
"S=hello, world", llvm::toString(std::move(*Err)));
54TEST(ErrorTest, ConsumeError) {
56 llvm::Error
Bar =
error(
"bar: {0}", std::move(
Foo));
57 EXPECT_EQ(
"bar: foo", llvm::toString(std::move(
Bar)));
llvm::Error error(std::error_code EC, const char *Fmt, Ts &&... Vals)
TEST(BackgroundQueueTest, Priority)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//