diff options
Diffstat (limited to 'clang-tools-extra/unittests/cpp11-migrate/ReformattingTest.cpp')
-rw-r--r-- | clang-tools-extra/unittests/cpp11-migrate/ReformattingTest.cpp | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/clang-tools-extra/unittests/cpp11-migrate/ReformattingTest.cpp b/clang-tools-extra/unittests/cpp11-migrate/ReformattingTest.cpp index b4b9a365478..fcde6b81db4 100644 --- a/clang-tools-extra/unittests/cpp11-migrate/ReformattingTest.cpp +++ b/clang-tools-extra/unittests/cpp11-migrate/ReformattingTest.cpp @@ -9,7 +9,6 @@ #include "Core/Reformatting.h" #include "Core/FileOverrides.h" -#include "Core/Refactoring.h" #include "gtest/gtest.h" #include "VirtualFileHelper.h" @@ -20,9 +19,9 @@ namespace { // convenience function to create a ChangedRanges containing one Range ChangedRanges makeChangedRanges(unsigned Offset, unsigned Length) { ChangedRanges Changes; - ReplacementsVec Replaces; + Replacements Replaces; - Replaces.push_back(Replacement("", Offset, 0, std::string(Length, '~'))); + Replaces.insert(Replacement("", Offset, 0, std::string(Length, '~'))); Changes.adjustChangedRanges(Replaces); return Changes; } @@ -36,20 +35,16 @@ TEST(Reformatter, SingleReformat) { Reformatter ChangesReformatter(format::getLLVMStyle()); ChangedRanges Changes = makeChangedRanges(0, 6); - tooling::ReplacementsVec Replaces; - ChangesReformatter.reformatSingleFile( - FileName, Changes, VFHelper.getNewSourceManager(), Replaces); - - // We expect the code above to reformatted like so: - // - // int a; - // int b; - // - // This test is slightly fragile since there's more than one Replacement that - // results in the above change. However, testing the result of applying the - // replacement is more trouble than it's worth in this context. - ASSERT_EQ(1u, Replaces.size()); - EXPECT_EQ(3u, Replaces[0].getOffset()); - EXPECT_EQ(2u, Replaces[0].getLength()); - EXPECT_EQ(" ", Replaces[0].getReplacementText()); + tooling::Replacements Replaces = ChangesReformatter.reformatSingleFile( + FileName, Changes, VFHelper.getNewSourceManager()); + + SourceOverrides Overrides(FileName, /*TrackChanges=*/false); + Overrides.applyReplacements(Replaces, VFHelper.getNewSourceManager()); + + std::string Expected, Result; + + Expected = "int a;\n" + "int b;\n"; + Result = Overrides.getMainFileContent(); + EXPECT_EQ(Expected, Result); } |