Skip to content

Commit f2c46d7

Browse files
committed
Refactor boundary tests for GridCell to use parameterized inputs
1 parent 1d8d55c commit f2c46d7

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

tests/unit/test_grid_cell.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,35 @@ def test_stroke_centroid_outside_cell(cell: models.GridCell) -> None:
4747
assert not cell.contains_points(stroke_points)
4848

4949

50-
def test_stroke_centroid_on_lower_boundary(cell: models.GridCell) -> None:
50+
@pytest.mark.parametrize(
51+
"x_vals,y_vals",
52+
[
53+
([10.0, 10.0], [88.0, 89.0]),
54+
([17.0, 18.0], [80.0, 80.0]),
55+
],
56+
ids=["left_boundary", "bottom_boundary"],
57+
)
58+
def test_stroke_centroid_on_lower_boundary(
59+
cell: models.GridCell, x_vals: list[float], y_vals: list[float]
60+
) -> None:
5161
"""Stroke whose centroid lands on the lower/left boundary (min) is included."""
52-
stroke_points = pd.DataFrame({"x": [10.0, 10.0], "y": [88.0, 89.0]})
62+
stroke_points = pd.DataFrame({"x": x_vals, "y": y_vals})
5363
assert cell.contains_points(stroke_points)
5464

5565

56-
def test_stroke_centroid_on_upper_boundary(cell: models.GridCell) -> None:
66+
@pytest.mark.parametrize(
67+
"x_vals,y_vals",
68+
[
69+
([25.0, 25.0], [88.0, 89.0]),
70+
([17.0, 18.0], [97.0, 97.0]),
71+
],
72+
ids=["right_boundary", "top_boundary"],
73+
)
74+
def test_stroke_centroid_on_upper_boundary(
75+
cell: models.GridCell, x_vals: list[float], y_vals: list[float]
76+
) -> None:
5777
"""Stroke whose centroid lands on the upper/right boundary (max) is excluded."""
58-
stroke_points = pd.DataFrame({"x": [17.0, 18.0], "y": [97.0, 97.0]})
78+
stroke_points = pd.DataFrame({"x": x_vals, "y": y_vals})
5979
assert not cell.contains_points(stroke_points)
6080

6181

0 commit comments

Comments
 (0)