You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
754 B
24 lines
754 B
import pytest
|
|
|
|
from src.models import BoundingBox, PixelRegion
|
|
|
|
|
|
def test_bounding_box_properties() -> None:
|
|
box = BoundingBox(10, 20, 30, 50)
|
|
assert (box.width, box.height) == (20, 30)
|
|
assert (box.center_x, box.center_y) == (20, 35)
|
|
assert (box.foot_x, box.foot_y) == (20, 50)
|
|
assert box.area == 600
|
|
|
|
|
|
def test_pixel_region_contains_including_boundary() -> None:
|
|
region = PixelRegion(10, 20, 30, 40)
|
|
assert region.contains(10, 20)
|
|
assert region.contains(30, 40)
|
|
assert not region.contains(31, 40)
|
|
|
|
|
|
@pytest.mark.parametrize("coords", [(1, 0, 1, 2), (0, 2, 1, 2), (2, 0, 1, 2)])
|
|
def test_invalid_bounding_box(coords: tuple[int, int, int, int]) -> None:
|
|
with pytest.raises(ValueError):
|
|
BoundingBox(*coords)
|
|
|