Пример #1
0
        public void Parse_WithPlus_ReturnsExpectedTree()
        {
            // Arrange
            var pattern = "a+";

            // Act
            var regex = Regex.Parse(pattern);

            // Assert
            regex.Tree.AssertRequiredRepeating(
                TreeAssert.Char('a'));
        }
Пример #2
0
        public void Parse_WithStar_ReturnsExpectedTree()
        {
            // Arrange
            var pattern = "a*";

            // Act
            var regex = Regex.Parse(pattern);

            // Assert
            regex.Tree.AssertOptionalRepeating(
                TreeAssert.Char('a'));
        }
Пример #3
0
        public void Parse_WithQuestion_ReturnsExpectedTree()
        {
            // Arrange
            var pattern = "a?";

            // Act
            var regex = Regex.Parse(pattern);

            // Assert
            regex.Tree.AssertOptional(
                TreeAssert.Char('a'));
        }
Пример #4
0
        public void Parse_WithAlternatives_ReturnsExpectedTree()
        {
            // Arrange
            var pattern = "a|b";

            // Act
            var regex = Regex.Parse(pattern);

            // Assert
            regex.Tree.AssertAlternative(
                TreeAssert.Char('a'),
                TreeAssert.Char('b'));
        }
Пример #5
0
        public void Parse_WithPlusInConcatination_ReturnsExpectedTree()
        {
            // Arrange
            var pattern = "ab+c";

            // Act
            var regex = Regex.Parse(pattern);

            // Assert
            regex.Tree.AssertConcatenation(
                TreeAssert.Char('a'),
                TreeAssert.Concat(
                    TreeAssert.Plus(
                        TreeAssert.Char('b')),
                    TreeAssert.Char('c')));
        }
Пример #6
0
        public void Parse_WithNestedAlternativeGroups_ReturnsExpectedTree()
        {
            // Arrange
            var pattern = "(a|b)(c|d)";

            // Act
            var regex = Regex.Parse(pattern);

            // Assert
            regex.Tree.AssertConcatenation(
                TreeAssert.Alt(
                    TreeAssert.Char('a'),
                    TreeAssert.Char('b')),
                TreeAssert.Alt(
                    TreeAssert.Char('c'),
                    TreeAssert.Char('d')));
        }
Пример #7
0
        public void Parse_WithGroupedAlternativesInConcatination_ReturnsExpectedTree()
        {
            // Arrange
            var pattern = "a(b|c)d";

            // Act
            var regex = Regex.Parse(pattern);

            // Assert
            regex.Tree.AssertConcatenation(
                TreeAssert.Char('a'),
                TreeAssert.Concat(
                    TreeAssert.Alt(
                        TreeAssert.Char('b'),
                        TreeAssert.Char('c')),
                    TreeAssert.Char('d')));
        }
Пример #8
0
        public void Parse_WithConcatinatedAlternatives_ReturnsExpectedTree()
        {
            // Arrange
            var pattern = "ab|cd";

            // Act
            var regex = Regex.Parse(pattern);

            // Assert
            regex.Tree.AssertAlternative(
                TreeAssert.Concat(
                    TreeAssert.Char('a'),
                    TreeAssert.Char('b')),
                TreeAssert.Concat(
                    TreeAssert.Char('c'),
                    TreeAssert.Char('d')));
        }
Пример #9
0
        public void Parse_WithMultipleChars_ReturnsExpectedTree()
        {
            // Arrange
            var pattern = "abcde";

            // Act
            var regex = Regex.Parse(pattern);

            // Assert
            regex.Tree.AssertConcatenation(
                TreeAssert.Char('a'),
                TreeAssert.Concat(
                    TreeAssert.Char('b'),
                    TreeAssert.Concat(
                        TreeAssert.Char('c'),
                        TreeAssert.Concat(
                            TreeAssert.Char('d'),
                            TreeAssert.Char('e')))));
        }