Skip to content

Commit b8d237b

Browse files
committed
Add back a proper integration test for #255 and #256
1 parent a77cb7e commit b8d237b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,25 @@ public async Task TestLambdaExpressionWithNoSpaceAfterClosingParenthesisAsync()
232232
await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false);
233233
}
234234

235+
/// <summary>
236+
/// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#255 and
237+
/// DotNetAnalyzers/StyleCopAnalyzers#256.
238+
/// </summary>
239+
/// <param name="operatorToken">The operator to test.</param>
240+
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
241+
[Theory]
242+
[InlineData("+")]
243+
[InlineData("-")]
244+
public async Task TestNotReportedWhenFollowedByUnaryPlusOrMinusAsync(string operatorToken)
245+
{
246+
// This will be reported as SA1021 or SA1022
247+
var ignoredStatement = $"var i = (int) {operatorToken}2;";
248+
var correctStatement = $"var i = (int){operatorToken}2;";
249+
250+
await this.TestWhitespaceInStatementOrDeclAsync(ignoredStatement, string.Empty, EmptyDiagnosticResults).ConfigureAwait(false);
251+
await this.TestWhitespaceInStatementOrDeclAsync(correctStatement, string.Empty, EmptyDiagnosticResults).ConfigureAwait(false);
252+
}
253+
235254
[Fact]
236255
public async Task TestSpaceBeforeParenthisInIncrementingForLoopAsync()
237256
{

0 commit comments

Comments
 (0)