From 9e709351c5b09f7d644e1ea4ac8ae4b37df8290c Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 26 Nov 2014 10:43:58 +0000 Subject: clang-format: Add SFS_Empty to only empty functions on a single line. Activated for and tested by Google's Java style. This fixes llvm.org/PR21667. llvm-svn: 222819 --- clang/unittests/Format/FormatTestJava.cpp | 58 ++++++++++++------------------- 1 file changed, 23 insertions(+), 35 deletions(-) (limited to 'clang/unittests/Format/FormatTestJava.cpp') diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp index 47e219b..946ae32 100644 --- a/clang/unittests/Format/FormatTestJava.cpp +++ b/clang/unittests/Format/FormatTestJava.cpp @@ -105,13 +105,11 @@ TEST_F(FormatTestJava, ClassDeclarations) { getStyleWithColumns(60)); verifyFormat("@SomeAnnotation()\n" "abstract class aaaaaaaaaaaa\n" - " extends bbbbbbbbbbbbbbb implements cccccccccccc {\n" - "}", + " extends bbbbbbbbbbbbbbb implements cccccccccccc {}", getStyleWithColumns(76)); verifyFormat("@SomeAnnotation()\n" "abstract class aaaaaaaaa\n" - " extends bbbbbbbbbbbb implements cccccccccccc {\n" - "}", + " extends bbbbbbbbbbbb implements cccccccccccc {}", getStyleWithColumns(76)); verifyFormat("interface SomeInterface extends Foo, Bar {\n" " void doStuff(int theStuff);\n" @@ -139,31 +137,26 @@ TEST_F(FormatTestJava, EnumDeclarations) { "}"); verifyFormat("public class SomeClass {\n" " enum SomeThing { ABC, CDE }\n" - " void f() {\n" - " }\n" + " void f() {}\n" "}"); verifyFormat("public class SomeClass implements SomeInterface {\n" " enum SomeThing { ABC, CDE }\n" - " void f() {\n" - " }\n" + " void f() {}\n" "}"); verifyFormat("enum SomeThing {\n" " ABC,\n" " CDE;\n" - " void f() {\n" - " }\n" + " void f() {}\n" "}"); verifyFormat("enum SomeThing {\n" " ABC(1, \"ABC\"),\n" " CDE(2, \"CDE\");\n" - " Something(int i, String s) {\n" - " }\n" + " Something(int i, String s) {}\n" "}"); verifyFormat("enum SomeThing {\n" " ABC(new int[] {1, 2}),\n" " CDE(new int[] {2, 3});\n" - " Something(int[] i) {\n" - " }\n" + " Something(int[] i) {}\n" "}"); verifyFormat("public enum SomeThing {\n" " ABC {\n" @@ -177,8 +170,7 @@ TEST_F(FormatTestJava, EnumDeclarations) { " return \"CDE\";\n" " }\n" " };\n" - " public void f() {\n" - " }\n" + " public void f() {}\n" "}"); verifyFormat("private enum SomeEnum implements Foo {\n" " ABC {\n" @@ -205,30 +197,28 @@ TEST_F(FormatTestJava, ArrayInitializers) { TEST_F(FormatTestJava, ThrowsDeclarations) { verifyFormat("public void doSooooooooooooooooooooooooooomething()\n" - " throws LooooooooooooooooooooooooooooongException {\n}"); + " throws LooooooooooooooooooooooooooooongException {}"); } TEST_F(FormatTestJava, Annotations) { verifyFormat("@Override\n" - "public String toString() {\n}"); + "public String toString() {}"); verifyFormat("@Override\n" "@Nullable\n" - "public String getNameIfPresent() {\n}"); + "public String getNameIfPresent() {}"); verifyFormat("@SuppressWarnings(value = \"unchecked\")\n" - "public void doSomething() {\n}"); + "public void doSomething() {}"); verifyFormat("@SuppressWarnings(value = \"unchecked\")\n" "@Author(name = \"abc\")\n" - "public void doSomething() {\n}"); + "public void doSomething() {}"); verifyFormat("DoSomething(new A() {\n" " @Override\n" - " public String toString() {\n" - " }\n" + " public String toString() {}\n" "});"); - verifyFormat("void SomeFunction(@Nullable String something) {\n" - "}"); + verifyFormat("void SomeFunction(@Nullable String something) {}"); verifyFormat("@Partial @Mock DataLoader loader;"); verifyFormat("@SuppressWarnings(value = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")\n" @@ -246,13 +236,13 @@ TEST_F(FormatTestJava, Generics) { verifyFormat("A.doSomething();"); verifyFormat("@Override\n" - "public Map getAll() {\n}"); + "public Map getAll() {}"); - verifyFormat("public ArrayList get() {\n}"); - verifyFormat("protected ArrayList get() {\n}"); - verifyFormat("private ArrayList get() {\n}"); - verifyFormat("public static ArrayList get() {\n}"); - verifyFormat("public final Foo foo() {\n}"); + verifyFormat("public ArrayList get() {}"); + verifyFormat("protected ArrayList get() {}"); + verifyFormat("private ArrayList get() {}"); + verifyFormat("public static ArrayList get() {}"); + verifyFormat("public final Foo foo() {}"); verifyFormat("public abstract Foo foo();"); verifyFormat(" T getInstance(Class type);"); verifyFormat("Function function;"); @@ -312,12 +302,10 @@ TEST_F(FormatTestJava, ImportDeclarations) { TEST_F(FormatTestJava, MethodDeclarations) { verifyFormat("void methodName(Object arg1,\n" - " Object arg2, Object arg3) {\n" - "}", + " Object arg2, Object arg3) {}", getStyleWithColumns(40)); verifyFormat("void methodName(\n" - " Object arg1, Object arg2) {\n" - "}", + " Object arg1, Object arg2) {}", getStyleWithColumns(40)); } -- cgit v1.1