public void MovingTapeRightBringsBlankCellIntoView() { Tape tape = new Tape(); tape.Write('a'); tape.MoveRight(); Assert.AreEqual(' ', tape.Read()); }
public void MovingTapeLeftThenRightReturnsTapeToOriginalPosition() { Tape tape = new Tape(); char symbol = 'a'; tape.Write(symbol); tape.MoveLeft(); tape.MoveRight(); Assert.AreEqual(symbol, tape.Read()); }
public void TapeCanBeInitialisedWithHeadBeforeInitialisedCellsAndWrittenTo() { Tape tape = new Tape("a,b\n-1"); tape.Write('c'); Assert.AreEqual('c', tape.Read()); }
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()); } }
public void TapeCanBeInitialisedWithHeadAfterInitialisedCellsAndRead() { Tape tape = new Tape("a,b\n2"); Assert.AreEqual(' ', tape.Read()); tape.Write('c'); Assert.AreEqual('c', tape.Read()); }
public void TapeCanBeInitialisedWithDifferentValues() { Tape tape = new Tape("a,,b,,c"); Assert.AreEqual('a', tape.Read()); tape.MoveRight(); Assert.AreEqual(' ', tape.Read()); tape.MoveRight(); Assert.AreEqual('b', tape.Read()); tape.MoveRight(); Assert.AreEqual(' ', tape.Read()); tape.MoveRight(); Assert.AreEqual('c', tape.Read()); tape.MoveRight(); }
public void TapeCanBeInitialisedToDifferentStartPosition() { Tape tape = new Tape("a,,b,,c\n2"); Assert.AreEqual('b', tape.Read()); tape.MoveRight(); Assert.AreEqual(' ', tape.Read()); tape.MoveRight(); Assert.AreEqual('c', tape.Read()); tape.MoveRight(); }
public void ReadReturnsLastWrittenCharacter() { Tape tape = new Tape(); char symbol = 'a'; tape.Write(symbol); Assert.AreEqual(symbol, tape.Read()); }
public void ReadingNewTapeReturnsNull() { Tape tape = new Tape(); Assert.AreEqual(' ', tape.Read()); }