9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TWEAKS_TWEAKTESTING_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TWEAKS_TWEAKTESTING_H
14#include "llvm/ADT/StringMap.h"
15#include "llvm/ADT/StringRef.h"
16#include "llvm/Testing/Annotations/Annotations.h"
17#include "gmock/gmock.h"
18#include "gtest/gtest.h"
60 TweakTest(
const char *TweakID) : TweakID(TweakID) {}
76 std::unique_ptr<const SymbolIndex>
Index =
nullptr;
91 std::string
apply(llvm::StringRef MarkedCode,
92 llvm::StringMap<std::string> *EditedFiles =
nullptr)
const;
99 static std::string
decorate(llvm::StringRef,
unsigned);
100 static std::string
decorate(llvm::StringRef, llvm::Annotations::Range);
104 return arg.first() == FileName && arg.second == Contents;
107#define TWEAK_TEST(TweakID) \
108 class TweakID##Test : public ::clang::clangd::TweakTest { \
110 TweakID##Test() : TweakTest(#TweakID) {} \
113#define EXPECT_AVAILABLE_(MarkedCode, Available) \
115 llvm::Annotations A{llvm::StringRef(MarkedCode)}; \
116 auto AST = build(A.code()); \
117 assert(!A.points().empty() || !A.ranges().empty()); \
118 for (const auto &P : A.points()) \
119 EXPECT_EQ(Available, isAvailable(AST, {P, P})) << decorate(A.code(), P); \
120 for (const auto &R : A.ranges()) \
121 EXPECT_EQ(Available, isAvailable(AST, R)) << decorate(A.code(), R); \
123#define EXPECT_AVAILABLE(MarkedCode) EXPECT_AVAILABLE_(MarkedCode, true)
124#define EXPECT_UNAVAILABLE(MarkedCode) EXPECT_AVAILABLE_(MarkedCode, false)
Stores and provides access to parsed AST.
std::vector< std::string > ExtraArgs
TweakTest(const char *TweakID)
llvm::StringMap< std::string > ExtraFiles
static std::string decorate(llvm::StringRef, unsigned)
WrappedAST build(llvm::StringRef) const
std::pair< ParsedAST, unsigned > WrappedAST
std::string apply(llvm::StringRef MarkedCode, llvm::StringMap< std::string > *EditedFiles=nullptr) const
bool isAvailable(WrappedAST &, llvm::Annotations::Range) const
std::unique_ptr< const SymbolIndex > Index
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
MATCHER_P2(hasFlag, Flag, Path, "")
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//