コード例 #1
0
ファイル: test_matrix.py プロジェクト: Juddling/BattlePi
    def test_same_height_2(self):
        test_pattern = [
            [1],
            [2],
            [2],
            [1]
        ]

        ship = [
            [1, 1, 1, 1, 1],
            [1, 1, 2, 1, 1],
            [1, 2, 2, 2, 1],
            [1, 2, 1, 2, 1]
        ]

        expected = [
            [0,1,2,3,4],
            [2],
            [1,2,3],
            [0,2,4]
        ]

        result = transform.match_matrix_same_height(test_pattern, ship)

        # test generator of generators
        for index, row in enumerate(result):
            self.assertSequenceEqual(tuple(row), tuple(expected[index]))
コード例 #2
0
ファイル: test_matrix.py プロジェクト: Juddling/BattlePi
    def test_same_height(self):
        test_pattern = [
            [1],
            [2],
            [2],
            [1]
        ]

        ship = [
            [1, 1, 2, 1, 1],
            [1, 2, 2, 2, 1],
            [1, 2, 1, 2, 1],
            [1, 1, 1, 1, 1]
        ]

        result = transform.group_matches(transform.match_matrix_same_height(test_pattern, ship))
        self.assertListEqual(result, [1,3])
コード例 #3
0
ファイル: test_matrix.py プロジェクト: Juddling/BattlePi
    def test_same_height_grouped(self):
        test_pattern = [
            [1],
            [2],
            [2],
            [1]
        ]

        ship = [
            [1, 1, 1, 1, 1],
            [1, 1, 2, 1, 1],
            [1, 2, 2, 2, 1],
            [1, 2, 1, 2, 1]
        ]

        ungrouped = transform.match_matrix_same_height(test_pattern, ship)
        grouped = transform.group_matches(ungrouped)

        self.assertListEqual(grouped, [2])