コード例 #1
0
        public void GetNdfaFromRegularExpressionShouldReturnListOfTransitions()
        {
            // arrange
            string formula = "*(|(.(a,b),a))";
            IRegularExpressionController regularExpressionController = new RegularExpressionController();

            // act
            RegularExpression regularExpression = regularExpressionController.GetNdfaFromRegularExpression(ref formula);

            // assert
            Assert.AreEqual(11, regularExpression.transitions.Count);
            Assert.IsTrue(regularExpression.final.isFinalState);
        }
コード例 #2
0
        public void GetNdfaFromRegularExpressionShouldUseOrRule()
        {
            // arrange
            string formula = "|(a,b)";
            IRegularExpressionController regularExpressionController = new RegularExpressionController();

            // act
            RegularExpression regularExpression = regularExpressionController.GetNdfaFromRegularExpression(ref formula);

            // assert
            Assert.IsTrue(regularExpression.transitions.Count == 6);
            Assert.IsTrue(regularExpression.transitions.Exists(_ => _.connectingLetter.data == 'a'));
            Assert.IsTrue(regularExpression.transitions.Exists(_ => _.connectingLetter.data == 'b'));
            Assert.IsTrue(regularExpression.final.isFinalState);
        }
コード例 #3
0
        public void GetNdfaFromRegularExpressionShouldUseStarRule()
        {
            // arrange
            string formula = "*(a)";
            IRegularExpressionController regularExpressionController = new RegularExpressionController();

            // act
            RegularExpression regularExpression = regularExpressionController.GetNdfaFromRegularExpression(ref formula);

            // assert
            Assert.IsTrue(regularExpression.transitions.Count == 5);
            Assert.IsTrue(regularExpression.transitions.Exists(_ => _.connectingLetter.data == 'a'));
            Assert.IsTrue(regularExpression.final.isFinalState);
            Assert.AreEqual(4, regularExpression.transitions.FindAll(_ => _.connectingLetter.data == '_').Count);
        }
コード例 #4
0
        public void GetNdfaFromRegularExpressionShouldUseLetterRule()
        {
            // arrange
            string formula = "a";
            IRegularExpressionController regularExpressionController = new RegularExpressionController();

            // act
            RegularExpression regularExpression = regularExpressionController.GetNdfaFromRegularExpression(ref formula);

            // assert
            Assert.AreEqual(1, regularExpression.transitions.Count);
            Assert.IsTrue(regularExpression.initial.data == "S0");
            Assert.IsTrue(regularExpression.final.data == "S1");
            Assert.IsTrue(regularExpression.final.isFinalState);
        }