summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-12-01 12:00:43 +0000
committerDaniel Jasper <djasper@google.com>2015-12-01 12:00:43 +0000
commitec90e51c7946bfd57097c8e45b5f12f3077f4895 (patch)
tree4940e2087df6d7396160ca69cf9bfc5dd74c1b73 /clang/unittests/Format/FormatTest.cpp
parente51b0e13f30a54fbde3017d7e72cca6cc01312a4 (diff)
downloadbcm5719-llvm-ec90e51c7946bfd57097c8e45b5f12f3077f4895.tar.gz
bcm5719-llvm-ec90e51c7946bfd57097c8e45b5f12f3077f4895.zip
This fixes https://llvm.org/bugs/show_bug.cgi?id=25329, as well as
misalignments like the following: int a, b = 2; int c = 3; Patch by Beren Minor, thanks! llvm-svn: 254406
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp56
1 files changed, 55 insertions, 1 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 176c74bf7ee..1d64405f08f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8659,7 +8659,7 @@ TEST_F(FormatTest, AlignConsecutiveAssignments) {
Alignment);
verifyFormat("class C {\n"
"public:\n"
- " int i = 1;\n"
+ " int i = 1;\n"
" virtual void f() = 0;\n"
"};",
Alignment);
@@ -8708,6 +8708,19 @@ TEST_F(FormatTest, AlignConsecutiveAssignments) {
" loooooooooooooooooooooongParameterB);\n"
"int j = 2;",
Alignment);
+
+ verifyFormat("template <typename T, typename T_0 = very_long_type_name_0,\n"
+ " typename B = very_long_type_name_1,\n"
+ " typename T_2 = very_long_type_name_2>\n"
+ "auto foo() {}\n",
+ Alignment);
+ verifyFormat("int a, b = 1;\n"
+ "int c = 2;\n"
+ "int dd = 3;\n",
+ Alignment);
+ verifyFormat("int aa = ((1 > 2) ? 3 : 4);\n"
+ "float b[1][] = {{3.f}};\n",
+ Alignment);
}
TEST_F(FormatTest, AlignConsecutiveDeclarations) {
@@ -8908,6 +8921,47 @@ TEST_F(FormatTest, AlignConsecutiveDeclarations) {
"int myvar = 1;",
Alignment);
Alignment.ColumnLimit = 80;
+ Alignment.AlignConsecutiveAssignments = false;
+
+ verifyFormat(
+ "template <typename LongTemplate, typename VeryLongTemplateTypeName,\n"
+ " typename LongType, typename B>\n"
+ "auto foo() {}\n",
+ Alignment);
+ verifyFormat("float a, b = 1;\n"
+ "int c = 2;\n"
+ "int dd = 3;\n",
+ Alignment);
+ verifyFormat("int aa = ((1 > 2) ? 3 : 4);\n"
+ "float b[1][] = {{3.f}};\n",
+ Alignment);
+ Alignment.AlignConsecutiveAssignments = true;
+ verifyFormat("float a, b = 1;\n"
+ "int c = 2;\n"
+ "int dd = 3;\n",
+ Alignment);
+ verifyFormat("int aa = ((1 > 2) ? 3 : 4);\n"
+ "float b[1][] = {{3.f}};\n",
+ Alignment);
+ Alignment.AlignConsecutiveAssignments = false;
+
+ Alignment.ColumnLimit = 30;
+ Alignment.BinPackParameters = false;
+ verifyFormat("void foo(float a,\n"
+ " float b,\n"
+ " int c,\n"
+ " uint32_t *d) {\n"
+ " int * e = 0;\n"
+ " float f = 0;\n"
+ " double g = 0;\n"
+ "}\n"
+ "void bar(ino_t a,\n"
+ " int b,\n"
+ " uint32_t *c,\n"
+ " bool d) {}\n",
+ Alignment);
+ Alignment.BinPackParameters = true;
+ Alignment.ColumnLimit = 80;
}
TEST_F(FormatTest, LinuxBraceBreaking) {
OpenPOWER on IntegriCloud