summaryrefslogtreecommitdiff
path: root/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
commit3c90e57f06bed57e1587e4b4fb06b7b7fae94119 (patch)
tree8c4a9f7bdcf4a1ba075dd8a36037e8d19985d484 /unittests/Tooling/RefactoringTest.cpp
parentfce476b6e965594e2bf2ea2f03a3d1021e2e227a (diff)
downloadclang-3c90e57f06bed57e1587e4b4fb06b7b7fae94119.tar.gz
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284219 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Tooling/RefactoringTest.cpp')
-rw-r--r--unittests/Tooling/RefactoringTest.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/unittests/Tooling/RefactoringTest.cpp b/unittests/Tooling/RefactoringTest.cpp
index 0a70a112aa..bf50b7d94d 100644
--- a/unittests/Tooling/RefactoringTest.cpp
+++ b/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