Skip to content

Commit 0a0fa20

Browse files
committed
Add extra test to ensure mixed line-end styles are handled correctly
1 parent e30e5a6 commit 0a0fa20

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace CommandLine.Tests.Fakes
2+
{
3+
public class HelpTextWithMixedLineBreaks_Options
4+
{
5+
[Option(HelpText =
6+
"This is a help text description\n It has multiple lines.\r\n Third line")]
7+
public string StringValue { get; set; }
8+
}
9+
}

tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,5 +718,24 @@ public void HelpTextPreservesIndentationAcrossWordWrap()
718718
}
719719

720720

721+
[Fact]
722+
public void HelpTextIsConsitentRegardlessOfCompileTimeLineStyle()
723+
{
724+
// Fixture setup
725+
// Exercize system
726+
var sut = new HelpText {AddDashesToOption = true}
727+
.AddOptions(new NotParsed<Simple_Options>(TypeInfo.Create(typeof(HelpTextWithMixedLineBreaks_Options)),
728+
Enumerable.Empty<Error>()));
729+
730+
// Verify outcome
731+
732+
var lines = sut.ToString().ToNotEmptyLines();
733+
lines[0].Should().BeEquivalentTo(" --stringvalue This is a help text description");
734+
lines[1].Should().BeEquivalentTo(" It has multiple lines.");
735+
lines[2].Should().BeEquivalentTo(" Third line");
736+
737+
// Teardown
738+
}
739+
721740
}
722741
}

0 commit comments

Comments
 (0)