示例#1
0
    def test_find_corner_squares_3x3(self):

        piece = Blockies.Piece('square', 3, 3, (3, 3), const.WHITE)
        expected_squares = [(3, 3), (4, 3), (5, 3), (3, 4), (4, 4), (5, 4),
                            (3, 5), (4, 5), (5, 5)]
        expected_corners = [(3, 3), (3, 5), (5, 5), (5, 3)]
        self.assertEqual(piece.squares, expected_squares)
        self.assertEqual(Blockies.find_corners(piece.squares),
                         expected_corners)
示例#2
0
 def test_rotate_3_2_rect_clockwise(self):
     piece = Blockies.Piece('rectangle', 3, 2, (2, 2), const.WHITE)
     initial_squares = [(2, 2), (3, 2), (4, 2), (2, 3), (3, 3), (4, 3)]
     expected_squares = [(1, 2), (2, 2), (1, 3), (2, 3), (1, 4), (2, 4)]
     self.assertEqual(set(piece.squares), set(initial_squares))
     piece.rotate_clockwise()
     self.assertEqual(set(piece.squares), set(expected_squares),
                      'rotated 3x2 rect does not occupy expected squares')
示例#3
0
 def test_rotate_1_2_rect_clockwise(self):
     piece = Blockies.Piece('rectangle', 1, 2, (3, 6), const.WHITE)
     initial_squares = [(3, 6), (3, 7)]
     expected_squares = [(2, 6), (3, 6)]
     self.assertEqual(set(piece.squares), set(initial_squares))
     piece.rotate_clockwise()
     self.assertEqual(set(piece.squares), set(expected_squares),
                      'rotated 1x2 rect does not occupy expected squares')
示例#4
0
 def make_empty_game_grid(self):
     return Blockies.Game(2)
示例#5
0
 def test_unique_from_list(self):
     ordered_list = [1, "Hello", (3, 3), "Hello", (1, 1), (3, 3)]
     self.assertEqual(Blockies.unique_from_list(ordered_list),
                      [1, "Hello", (3, 3), (1, 1)])
示例#6
0
 def test_shift_coords_positive_xy(self):
     negative_coords = [(-1, -1), (0, -1), (-1, 0), (0, 0)]
     expected_coords = [(0, 0), (1, 0), (0, 1), (1, 1)]
     self.assertEqual(Blockies.shift_coords_positive(negative_coords),
                      expected_coords)