diff options
author | Marek Kurdej <marek.kurdej+llvm.org@gmail.com> | 2022-03-07 18:48:24 +0100 |
---|---|---|
committer | Marek Kurdej <marek.kurdej+llvm.org@gmail.com> | 2022-03-08 13:35:26 +0100 |
commit | f537a409160dc1e506445724c5256bb116c0d71a (patch) | |
tree | 1b13e56a2b46d97fd98ccb2678129bd925317089 /clang/unittests/Format/FormatTestCSharp.cpp | |
parent | 7a54fceb256257e3f8c8bd16ffd55531d806c96e (diff) | |
download | llvm-f537a409160dc1e506445724c5256bb116c0d71a.zip llvm-f537a409160dc1e506445724c5256bb116c0d71a.tar.gz llvm-f537a409160dc1e506445724c5256bb116c0d71a.tar.bz2 |
[clang-format] Correctly detect `!` as TT_NonNullAssertion after `default`.
Fixes https://github.com/llvm/llvm-project/issues/53153.
Depends on D121132.
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D121136
Diffstat (limited to 'clang/unittests/Format/FormatTestCSharp.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestCSharp.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestCSharp.cpp b/clang/unittests/Format/FormatTestCSharp.cpp index 2a76420..aa0304f 100644 --- a/clang/unittests/Format/FormatTestCSharp.cpp +++ b/clang/unittests/Format/FormatTestCSharp.cpp @@ -1078,6 +1078,26 @@ public class SaleItem MicrosoftStyle); } +TEST_F(FormatTestCSharp, DefaultLiteral) { + FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp); + + verifyFormat( + "T[] InitializeArray<T>(int length, T initialValue = default) {}", Style); + verifyFormat("System.Numerics.Complex fillValue = default;", Style); + verifyFormat("int Value { get } = default;", Style); + verifyFormat("int Value { get } = default!;", Style); + verifyFormat(R"(// +public record Person { + public string GetInit { get; init; } = default!; +};)", + Style); + verifyFormat(R"(// +public record Person { + public string GetSet { get; set; } = default!; +};)", + Style); +} + TEST_F(FormatTestCSharp, CSharpSpaces) { FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp); Style.SpaceBeforeSquareBrackets = false; |