def test_horizontal_two_wins(self): """ Tests a won horizontal does result in a game win declaration """ test = Game() test.board = [[None, None, None, '1010'], [None, None, '1100', None], [None, '1000', None, None], ['1111', None, None, None]] self.assertTrue(test.has_won_game('1000'))
def test_horizontal_two_loses(self): """ Tests a not won horizontal does not result in a game win declaration """ test = Game() test.board = [[None, None, None, '1010'], [None, None, '0100', None], [None, '1000', None, None], ['1111', None, None, None]] self.assertFalse(test.has_won_game('1010'))
def test_fourth_column_loses(self): """ Tests a not won fourth column does not result in a game win declaration """ test = Game() test.board = [[None, None, None, '0010'], [None, None, None, '1100'], [None, None, None, '1000'], [None, None, None, '1111']] self.assertFalse(test.has_won_game('0010'))
def test_fourth_column_wins(self): """ Tests a won fourth column does result in a game win declaration """ test = Game() test.board = [[None, None, None, '1010'], [None, None, None, '1100'], [None, None, None, '1000'], [None, None, None, '1111']] self.assertTrue(test.has_won_game('1000'))
def test_third_column_loses(self): """ Tests a not won third column does not result in a game win declaration """ test = Game() test.board = [[None, None, '1010', None], [None, None, '0100', None], [None, None, '1010', None], [None, None, '1111', None]] self.assertFalse(test.has_won_game('1111'))
def test_second_column_wins(self): """ Tests a won second column does result in a game win declaration """ test = Game() test.board = [[None, '1010', None, None], [None, '1100', None, None], [None, '1000', None, None], [None, '1111', None, None]] self.assertTrue(test.has_won_game('1111'))
def test_third_row_loses(self): """ Tests a not won third row does not result in a game win declaration """ test = Game() test.board = [[None, None, None, None], [None, None, None, None], ['0000', '1000', '0101', '0010'], [None, None, None, None]] self.assertFalse(test.has_won_game('0101'))
def test_third_row_wins(self): """ Tests a won third row does result in a game win declaration """ test = Game() test.board = [[None, None, None, None], [None, None, None, None], ['0000', '1000', '0100', '0010'], [None, None, None, None]] self.assertTrue(test.has_won_game('0000'))
def test_most_pieces_loses(self): """ Tests a mostly full board does not result in a game win declaration """ test = Game() test.board = [['0001', '1000', None, '0100'], ['1110', '0001', '0010', '0111'], ['1001', None, '1110', '1011'], ['0100', '0110', '0011', '1111']] self.assertFalse(test.has_won_game('1111'))
def test_fourth_column(self): """ Tests the number of similarities between pieces for each characteristic along the fourth column of pieces is the expected number of similarities """ test = Game() test.board = [[None, '1000', '0001', None], [None, '0000', '0010', '0111'], ['1001', None, '1111', '1011'], ['0100', '0110', '0011', '1110']] self.assertEqual([1, 2, 3, 1], test.bin_count('0110', 0, 3, 1, 0, 3))
def test_third_row(self): """ Tests the number of similarities between pieces for each characteristic along the third row of pieces is the expected number of similarities """ test = Game() test.board = [[None, '1000', '0001', '0101'], [None, '0000', '0010', '0111'], ['1001', None, '1111', '1011'], ['0100', '0110', '0011', '1110']] self.assertEqual([0, 1, 2, 0], test.bin_count('0110', 2, 1, 0, 1, 3))
def test_one_block(self): """ Tests the number of similarities between pieces for each characteristic along one block of pieces is the expected number of similarities """ test = Game() test.board = [[None, '1000', '0001', None], [None, '0000', '0010', '0111'], ['1001', None, '1111', '1011'], ['0100', '0110', '0011', '1110']] self.assertEqual([1, 0, 0, 1], test.bin_count('0110', 0, 0, 1, 1, 1))
def test_horizontal_two(self): """ Tests the number of similarities between pieces for each characteristic along a horizontal row of pieces is the expected number of similarities """ test = Game() test.board = [[None, '1000', '0001', None], [None, '0000', '0010', '0111'], ['1001', None, '1111', '1011'], ['0100', '0110', '0011', '1110']] self.assertEqual([1, 2, 2, 2], test.bin_count('0110', 0, 0, 1, 1, 3))