diff options
author | mydeveloperday <mydeveloperday@gmail.com> | 2021-01-17 11:13:50 +0000 |
---|---|---|
committer | mydeveloperday <mydeveloperday@gmail.com> | 2021-01-17 11:14:33 +0000 |
commit | 00dc97f16708aad67834552285c0af01b37303d6 (patch) | |
tree | 704918c3091cba34a03f53bacbee3c8b20af7a4a /clang/unittests/Format/FormatTestCSharp.cpp | |
parent | e7bc6c594b75602c23cb901f53b3a30d48e2ee78 (diff) | |
download | llvm-00dc97f16708aad67834552285c0af01b37303d6.zip llvm-00dc97f16708aad67834552285c0af01b37303d6.tar.gz llvm-00dc97f16708aad67834552285c0af01b37303d6.tar.bz2 |
[clang-format] PR48594 BraceWrapping: SplitEmptyRecord ignored for templates
https://bugs.llvm.org/show_bug.cgi?id=48594
Empty or small templates were not being treated the same way as small classes especially when SplitEmptyRecord was set to true
This revision aims to help this by identifying a case when we should try not to merge the lines together
Reviewed By: curdeius, JohelEGP
Differential Revision: https://reviews.llvm.org/D93839
Diffstat (limited to 'clang/unittests/Format/FormatTestCSharp.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestCSharp.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/clang/unittests/Format/FormatTestCSharp.cpp b/clang/unittests/Format/FormatTestCSharp.cpp index b5c6f05..51617aa 100644 --- a/clang/unittests/Format/FormatTestCSharp.cpp +++ b/clang/unittests/Format/FormatTestCSharp.cpp @@ -835,25 +835,27 @@ if (someThings[i][j][k].Contains(myThing)) { TEST_F(FormatTestCSharp, CSharpGenericTypeConstraints) { FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp); - verifyFormat(R"(// -class ItemFactory<T> - where T : new() {})", + EXPECT_TRUE(Style.BraceWrapping.SplitEmptyRecord); + + verifyFormat("class ItemFactory<T>\n" + " where T : new() {\n" + "}", Style); - verifyFormat(R"(// -class Dictionary<TKey, TVal> - where TKey : IComparable<TKey> - where TVal : IMyInterface { - public void MyMethod<T>(T t) - where T : IMyInterface { - doThing(); - } -})", + verifyFormat("class Dictionary<TKey, TVal>\n" + " where TKey : IComparable<TKey>\n" + " where TVal : IMyInterface {\n" + " public void MyMethod<T>(T t)\n" + " where T : IMyInterface {\n" + " doThing();\n" + " }\n" + "}", Style); - verifyFormat(R"(// -class ItemFactory<T> - where T : new(), IAnInterface<T>, IAnotherInterface<T>, IAnotherInterfaceStill<T> {})", + verifyFormat("class ItemFactory<T>\n" + " where T : new(), IAnInterface<T>, IAnotherInterface<T>, " + "IAnotherInterfaceStill<T> {\n" + "}", Style); Style.ColumnLimit = 50; // Force lines to be wrapped. @@ -862,7 +864,8 @@ class ItemFactory<T, U> where T : new(), IAnInterface<T>, IAnotherInterface<T, U>, - IAnotherInterfaceStill<T, U> {})", + IAnotherInterfaceStill<T, U> { +})", Style); // In other languages `where` can be used as a normal identifier. |