Exemple #1
0
        public void TestAutomataAFD()
        {
            Automata <int, char> testAutomata = GenerateTestAutomataAFN();

            List <char> transictionList = new List <char>(new char[] { 'a', 'b', 'e' });

            testAutomata = Automata <int, char> .AFNtoAFD(testAutomata, transictionList, 'e');

            State <int, char> state0 = testAutomata.InitialState;

            Assert.AreEqual(0, state0.StateValue, "Valor do estado 0 diferente de 0, valor = " + state0.StateValue);

            State <int, char> stateAux = state0.Transictions[0].NextState;

            Assert.AreEqual(2, stateAux.StateValue, "Valor do estado 2 diferente de 2, valor = " + stateAux.StateValue);
            Assert.AreEqual(2, stateAux.Transictions.Count, "Valor do estado 2 diferente de 2, valor = " + stateAux.StateValue);

            stateAux = stateAux.Transictions[0].NextState;
            Assert.AreEqual(3, stateAux.StateValue, "Valor do estado 3 diferente de 3, valor = " + stateAux.StateValue);
            Assert.AreEqual(1, stateAux.Transictions.Count, "Valor do estado 1 diferente de 1, valor = " + stateAux.StateValue);

            stateAux = stateAux.Transictions[0].NextState;
            Assert.AreEqual(4, stateAux.StateValue, "Valor do estado 4 diferente de 4, valor = " + stateAux.StateValue);
            Assert.IsTrue(stateAux.IsFinal, "Estado 4 não é final!");

            GrammarDeterministicAutomata automata = new GrammarDeterministicAutomata();

            Assert.IsNotNull(automata, "Automato determinístico retornou nulo");

            //TODO mais testes
        }