Ejemplo n.º 1
0
        public void ToStringOnNegatedCharacterClassNodeWithCharacterSetShouldReturnCharactersBetweenBrackets()
        {
            // Arrange
            var characterSet = new CharacterClassCharacterSetNode(new List <RegexNode> {
                new CharacterNode('a'), new CharacterNode('b'), new CharacterNode('c')
            });
            var target = new CharacterClassNode(characterSet, true);

            // Act
            var result = target.ToString();

            // Assert
            result.ShouldBe("[^abc]");
        }
Ejemplo n.º 2
0
        public void ToStringOnCharacterClassNodeWithSubtractionSubtractionBetweenBrackets()
        {
            // Arrange
            var subtractionCharacterSet = new CharacterClassCharacterSetNode(new CharacterNode('a'));
            var subtraction             = new CharacterClassNode(subtractionCharacterSet, false);
            var characterSet            = new CharacterClassCharacterSetNode(new List <RegexNode> {
                new CharacterNode('a'), new CharacterNode('b'), new CharacterNode('c')
            });
            var target = new CharacterClassNode(characterSet, subtraction, false);

            // Act
            var result = target.ToString();

            // Assert
            result.ShouldBe("[abc-[a]]");
        }
Ejemplo n.º 3
0
        public void ToStringOnCharacterClassNodeWithPrefixShouldReturnPrefixBeforeCharacterClass()
        {
            // Arrange
            var comment      = new CommentGroupNode("This is a comment.");
            var characterSet = new CharacterClassCharacterSetNode(new List <RegexNode> {
                new CharacterNode('a'), new CharacterNode('b'), new CharacterNode('c')
            });
            var target = new CharacterClassNode(characterSet, false)
            {
                Prefix = comment
            };

            // Act
            var result = target.ToString();

            // Assert
            result.ShouldBe("(?#This is a comment.)[abc]");
        }