public void SpanOnCommentGroupShouldStartAfter() { // Arrange var comment = new CommentGroupNode("This is a comment."); var a = new CharacterNode('a'); var b = new CharacterNode('b') { Prefix = comment }; var concat = new ConcatenationNode(new List <RegexNode> { a, b }); // Act var(commentStart, commentLength) = comment.GetSpan(); var(aStart, aLength) = a.GetSpan(); var(bStart, bLength) = b.GetSpan(); var(concatStart, concatLength) = concat.GetSpan(); // Assert concatStart.ShouldBe(0); concatLength.ShouldBe(a.ToString().Length + b.ToString().Length); aStart.ShouldBe(0); aLength.ShouldBe(1); commentStart.ShouldBe(1); commentLength.ShouldBe(comment.ToString().Length); bStart.ShouldBe(commentStart + commentLength); bLength.ShouldBe(1); }
public void ToStringShouldReturnCharAsString() { // Arrange var target = new CharacterNode('a'); // Act var result = target.ToString(); // Assert result.ShouldBe("a"); }
public void SpanShouldStartAfterChildNodes() { // Arrange var childNode = new CharacterNode('a'); var target = new QuantifierQuestionMarkNode(childNode); // Act var(Start, Length) = target.GetSpan(); // Assert Start.ShouldBe(childNode.ToString().Length); Length.ShouldBe(1); }
public void ToStringOnCharacterNodeWithPrefixShouldReturnPrefixBeforeCharacter() { // Arrange var comment = new CommentGroupNode("This is a comment."); var target = new CharacterNode('a') { Prefix = comment }; // Act var result = target.ToString(); // Assert result.ShouldBe("(?#This is a comment.)a"); }