예제 #1
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')));
        }
예제 #2
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')));
        }
예제 #3
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')));
        }
예제 #4
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')))));
        }