Skip to content

Commit a2540cb

Browse files
authored
fix empty line scrubbing (#549)
1 parent 8d31c58 commit a2540cb

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

docs/scrubbers.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ public class ScrubbersSample
162162
");
163163
}
164164

165+
[Fact]
166+
public Task EmptyLine()
167+
{
168+
var settings = new VerifySettings();
169+
settings.ScrubLinesWithReplace(
170+
replaceLine: line =>
171+
{
172+
return "";
173+
});
174+
return Verify(
175+
settings: settings,
176+
target: @"");
177+
}
178+
165179
[Fact]
166180
public Task LinesFluent() =>
167181
Verify(
@@ -246,7 +260,7 @@ public class ScrubbersSample
246260
.ScrubEmptyLines();
247261
}
248262
```
249-
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.cs#L1-L121' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberssamplexunit' title='Start of snippet'>anchor</a></sup>
263+
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.cs#L1-L135' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberssamplexunit' title='Start of snippet'>anchor</a></sup>
250264
<!-- endSnippet -->
251265

252266

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<PropertyGroup>
44
<NoWarn>CS1591;CS0649;xUnit1026;xUnit1013;msb3277;CS0436</NoWarn>
5-
<Version>17.1.4</Version>
5+
<Version>17.1.5</Version>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<LangVersion>10</LangVersion>
88
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ public Task Lines()
3434
");
3535
}
3636

37+
[Fact]
38+
public Task EmptyLine()
39+
{
40+
var settings = new VerifySettings();
41+
settings.ScrubLinesWithReplace(
42+
replaceLine: line =>
43+
{
44+
return "";
45+
});
46+
return Verify(
47+
settings: settings,
48+
target: @"");
49+
}
50+
3751
[Fact]
3852
public Task LinesFluent() =>
3953
Verify(

src/Verify/Serialization/Scrubbers/LinesScrubber.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public static void ReplaceLines(this StringBuilder input, Func<string, string?>
2121
}
2222
}
2323

24-
if (!theString.EndsWith("\n"))
24+
if (theString.Length > 0 &&
25+
!theString.EndsWith("\n"))
2526
{
2627
input.Length -= 1;
2728
}

0 commit comments

Comments
 (0)