diff options
author | Edwin Vane <edwin.vane@intel.com> | 2013-08-13 17:38:19 +0000 |
---|---|---|
committer | Edwin Vane <edwin.vane@intel.com> | 2013-08-13 17:38:19 +0000 |
commit | b58cfd93c49727c1d471ce71901502df824556c7 (patch) | |
tree | 51ff50f7ed12847d7a0fdbf91219d28eb31b9429 /unittests/Tooling/RefactoringTest.cpp | |
parent | 95f0766c1942c8cdc9f913a083ad2bfc4c0c27c9 (diff) | |
download | clang-b58cfd93c49727c1d471ce71901502df824556c7.tar.gz clang-b58cfd93c49727c1d471ce71901502df824556c7.tar.bz2 clang-b58cfd93c49727c1d471ce71901502df824556c7.tar.xz |
Adding a vector version of tooling::applyAllReplacements
One day soon, tooling::Replacements will be changed from being implemented as
an std::set to being implemented as an std::vector. Until then, some new code
using vectors of Replacements would enjoy having a version of
applyAllReplacements that takes a vector.
Differential Revision: http://llvm-reviews.chandlerc.com/D1380
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188295 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Tooling/RefactoringTest.cpp')
-rw-r--r-- | unittests/Tooling/RefactoringTest.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/unittests/Tooling/RefactoringTest.cpp b/unittests/Tooling/RefactoringTest.cpp index d9f023d965..81f9f040ae 100644 --- a/unittests/Tooling/RefactoringTest.cpp +++ b/unittests/Tooling/RefactoringTest.cpp @@ -120,6 +120,21 @@ TEST_F(ReplacementTest, CanApplyReplacements) { EXPECT_EQ("line1\nreplaced\nother\nline4", Context.getRewrittenText(ID)); } +// 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_F(ReplacementTest, VectorCanApplyReplacements) { + FileID ID = Context.createInMemoryFile("input.cpp", + "line1\nline2\nline3\nline4"); + std::vector<Replacement> Replaces; + Replaces.push_back(Replacement(Context.Sources, Context.getLocation(ID, 2, 1), + 5, "replaced")); + Replaces.push_back( + Replacement(Context.Sources, Context.getLocation(ID, 3, 1), 5, "other")); + EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite)); + EXPECT_EQ("line1\nreplaced\nother\nline4", Context.getRewrittenText(ID)); +} + TEST_F(ReplacementTest, SkipsDuplicateReplacements) { FileID ID = Context.createInMemoryFile("input.cpp", "line1\nline2\nline3\nline4"); |