Skip to content

Commit 19b9704

Browse files
committed
Add skipped test for line ending handling in SA1107
1 parent b174ec2 commit 19b9704

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1107UnitTests.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
#nullable disable
5-
64
namespace StyleCop.Analyzers.Test.ReadabilityRules
75
{
86
using System.Threading;
97
using System.Threading.Tasks;
108
using Microsoft.CodeAnalysis.Testing;
119
using StyleCop.Analyzers.ReadabilityRules;
10+
using StyleCop.Analyzers.Test.Helpers;
1211
using Xunit;
1312
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
1413
StyleCop.Analyzers.ReadabilityRules.SA1107CodeMustNotContainMultipleStatementsOnOneLine,
@@ -49,34 +48,36 @@ public static void Foo(string a, string b)
4948
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
5049
}
5150

52-
[Fact]
53-
public async Task TestWrongCodeAsync()
51+
[Theory]
52+
[InlineData("\n", Skip = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3656")]
53+
[InlineData("\r\n")]
54+
public async Task TestWrongCodeAsync(string lineEnding)
5455
{
5556
string testCode = @"
5657
using System;
5758
class ClassName
5859
{
5960
public static void Foo(string a, string b)
6061
{
61-
int i = 5; int j = 6, k = 3; if(true)
62+
int i = 5; {|#0:int j = 6, k = 3;|} {|#1:if(true)
6263
{
6364
i++;
6465
}
6566
else
6667
{
6768
j++;
68-
} Foo(""a"", ""b"");
69+
}|} {|#2:Foo(""a"", ""b"");|}
6970
70-
Func<int, int, int> g = (c, d) => { c++; return c + d; };
71+
Func<int, int, int> g = (c, d) => { c++; {|#3:return c + d;|} };
7172
}
7273
}
73-
";
74+
".ReplaceLineEndings(lineEnding);
7475
var expected = new[]
7576
{
76-
Diagnostic().WithLocation(7, 20),
77-
Diagnostic().WithLocation(7, 38),
78-
Diagnostic().WithLocation(14, 11),
79-
Diagnostic().WithLocation(16, 50),
77+
Diagnostic().WithLocation(0),
78+
Diagnostic().WithLocation(1),
79+
Diagnostic().WithLocation(2),
80+
Diagnostic().WithLocation(3),
8081
};
8182

8283
string fixedCode = @"
@@ -102,7 +103,7 @@ public static void Foo(string a, string b)
102103
return c + d; };
103104
}
104105
}
105-
";
106+
".ReplaceLineEndings(lineEnding);
106107

107108
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
108109
}

0 commit comments

Comments
 (0)