summaryrefslogtreecommitdiffstats
path: root/unittests/Tooling/RefactoringTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Tooling/RefactoringTest.cpp')
-rw-r--r--unittests/Tooling/RefactoringTest.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/unittests/Tooling/RefactoringTest.cpp b/unittests/Tooling/RefactoringTest.cpp
index ddb974a..a026a94 100644
--- a/unittests/Tooling/RefactoringTest.cpp
+++ b/unittests/Tooling/RefactoringTest.cpp
@@ -237,7 +237,8 @@ public:
const FileEntry *File = Context.Files.getFile(Path);
assert(File != nullptr);
- StringRef Found = TemporaryFiles.GetOrCreateValue(Name, Path.str()).second;
+ StringRef Found =
+ TemporaryFiles.insert(std::make_pair(Name, Path.str())).first->second;
assert(Found == Path);
(void)Found;
return Context.Sources.createFileID(File, SourceLocation(), SrcMgr::C_User);
@@ -251,9 +252,8 @@ public:
// descriptor, which might not see the changes made.
// FIXME: Figure out whether there is a way to get the SourceManger to
// reopen the file.
- std::unique_ptr<const llvm::MemoryBuffer> FileBuffer(
- Context.Files.getBufferForFile(Path, nullptr));
- return FileBuffer->getBuffer();
+ auto FileBuffer = Context.Files.getBufferForFile(Path);
+ return (*FileBuffer)->getBuffer();
}
llvm::StringMap<std::string> TemporaryFiles;
@@ -299,11 +299,12 @@ private:
public:
TestAction(TestVisitor *Visitor) : Visitor(Visitor) {}
- virtual clang::ASTConsumer* CreateASTConsumer(
- clang::CompilerInstance& compiler, llvm::StringRef dummy) {
+ virtual std::unique_ptr<clang::ASTConsumer>
+ CreateASTConsumer(clang::CompilerInstance &compiler,
+ llvm::StringRef dummy) {
Visitor->SM = &compiler.getSourceManager();
/// TestConsumer will be deleted by the framework calling us.
- return new FindConsumer(Visitor);
+ return llvm::make_unique<FindConsumer>(Visitor);
}
private:
@@ -392,6 +393,8 @@ TEST(DeduplicateTest, removesDuplicates) {
Input.push_back(Replacement("fileA", 50, 0, " foo ")); // Duplicate
Input.push_back(Replacement("fileA", 51, 3, " bar "));
Input.push_back(Replacement("fileB", 51, 3, " bar ")); // Filename differs!
+ Input.push_back(Replacement("fileB", 60, 1, " bar "));
+ Input.push_back(Replacement("fileA", 60, 2, " bar "));
Input.push_back(Replacement("fileA", 51, 3, " moo ")); // Replacement text
// differs!
@@ -402,12 +405,14 @@ TEST(DeduplicateTest, removesDuplicates) {
Expected.push_back(Replacement("fileA", 50, 0, " foo "));
Expected.push_back(Replacement("fileA", 51, 3, " bar "));
Expected.push_back(Replacement("fileA", 51, 3, " moo "));
- Expected.push_back(Replacement("fileB", 51, 3, " bar "));
+ Expected.push_back(Replacement("fileB", 60, 1, " bar "));
+ Expected.push_back(Replacement("fileA", 60, 2, " bar "));
std::vector<Range> Conflicts; // Ignored for this test
deduplicate(Input, Conflicts);
- ASSERT_TRUE(Expected == Input);
+ EXPECT_EQ(3U, Conflicts.size());
+ EXPECT_EQ(Expected, Input);
}
TEST(DeduplicateTest, detectsConflicts) {
OpenPOWER on IntegriCloud