Пример #1
0
 def testWinsForVerticalTrue(self):
     b = hw.Board(7, 6)
     b.addMove(0, 'X')
     b.addMove(0, 'X')
     b.addMove(0, 'X')
     b.addMove(0, 'X')
     self.assertTrue(b.winsFor('X'), '** INCORRECT **  b does win for X')
Пример #2
0
 def testAddMoveLastColumn(self):
     b = hw.Board(7, 6)
     b.addMove(6, 'X')
     answer1 = [[' '] * 7 for i in range(6)]
     answer1[5][6] = 'X'
     self.assertEqual(b.data, answer1,
                      '** INCORRECT **  X should be in the lower right')
Пример #3
0
 def testWinsForHorizontalTrue(self):
     b = hw.Board(7, 6)
     b.addMove(0, 'X')
     b.addMove(1, 'X')
     b.addMove(2, 'X')
     b.addMove(3, 'X')
     self.assertTrue(b.winsFor('X'), '** INCORRECT **  b does win for X')
Пример #4
0
 def testIsFullTrue(self):
     b = hw.Board(2, 2)
     b.addMove(0, 'X')
     b.addMove(0, 'X')
     b.addMove(1, 'X')
     b.addMove(1, 'X')
     self.assertTrue(b.isFull(), '** INCORRECT **  b actually is full')
Пример #5
0
 def testDelMove(self):
     b = hw.Board(7, 6)
     b.addMove(6, 'X')
     b.delMove(6)
     answer2 = [[' '] * 7 for i in range(6)]
     self.assertEqual(b.data, answer2,
                      '** INCORRECT **  board should be empty')
Пример #6
0
 def testIsFullFalse(self):
     b = hw.Board(2, 2)
     b.addMove(0, 'X')
     b.addMove(0, 'X')
     b.addMove(1, 'X')
     b.addMove(1, 'X')
     b.delMove(1)
     self.assertFalse(b.isFull(), '** INCORRECT **  b actually is not full')
Пример #7
0
 def testWinsForDiagonalSWFalse(self):
     b = hw.Board(7, 6)
     b.addMove(0, 'X')
     b.addMove(1, 'O')
     b.addMove(1, 'X')
     b.addMove(2, 'O')
     b.addMove(2, 'X')
     b.addMove(2, 'X')
     b.addMove(3, 'X')
     b.addMove(3, 'O')
     b.addMove(3, 'X')
     self.assertFalse(b.winsFor('X'),
                      '** INCORRECT **  b does not win for X')
Пример #8
0
 def testWinsForDiagonalSETrue(self):
     print "\n\nTEST 8"
     b = hw.Board(7, 6)
     b.addMove(6, 'X')
     b.addMove(5, 'O')
     b.addMove(5, 'X')
     b.addMove(4, 'O')
     b.addMove(4, 'X')
     b.addMove(4, 'X')
     b.addMove(3, 'X')
     b.addMove(3, 'O')
     b.addMove(3, 'X')
     b.addMove(3, 'X')
     self.assertTrue(b.winsFor('X'), '** INCORRECT **  b does win for X')