Beispiel #1
0
        public void MovingTapeLeftBringsBlankCellIntoView()
        {
            Tape tape = new Tape();

            tape.Write('a');
            tape.MoveLeft();

            Assert.AreEqual(' ', tape.Read());
        }
Beispiel #2
0
        public void GetIndexReturnsCurrentTapeIndex()
        {
            Tape tape = new Tape();

            tape.MoveRight();
            Assert.AreEqual(1, tape.GetIndex());
            tape.MoveLeft();
            Assert.AreEqual(0, tape.GetIndex());
        }
Beispiel #3
0
        public void MovingTapeLeftThenRightReturnsTapeToOriginalPosition()
        {
            Tape tape = new Tape();

            char symbol = 'a';

            tape.Write(symbol);
            tape.MoveLeft();
            tape.MoveRight();

            Assert.AreEqual(symbol, tape.Read());
        }
Beispiel #4
0
        public void TapeStoresAllWrittenSymbolsAsItMovesRight()
        {
            Tape tape = new Tape();

            List<char> symbols = new List<char>() { 'a', 'b', 'c', 'd' };

            for(int symbolIndex = 0; symbolIndex < symbols.Count; ++symbolIndex)
            {
                tape.Write(symbols[symbolIndex]);
                tape.MoveRight();
            }

            for (int symbolIndex = symbols.Count - 1; symbolIndex >= 0; --symbolIndex)
            {
                tape.MoveLeft();
                Assert.AreEqual(symbols[symbolIndex], tape.Read());
            }
        }