summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/CleanupTest.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2016-10-05 15:42:19 +0000
committerEric Liu <ioeric@google.com>2016-10-05 15:42:19 +0000
commit11a4237b23eaeb718ac7b746dc91a6131054cf81 (patch)
treedec69d421aab3a2d91432e35321845c336a2c2b0 /clang/unittests/Format/CleanupTest.cpp
parentc26c03d911f8f686aabc19705ef2f240098cc886 (diff)
downloadbcm5719-llvm-11a4237b23eaeb718ac7b746dc91a6131054cf81.tar.gz
bcm5719-llvm-11a4237b23eaeb718ac7b746dc91a6131054cf81.zip
[clang-format] append newline after code when inserting new headers at the end of the code which does not end with newline.
Summary: append newline after code when inserting new headers at the end of the code which does not end with newline. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D21026 llvm-svn: 283330
Diffstat (limited to 'clang/unittests/Format/CleanupTest.cpp')
-rw-r--r--clang/unittests/Format/CleanupTest.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/clang/unittests/Format/CleanupTest.cpp b/clang/unittests/Format/CleanupTest.cpp
index c3e297f7976..25fa9539f2b 100644
--- a/clang/unittests/Format/CleanupTest.cpp
+++ b/clang/unittests/Format/CleanupTest.cpp
@@ -709,16 +709,24 @@ TEST_F(CleanUpReplacementsTest, EmptyCode) {
EXPECT_EQ(Expected, apply(Code, Replaces));
}
-// FIXME: although this case does not crash, the insertion is wrong. A '\n'
-// should be inserted between the two #includes.
TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCode) {
std::string Code = "#include <map>";
- std::string Expected = "#include <map>#include <vector>\n";
+ std::string Expected = "#include <map>\n#include <vector>\n";
tooling::Replacements Replaces =
toReplacements({createInsertion("#include <vector>")});
EXPECT_EQ(Expected, apply(Code, Replaces));
}
+TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCodeMultipleInsertions) {
+ std::string Code = "#include <map>";
+ std::string Expected =
+ "#include <map>\n#include <string>\n#include <vector>\n";
+ tooling::Replacements Replaces =
+ toReplacements({createInsertion("#include <string>"),
+ createInsertion("#include <vector>")});
+ EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
TEST_F(CleanUpReplacementsTest, SkipExistingHeaders) {
std::string Code = "#include \"a.h\"\n"
"#include <vector>\n";
OpenPOWER on IntegriCloud