aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/RefactoringTest.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2016-10-14 09:32:06 +0000
committerEric Liu <ioeric@google.com>2016-10-14 09:32:06 +0000
commitcefe763dd277a88d9b7fd5d267e8c6baacc5f7a6 (patch)
treea369bbd388be5c7f9db22e2209e3ee7ae7591301 /clang/unittests/Tooling/RefactoringTest.cpp
parentb3fd189cb5030f394db0414e2d06d779adfad062 (diff)
downloadllvm-cefe763dd277a88d9b7fd5d267e8c6baacc5f7a6.zip
llvm-cefe763dd277a88d9b7fd5d267e8c6baacc5f7a6.tar.gz
llvm-cefe763dd277a88d9b7fd5d267e8c6baacc5f7a6.tar.bz2
Deduplicate sets of replacements by file names.
Summary: If there are multiple <File, Replacements> pairs with the same file path after removing dots, we only keep one pair (with path after dots being removed) and discard the rest. Reviewers: djasper Subscribers: klimek, hokein, bkramer, cfe-commits Differential Revision: https://reviews.llvm.org/D25565 llvm-svn: 284219
Diffstat (limited to 'clang/unittests/Tooling/RefactoringTest.cpp')
-rw-r--r--clang/unittests/Tooling/RefactoringTest.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/RefactoringTest.cpp b/clang/unittests/Tooling/RefactoringTest.cpp
index 0a70a11..bf50b7d 100644
--- a/clang/unittests/Tooling/RefactoringTest.cpp
+++ b/clang/unittests/Tooling/RefactoringTest.cpp
@@ -972,5 +972,23 @@ TEST_F(MergeReplacementsTest, OverlappingRanges) {
toReplacements({{"", 0, 3, "cc"}, {"", 3, 3, "dd"}}));
}
+TEST(DeduplicateByFileTest, LeaveLeadingDotDot) {
+ std::map<std::string, Replacements> FileToReplaces;
+ FileToReplaces["../../a/b/.././c.h"] = Replacements();
+ FileToReplaces["../../a/c.h"] = Replacements();
+ FileToReplaces = groupReplacementsByFile(FileToReplaces);
+ EXPECT_EQ(1u, FileToReplaces.size());
+ EXPECT_EQ("../../a/c.h", FileToReplaces.begin()->first);
+}
+
+TEST(DeduplicateByFileTest, RemoveDotSlash) {
+ std::map<std::string, Replacements> FileToReplaces;
+ FileToReplaces["./a/b/.././c.h"] = Replacements();
+ FileToReplaces["a/c.h"] = Replacements();
+ FileToReplaces = groupReplacementsByFile(FileToReplaces);
+ EXPECT_EQ(1u, FileToReplaces.size());
+ EXPECT_EQ("a/c.h", FileToReplaces.begin()->first);
+}
+
} // end namespace tooling
} // end namespace clang