summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/CleanupTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Format/CleanupTest.cpp')
-rw-r--r--clang/unittests/Format/CleanupTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/unittests/Format/CleanupTest.cpp b/clang/unittests/Format/CleanupTest.cpp
index c3e7e2b4c18..dbf3f070476 100644
--- a/clang/unittests/Format/CleanupTest.cpp
+++ b/clang/unittests/Format/CleanupTest.cpp
@@ -916,6 +916,30 @@ TEST_F(CleanUpReplacementsTest, CanInsertAfterComment) {
EXPECT_EQ(Expected, apply(Code, Replaces));
}
+TEST_F(CleanUpReplacementsTest, LongCommentsInTheBeginningOfFile) {
+ std::string Code = "// Loooooooooooooooooooooooooong comment\n"
+ "// Loooooooooooooooooooooooooong comment\n"
+ "// Loooooooooooooooooooooooooong comment\n"
+ "#include <string>\n"
+ "#include <vector>\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \"b.h\"\n";
+ std::string Expected = "// Loooooooooooooooooooooooooong comment\n"
+ "// Loooooooooooooooooooooooooong comment\n"
+ "// Loooooooooooooooooooooooooong comment\n"
+ "#include <string>\n"
+ "#include <vector>\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \"b.h\"\n"
+ "#include \"third.h\"\n";
+ tooling::Replacements Replaces =
+ toReplacements({createInsertion("#include \"third.h\"")});
+ Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp);
+ EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
TEST_F(CleanUpReplacementsTest, CanDeleteAfterCode) {
std::string Code = "#include \"a.h\"\n"
"void f() {}\n"
OpenPOWER on IntegriCloud