47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
import pytest
|
|
|
|
import spiral_matrix
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("matrix", "expected"),
|
|
[
|
|
(
|
|
[
|
|
["a", "b", "c"],
|
|
["d", "e", "f"],
|
|
["g", "h", "i"],
|
|
],
|
|
["a", "b", "c", "f", "i", "h", "g", "d", "e"],
|
|
),
|
|
(
|
|
[
|
|
[1, 2, 3, 4],
|
|
[5, 6, 7, 8],
|
|
[9, 10, 11, 12],
|
|
],
|
|
[1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7],
|
|
),
|
|
(
|
|
[
|
|
[1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
[1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
[1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
[1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
[1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
],
|
|
[] # noqa
|
|
+ [1, 2, 3, 4, 5, 6, 7, 8, 9] # right
|
|
+ [9, 9, 9] # down
|
|
+ [9, 8, 7, 6, 5, 4, 3, 2, 1] # left
|
|
+ [1, 1] # up
|
|
+ [1, 2, 3, 4, 5, 6, 7, 8] # right
|
|
+ [8] # down
|
|
+ [8, 7, 6, 5, 4, 3, 2] # left
|
|
+ [2, 3, 4, 5, 6, 7], # right
|
|
),
|
|
],
|
|
)
|
|
def test_matrix_spiral(matrix, expected):
|
|
assert spiral_matrix.matrix_spiral(matrix) == expected
|