예제 #1
0
        public void ParseDefinition_CheckThatElementsAreLengthOne()
        {
            List<string> definition = new List<string>()
            {
                "ab",
                "TAPE_ALPHABET:"
            };

            InputAlphabet test_inputalphabet = new InputAlphabet();

            Assert.IsFalse(test_inputalphabet.load(ref definition), "Failed to detect improper length of input alphabet element.");
        }
예제 #2
0
        public void ParseDefinition_CheckForDuplicateInputAlphabetCharacters()
        {
            List<string> definition = new List<string>()
            {
                "a a",
                "TAPE_ALPHABET:"
            };

            InputAlphabet test_inputalphabet = new InputAlphabet();

            Assert.IsFalse(test_inputalphabet.load(ref definition), "Failed to detect duplicate input alphabet characters.");
        }
예제 #3
0
        public void ParseDefinition_TransFunct_InvalidChar()
        {
            List<string> definition = new List<string>() 
            {
                "description stuff1",
                "description stuff2",
                "STATES: S1 S2 S3 S4",
                "INPUT_ALPHABET: a b",
                "TAPE_ALPHABET: a b x y -",
                "TRANSITION_FUNCTION:",
                "s0 a   s1 X R",
                "s0 Y   s3 Y R",
                "s1 a   s1 a R",
                "s1 b   s2 Y L",
                "s1 Y   s1 Y R", 
                "s2 a   s2 a L",
                "s2 X   s0 X R",
                "s2 Y   s2 Y L",
                "s3 Y   s3 Y R",
                "s3 -   s4 - R",
                "INITIAL_STATE: s0",
                "BLANK_CHARACTER: -",
                "FINAL_STATES: s4"
            };
            Tape tape = new Tape();
            FinalStates final_states = new FinalStates();
            InputAlphabet input_alphabet = new InputAlphabet();
            States states = new States();
            TapeAlphabet tape_alphabet = new TapeAlphabet();
            TransitionFunction transition_function = new TransitionFunction();
            TuringMachine tm = new TuringMachine("");

            Assert.IsTrue(tm.parseDescription(ref definition), "Failed to parse description");
            Assert.IsTrue(states.load(ref definition), "Failed to parse states.");
            Assert.IsTrue(input_alphabet.load(ref definition), "Failed to parse input alphabet");
            Assert.IsTrue(tape_alphabet.load(ref definition), "Failed to parse tape alphabet");
            Assert.IsFalse(transition_function.load(ref definition), "Should not accept transition with a state not in STATES:");

        }