summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2014-04-14 09:14:11 +0000
committerManuel Klimek <klimek@google.com>2014-04-14 09:14:11 +0000
commit68b03049e09824094b8ff07280b8240ab438167d (patch)
treefca344860a67d70bc4615f7c33d8e3003f0951e2 /clang/unittests/Format/FormatTest.cpp
parentefc3013544ee79c43f289b92125a81470fb7bc71 (diff)
downloadbcm5719-llvm-68b03049e09824094b8ff07280b8240ab438167d.tar.gz
bcm5719-llvm-68b03049e09824094b8ff07280b8240ab438167d.zip
Format code around VCS conflict markers.
Now correctly formats: { int a; void f() { callme(some(parameter1, <<<<<<< text by the vcs parameter2), ||||||| text by the vcs parameter2), parameter3, ======= text by the vcs parameter2, parameter3), >>>>>>> text by the vcs otherparameter); } } llvm-svn: 206157
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 382276abb60..fb33bd685be 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8402,5 +8402,97 @@ TEST_F(FormatTest, HandleUnbalancedImplicitBracesAcrossPPBranches) {
EXPECT_EQ(code, format(code));
}
+TEST_F(FormatTest, HandleConflictMarkers) {
+ // Git/SVN conflict markers.
+ EXPECT_EQ("int a;\n"
+ "void f() {\n"
+ " callme(some(parameter1,\n"
+ "<<<<<<< text by the vcs\n"
+ " parameter2),\n"
+ "||||||| text by the vcs\n"
+ " parameter2),\n"
+ " parameter3,\n"
+ "======= text by the vcs\n"
+ " parameter2, parameter3),\n"
+ ">>>>>>> text by the vcs\n"
+ " otherparameter);\n",
+ format("int a;\n"
+ "void f() {\n"
+ " callme(some(parameter1,\n"
+ "<<<<<<< text by the vcs\n"
+ " parameter2),\n"
+ "||||||| text by the vcs\n"
+ " parameter2),\n"
+ " parameter3,\n"
+ "======= text by the vcs\n"
+ " parameter2,\n"
+ " parameter3),\n"
+ ">>>>>>> text by the vcs\n"
+ " otherparameter);\n"));
+
+ // Perforce markers.
+ EXPECT_EQ("void f() {\n"
+ " function(\n"
+ ">>>> text by the vcs\n"
+ " parameter,\n"
+ "==== text by the vcs\n"
+ " parameter,\n"
+ "==== text by the vcs\n"
+ " parameter,\n"
+ "<<<< text by the vcs\n"
+ " parameter);\n",
+ format("void f() {\n"
+ " function(\n"
+ ">>>> text by the vcs\n"
+ " parameter,\n"
+ "==== text by the vcs\n"
+ " parameter,\n"
+ "==== text by the vcs\n"
+ " parameter,\n"
+ "<<<< text by the vcs\n"
+ " parameter);\n"));
+
+ EXPECT_EQ("<<<<<<<\n"
+ "|||||||\n"
+ "=======\n"
+ ">>>>>>>",
+ format("<<<<<<<\n"
+ "|||||||\n"
+ "=======\n"
+ ">>>>>>>"));
+
+ EXPECT_EQ("<<<<<<<\n"
+ "|||||||\n"
+ "int i;\n"
+ "=======\n"
+ ">>>>>>>",
+ format("<<<<<<<\n"
+ "|||||||\n"
+ "int i;\n"
+ "=======\n"
+ ">>>>>>>"));
+
+ // FIXME: Handle parsing of macros around conflict markers correctly:
+ EXPECT_EQ("#define Macro \\\n"
+ "<<<<<<<\n"
+ "Something \\\n"
+ "|||||||\n"
+ "Else \\\n"
+ "=======\n"
+ "Other \\\n"
+ ">>>>>>>\n"
+ "End int i;\n",
+ format("#define Macro \\\n"
+ "<<<<<<<\n"
+ " Something \\\n"
+ "|||||||\n"
+ " Else \\\n"
+ "=======\n"
+ " Other \\\n"
+ ">>>>>>>\n"
+ " End\n"
+ "int i;\n"));
+}
+
} // end namespace tooling
} // end namespace clang
OpenPOWER on IntegriCloud