GParse/source/GParseTests/DelimitedTextParserTests.cs
2025-03-21 00:43:59 -06:00

27 lines
719 B
C#

namespace GParseTests;
public class DelimitedTextParserTests
{
[Fact]
public void CanConstruct()
{
_ = new DelimitedTextParser("|");
}
[Theory]
[InlineData("", new string[] { "" })]
[InlineData("1", new string[] { "1" })]
[InlineData("1,2", new string[] { "1", "2" })]
[InlineData(",", new string[] { "", "" })]
[InlineData(",,", new string[] { "", "", "" })]
[InlineData("1,", new string[] { "1", "" })]
[InlineData(",1", new string[] { "", "1" })]
public void VarietyTests(string inputText, IEnumerable<string> expected)
{
const string delimiter = ",";
var parser = new DelimitedTextParser(delimiter);
IEnumerable<string> actual = parser.Parse(inputText);
actual.ShouldBe(expected);
}
}