コード例 #1
0
	def test_checkUnavailableSquare_UnavailableSquaresEqualToPassed_returnsTrue(self):
		queenSolver = QueenSolver()
		square = Square(ord('A'),1)
		queenSolver.addUnavailableSquare(square)
		square2 = Square(ord('A'),1)
		isUnavailable = queenSolver.checkUnavailableSquare(square2)
		self.assertTrue(isUnavailable)
コード例 #2
0
 def test_checkUnavailableSquare_SameUnavailableSquaresAsPassed_returnsTrue(
         self):
     queenSolver = QueenSolver()
     square = Square(ord('A'), 1)
     queenSolver.addUnavailableSquare(square)
     isUnavailable = queenSolver.checkUnavailableSquare(square)
     self.assertTrue(isUnavailable)
コード例 #3
0
	def test_getNextAvailableSquare_AllAvailableRanksFirstIsUnavailableSquare_returnsTheSecondRank(self):
		queenSolver = QueenSolver()
		availableRanks = deque ([1,2,3,4,5,6,7,8])
		discardedRanks = list()
		queenSolver.addUnavailableSquare(Square(ord('A'),1))
		possibleRank, square = queenSolver.getNextAvailableSquare(ord('A'), availableRanks , discardedRanks)
		self.assertEqual(len(availableRanks), 6)
		self.assertEqual(len(discardedRanks), 1)
		self.assertEqual(discardedRanks[0], 1)
		self.assertEqual (possibleRank, 2)
		self.assertEqual (square, Square(ord('A'),2))
コード例 #4
0
 def test_getNextAvailableSquare_AllAvailableRanksFirstIsUnavailableSquare_returnsTheSecondRank(
         self):
     queenSolver = QueenSolver()
     availableRanks = deque([1, 2, 3, 4, 5, 6, 7, 8])
     discardedRanks = list()
     queenSolver.addUnavailableSquare(Square(ord('A'), 1))
     possibleRank, square = queenSolver.getNextAvailableSquare(
         ord('A'), availableRanks, discardedRanks)
     self.assertEqual(len(availableRanks), 6)
     self.assertEqual(len(discardedRanks), 1)
     self.assertEqual(discardedRanks[0], 1)
     self.assertEqual(possibleRank, 2)
     self.assertEqual(square, Square(ord('A'), 2))
コード例 #5
0
	def test_checkUnavailableSquare_SeverUnavailableSquaresOneEqualToPassed_returnsTrue(self):
		queenSolver = QueenSolver()
		square = Square(ord('A'),1)
		queenSolver.addUnavailableSquare(square)
		square = Square(ord('B'),2)
		queenSolver.addUnavailableSquare(square)
		square = Square(ord('C'),3)
		queenSolver.addUnavailableSquare(square)
		square = Square(ord('C'),4)
		queenSolver.addUnavailableSquare(square)
		square = Square(ord('D'),5)
		queenSolver.addUnavailableSquare(square)
		square2 = Square(ord('C'),4)
		isUnavailable = queenSolver.checkUnavailableSquare(square2)
		self.assertTrue(isUnavailable)
コード例 #6
0
 def test_checkUnavailableSquare_SeverUnavailableSquaresOneEqualToPassed_returnsTrue(
         self):
     queenSolver = QueenSolver()
     square = Square(ord('A'), 1)
     queenSolver.addUnavailableSquare(square)
     square = Square(ord('B'), 2)
     queenSolver.addUnavailableSquare(square)
     square = Square(ord('C'), 3)
     queenSolver.addUnavailableSquare(square)
     square = Square(ord('C'), 4)
     queenSolver.addUnavailableSquare(square)
     square = Square(ord('D'), 5)
     queenSolver.addUnavailableSquare(square)
     square2 = Square(ord('C'), 4)
     isUnavailable = queenSolver.checkUnavailableSquare(square2)
     self.assertTrue(isUnavailable)