Skip to content

Commit fcb0b15

Browse files
committed
Added tests to improve coverage in SA1012 (OpeningCurlyBracketsMustBeSpacedCorrectly)
1 parent 1b36063 commit fcb0b15

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1012UnitTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,33 @@ public void TestMethod()
221221
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
222222
}
223223

224+
[Fact]
225+
public async Task TestMissingTokenAsync()
226+
{
227+
string testCode = @"
228+
class ClassName
229+
{
230+
void Method()
231+
{
232+
int[] x = new[] 0 };
233+
}
234+
}
235+
";
236+
237+
DiagnosticResult[] expected =
238+
{
239+
new DiagnosticResult
240+
{
241+
Id = "CS1514",
242+
Severity = DiagnosticSeverity.Error,
243+
Message = "{ expected",
244+
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 6, 25) }
245+
}
246+
};
247+
248+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
249+
}
250+
224251
/// <inheritdoc/>
225252
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
226253
{

0 commit comments

Comments
 (0)