# Changeset View

Changeset View

# Standalone View

Standalone View

# unittests/Format/FormatTest.cpp

- This file is larger than 256 KB, so syntax highlighting is disabled by default.

Show First 20 Lines • Show All 4020 Lines • ▼ Show 20 Line(s) | 4006 | TEST_F(FormatTest, AlignsAfterReturn) { | |||
---|---|---|---|---|---|

4021 | verifyFormat("return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" | 4021 | verifyFormat("return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" | ||

4022 | " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) &&\n" | 4022 | " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) &&\n" | ||

4023 | " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;"); | 4023 | " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;"); | ||

4024 | verifyFormat("return\n" | 4024 | verifyFormat("return\n" | ||

4025 | " // true if code is one of a or b.\n" | 4025 | " // true if code is one of a or b.\n" | ||

4026 | " code == a || code == b;"); | 4026 | " code == a || code == b;"); | ||

4027 | } | 4027 | } | ||

4028 | 4028 | | |||

4029 | TEST_F(FormatTest, AlignsAfterOpenBracket) { | ||||

4030 | verifyFormat( | ||||

4031 | "void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaa aaaaaaaa,\n" | ||||

4032 | " aaaaaaaaa aaaaaaa) {}"); | ||||

4033 | verifyFormat( | ||||

4034 | "SomeLongVariableName->someVeryLongFunctionName(aaaaaaaaaaa aaaaaaaaa,\n" | ||||

4035 | " aaaaaaaaaaa aaaaaaaaa);"); | ||||

4036 | verifyFormat( | ||||

4037 | "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n" | ||||

4038 | " aaaaaaaaaaaaaaaaaaaaa));"); | ||||

4039 | FormatStyle Style = getLLVMStyle(); | ||||

4040 | Style.AlignAfterOpenBracket = false; | ||||

4041 | verifyFormat( | ||||

4042 | "void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaa aaaaaaaa,\n" | ||||

4043 | " aaaaaaaaa aaaaaaa) {}", | ||||

4044 | Style); | ||||

4045 | verifyFormat( | ||||

4046 | "SomeLongVariableName->someVeryLongFunctionName(aaaaaaaaaaa aaaaaaaaa,\n" | ||||

4047 | " aaaaaaaaaaa aaaaaaaaa);", | ||||

4048 | Style); | ||||

4049 | verifyFormat( | ||||

4050 | "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n" | ||||

4051 | " aaaaaaaaaaaaaaaaaaaaa));", | ||||

4052 | Style); | ||||

4053 | } | ||||

4054 | | ||||

4029 | TEST_F(FormatTest, BreaksConditionalExpressions) { | 4055 | TEST_F(FormatTest, BreaksConditionalExpressions) { | ||

4030 | verifyFormat( | 4056 | verifyFormat( | ||

4031 | "aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa\n" | 4057 | "aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa\n" | ||

4032 | " ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" | 4058 | " ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" | ||

4033 | " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); | 4059 | " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); | ||

4034 | verifyFormat( | 4060 | verifyFormat( | ||

4035 | "aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" | 4061 | "aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" | ||

4036 | " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); | 4062 | " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); | ||

▲ Show 20 Lines • Show All 5044 Lines • ▼ Show 20 Line(s) | 9063 | TEST_F(FormatTest, FormatsWithWebKitStyle) { | |||

9081 | // Allow functions on a single line. | 9107 | // Allow functions on a single line. | ||

9082 | verifyFormat("void f() { return; }", Style); | 9108 | verifyFormat("void f() { return; }", Style); | ||

9083 | 9109 | | |||

9084 | // Constructor initializers are formatted one per line with the "," on the | 9110 | // Constructor initializers are formatted one per line with the "," on the | ||

9085 | // new line. | 9111 | // new line. | ||

9086 | verifyFormat("Constructor()\n" | 9112 | verifyFormat("Constructor()\n" | ||

9087 | " : aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" | 9113 | " : aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" | ||

9088 | " , aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa, // break\n" | 9114 | " , aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa, // break\n" | ||

9089 | " aaaaaaaaaaaaaa)\n" | 9115 | " aaaaaaaaaaaaaa)\n" | ||

9090 | " , aaaaaaaaaaaaaaaaaaaaaaa()\n" | 9116 | " , aaaaaaaaaaaaaaaaaaaaaaa()\n" | ||

9091 | "{\n" | 9117 | "{\n" | ||

9092 | "}", | 9118 | "}", | ||

9093 | Style); | 9119 | Style); | ||

9094 | verifyFormat("SomeClass::Constructor()\n" | 9120 | verifyFormat("SomeClass::Constructor()\n" | ||

9095 | " : a(a)\n" | 9121 | " : a(a)\n" | ||

9096 | "{\n" | 9122 | "{\n" | ||

9097 | "}", | 9123 | "}", | ||

▲ Show 20 Lines • Show All 501 Lines • Show Last 20 Lines |