diff options
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; |