summaryrefslogtreecommitdiff
path: root/unittests/Tooling/RefactoringTest.cpp
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-08-27 15:44:26 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-08-27 15:44:26 +0000
commita778cde0ddf4c47a63786fb1067f25c1fbfcf19d (patch)
treec983bfcadd5aa652881f5128cd684d742b3bd38e /unittests/Tooling/RefactoringTest.cpp
parentd36e46350b50907425bba0db1b3ddfb46cc1637f (diff)
downloadclang-a778cde0ddf4c47a63786fb1067f25c1fbfcf19d.tar.gz
Adding a vector version of clang::tooling::shiftedCodePosition().
During the transition of clang::tooling::Replacements from std::set to std::vector, functions such as clang::tooling::applyAllReplacements() have been duplicated to take a std::vector<Replacement>. Applying this same temporary duplication to clang::tooling::shiftedCodePosition(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189358 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Tooling/RefactoringTest.cpp')
-rw-r--r--unittests/Tooling/RefactoringTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/unittests/Tooling/RefactoringTest.cpp b/unittests/Tooling/RefactoringTest.cpp
index a88de1c9f4..8c7bfa1c76 100644
--- a/unittests/Tooling/RefactoringTest.cpp
+++ b/unittests/Tooling/RefactoringTest.cpp
@@ -182,6 +182,25 @@ TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
EXPECT_EQ(5u, shiftedCodePosition(Replaces, 8)); // int i|
}
+// FIXME: Remove this test case when Replacements is implemented as std::vector
+// instead of std::set. The other ReplacementTest tests will need to be updated
+// at that point as well.
+TEST(ShiftedCodePositionTest, VectorFindsNewCodePositionWithInserts) {
+ std::vector<Replacement> Replaces;
+ Replaces.push_back(Replacement("", 0, 1, ""));
+ Replaces.push_back(Replacement("", 4, 3, " "));
+ // Assume ' int i;' is turned into 'int i;' and cursor is located at '|'.
+ EXPECT_EQ(0u, shiftedCodePosition(Replaces, 0)); // |int i;
+ EXPECT_EQ(0u, shiftedCodePosition(Replaces, 1)); // |nt i;
+ EXPECT_EQ(1u, shiftedCodePosition(Replaces, 2)); // i|t i;
+ EXPECT_EQ(2u, shiftedCodePosition(Replaces, 3)); // in| i;
+ EXPECT_EQ(3u, shiftedCodePosition(Replaces, 4)); // int| i;
+ EXPECT_EQ(4u, shiftedCodePosition(Replaces, 5)); // int | i;
+ EXPECT_EQ(4u, shiftedCodePosition(Replaces, 6)); // int |i;
+ EXPECT_EQ(4u, shiftedCodePosition(Replaces, 7)); // int |;
+ EXPECT_EQ(5u, shiftedCodePosition(Replaces, 8)); // int i|
+}
+
TEST(ShiftedCodePositionTest, FindsNewCodePositionWithInserts) {
Replacements Replaces;
Replaces.insert(Replacement("", 4, 0, "\"\n\""));