コード例 #1
0
    def test_step_part_one(self):
        b0 = Board.from_file('small_test_input_0')
        b1 = Board.from_file('small_test_input_1')
        b2 = Board.from_file('small_test_input_2')

        t1 = b0._step(Part.one)
        self.assertListEqual(t1.matrix, b1.matrix)

        t2 = t1._step(Part.one)
        self.assertListEqual(t2.matrix, b2.matrix)
コード例 #2
0
 def test_from_file(self):
     board = Board.from_file('small_test_input_0')
     expected = [[V.floor, V.floor, V.floor, V.floor, V.floor],
                 [V.floor, V.floor, V.full, V.floor, V.floor],
                 [V.floor, V.floor, V.empty, V.empty, V.floor],
                 [V.floor, V.full, V.floor, V.empty, V.floor],
                 [V.floor, V.floor, V.floor, V.floor, V.floor]]
     self.assertEqual(len(board.matrix), 5)
     self.assertEqual(len(board.matrix[0]), 5)
     self.assertListEqual(board.matrix, expected)
コード例 #3
0
 def test_raycast(self):
     m = [[V.floor, V.floor, V.floor], [V.full, V.full, V.floor],
          [V.full, V.full, V.floor]]
     self.assertEqual(Board._raycast(1, 1, m), V.full)
コード例 #4
0
 def test_equality(self):
     a = Board.from_file('small_test_input_0')
     b = Board.from_file('small_test_input_0')
     self.assertTrue(a == b)
コード例 #5
0
 def test_dimensions(self):
     b = Board.from_file('input')
     self.assertEqual(b.width, 97 + 2)
     self.assertEqual(b.height, 93 + 2)
コード例 #6
0
 def test_convolve_input_2(self):
     b1 = Board.from_file('small_test_input_1')
     self.assertEqual(Board._convolve(2, 2, b1.matrix), V.empty)
     self.assertEqual(Board._convolve(2, 3, b1.matrix), V.empty)
コード例 #7
0
 def test_convolve_all_full(self):
     m = [[V.full, V.full, V.full]] * 3
     self.assertEqual(Board._convolve(1, 1, m), V.empty)
コード例 #8
0
 def test_convolve_all_floor(self):
     m = [[V.floor, V.floor, V.floor]] * 3
     self.assertEqual(Board._convolve(1, 1, m), V.floor)