diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs
index 20586344b..508d12ef9 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs
@@ -232,6 +232,25 @@ public async Task TestLambdaExpressionWithNoSpaceAfterClosingParenthesisAsync()
await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false);
}
+ ///
+ /// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#255 and
+ /// DotNetAnalyzers/StyleCopAnalyzers#256.
+ ///
+ /// The operator to test.
+ /// A representing the asynchronous operation.
+ [Theory]
+ [InlineData("+")]
+ [InlineData("-")]
+ public async Task TestNotReportedWhenFollowedByUnaryPlusOrMinusAsync(string operatorToken)
+ {
+ // This will be reported as SA1021 or SA1022
+ var ignoredStatement = $"var i = (int) {operatorToken}2;";
+ var correctStatement = $"var i = (int){operatorToken}2;";
+
+ await this.TestWhitespaceInStatementOrDeclAsync(ignoredStatement, string.Empty, EmptyDiagnosticResults).ConfigureAwait(false);
+ await this.TestWhitespaceInStatementOrDeclAsync(correctStatement, string.Empty, EmptyDiagnosticResults).ConfigureAwait(false);
+ }
+
[Fact]
public async Task TestSpaceBeforeParenthisInIncrementingForLoopAsync()
{