protected virtual object VisitZeroOrOneBlock(ZeroOrOneBlock block) { return Visit(block.InnerBlock); }
public void ParseTest7() { var parser = new RegexParser(); string pattern = "a?"; // Expected regular expression var aBlock = new TextBlock("a"); var zeroOrOneBlock = new ZeroOrOneBlock(aBlock); var groupBlock = new AndGroupBlock(new RegexBlock[] { zeroOrOneBlock }); var expected = new RegularExpression(groupBlock); var actual = parser.Parse(pattern); actual.ShouldBeEquivalentTo(expected, options => options.IncludingAllRuntimeProperties()); }
public IEnumerable<int> GetPositionsFromZeroOrOneBlock(int position, ZeroOrOneBlock block) { yield return position; foreach (var nextPosition in GetPositions(position, block.InnerBlock)) { yield return nextPosition; } }
public void GetPositionsFromZeroOrOneBlockTest() { int patternLength = 3; var pattern = new string('\0', patternLength); var builder = new Checker(pattern); var textBlock = new TextBlock("a"); var zeroOrOneBlock = new ZeroOrOneBlock(textBlock); var positions = builder.GetPositionsFromZeroOrOneBlock(0, zeroOrOneBlock).ToList(); CollectionAssert.AreEquivalent(new[] { 0, 1 }, positions); }
public void ParseTest7() { var parser = new RegexParser(); string pattern = "a?"; // Expected regular expression var aBlock = new TextBlock("a"); var zeroOrOneBlock = new ZeroOrOneBlock(aBlock); var groupBlock = new AndGroupBlock(new RegexBlock[] { zeroOrOneBlock }); var expected = new RegularExpression(groupBlock); var actual = parser.Parse(pattern); Assert.IsTrue(expected.Equals(actual), "Pattern was parsed incorrectly"); }
public void GetLinesFromZeroOrOneBlockTest() { int patternLength = 3; var pattern = new string('\0', patternLength); LineBuilder builder = new LineBuilder(pattern, null); string text = "a"; var textBlock = new TextBlock(text); var zeroOrOneBlock = new ZeroOrOneBlock(textBlock); List<string> lines = builder.GetLinesFromZeroOrOneBlock(0, zeroOrOneBlock).ToList(); string[] expectedLines = new[] { "", "a" }; CollectionAssert.AreEquivalent(expectedLines, lines); }