def test_fromcolumns(self): chess2 = chess2048() chess2.chess[0:4] = 2,4,4,8 columns = chess2.tocolumns chess3 = chess2048() chess3._fromcolumns(columns) self.assertEqual(chess2, chess3)
def test_fromrows(self): chess2 = chess2048() chess2.born() chess2.born() rows2 = chess2.torows chess3 = chess2048() chess3._fromrows(rows2) self.assertTrue(chess3 == chess2)
def test_neq(self): chess2 = chess2048() chess2.born() self.assertTrue(self.chess != chess2) self.assertTrue(self.chess.__ne__(chess2)) self.assertFalse(self.chess == chess2) self.assertFalse(self.chess.__eq__(chess2))
def test_move(self): chess = chess2048() self.assertFalse(chess.move(">")) self.assertFalse(chess.move("u")) chess.chess = [4, 2, 4, 8, 2, 4, 2, 16, 4, 8, 4, 8, 2, 4, 2, 4] self.assertFalse(chess.move("down")) self.assertFalse(chess.move("<<"))
def test_tocolumns(self): chess2 = chess2048() chess2.chess[0:4] = 2,4,4,8 columns = chess2.tocolumns self.assertListEqual(columns[0], [2] + [0] * (self.chess.columns -1)) self.assertListEqual(columns[1], [4] + [0] * (self.chess.columns -1)) self.assertListEqual(columns[2], [4] + [0] * (self.chess.columns -1)) self.assertListEqual(columns[3], [8] + [0] * (self.chess.columns -1))
def test_is_die(self): chess = chess2048() self.assertFalse(chess.is_die()) chess.chess = [4, 2, 4, 8, 2, 4, 2, 16, 4, 8, 4, 8, 2, 4, 2, 4] self.assertTrue(chess.is_die())
def test_top(self): chess = chess2048() self.assertEqual(chess.top() , 0) chess.chess = range(0, 32, 2) self.assertEqual(chess.top() , 30)