Files
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
INPUTS
bindings
cmake
docs
examples
include
lib
runtime
tools
unittests
AST
ASTMatchers
Analysis
Basic
CodeGen
CrossTU
Driver
Format
Frontend
Lex
Rename
Rewrite
Sema
StaticAnalyzer
Tooling
ASTSelectionTest.cpp
CMakeLists.txt
CastExprTest.cpp
CommentHandlerTest.cpp
CompilationDatabaseTest.cpp
DiagnosticsYamlTest.cpp
ExecutionTest.cpp
FixItTest.cpp
LexicallyOrderedRecursiveASTVisitorTest.cpp
LookupTest.cpp
QualTypeNamesTest.cpp
RecursiveASTVisitorTest.cpp
RecursiveASTVisitorTestCallVisitor.cpp
RecursiveASTVisitorTestDeclVisitor.cpp
RecursiveASTVisitorTestExprVisitor.cpp
RecursiveASTVisitorTestTypeLocVisitor.cpp
RefactoringActionRulesTest.cpp
RefactoringCallbacksTest.cpp
RefactoringTest.cpp
ReplacementTest.h
ReplacementsYamlTest.cpp
RewriterTest.cpp
RewriterTestContext.h
TestVisitor.h
ToolingTest.cpp
libclang
CMakeLists.txt
utils
www
.arcconfig
.clang-format
.clang-tidy
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
INSTALL.txt
LICENSE.TXT
ModuleInfo.txt
NOTES.txt
README.txt
clang-tools-extra
compiler-rt
libcxx
libcxxabi
libunwind
lld
lldb
llvm
openmp
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/external/llvm-project/clang/unittests/Tooling/ReplacementTest.h

57 lines
1.8 KiB
C
Raw Normal View History

//===- unittest/Tooling/ReplacementTest.h - Replacements related test------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines utility class and function for Replacement related tests.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_UNITTESTS_TOOLING_REPLACEMENTTESTBASE_H
#define LLVM_CLANG_UNITTESTS_TOOLING_REPLACEMENTTESTBASE_H
#include "RewriterTestContext.h"
#include "clang/Tooling/Core/Replacement.h"
#include "gtest/gtest.h"
namespace clang {
namespace tooling {
/// \brief Converts a set of replacements to Replacements class.
/// \return A Replacements class containing \p Replaces on success; otherwise,
/// an empty Replacements is returned.
inline tooling::Replacements
toReplacements(const std::set<tooling::Replacement> &Replaces) {
tooling::Replacements Result;
for (const auto &R : Replaces) {
auto Err = Result.add(R);
EXPECT_TRUE(!Err);
if (Err) {
llvm::errs() << llvm::toString(std::move(Err)) << "\n";
return tooling::Replacements();
}
}
return Result;
}
/// \brief A utility class for replacement related tests.
class ReplacementTest : public ::testing::Test {
protected:
tooling::Replacement createReplacement(SourceLocation Start, unsigned Length,
llvm::StringRef ReplacementText) {
return tooling::Replacement(Context.Sources, Start, Length,
ReplacementText);
}
RewriterTestContext Context;
};
} // namespace tooling
} // namespace clang
#endif // LLVM_CLANG_UNITTESTS_TOOLING_REPLACEMENTTESTBASE_H