Skip to content

Commit ad8516a

Browse files
committed
Update SA1001 tests for function pointers
1 parent 8ca93fe commit ad8516a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1001CSharp9UnitTests.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,43 @@
33

44
namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules
55
{
6+
using System.Threading;
7+
using System.Threading.Tasks;
68
using StyleCop.Analyzers.Test.CSharp8.SpacingRules;
9+
using Xunit;
10+
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12+
StyleCop.Analyzers.SpacingRules.SA1001CommasMustBeSpacedCorrectly,
13+
StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>;
714

815
public partial class SA1001CSharp9UnitTests : SA1001CSharp8UnitTests
916
{
17+
[Fact]
18+
[WorkItem(3970, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3970")]
19+
public async Task TestFunctionPointerParameterSpacingAsync()
20+
{
21+
var testCode = @"public class TestClass
22+
{
23+
private unsafe delegate*<int{|#0:,|}int, void> field1;
24+
private unsafe delegate*<int {|#1:,|}int, void> field2;
25+
}
26+
";
27+
28+
var fixedCode = @"public class TestClass
29+
{
30+
private unsafe delegate*<int, int, void> field1;
31+
private unsafe delegate*<int, int, void> field2;
32+
}
33+
";
34+
35+
var expected = new[]
36+
{
37+
Diagnostic().WithLocation(0).WithArguments(string.Empty, "followed"),
38+
Diagnostic().WithLocation(1).WithArguments(" not", "preceded"),
39+
Diagnostic().WithLocation(1).WithArguments(string.Empty, "followed"),
40+
};
41+
42+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
43+
}
1044
}
1145
}

0 commit comments

Comments
 (0)