Skip to content

Commit

Permalink
tests/camera: Roundtrip through viewport and frame coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
nbraud committed Apr 4, 2019
1 parent d9de8ed commit ff4b3aa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ def test_camera_point_in_viewport_not_at_origin():
assert not cam.point_in_viewport(Vector(901, 600))


@given(cam=cameras(), v=vectors())
def test_camera_roundtrip_frame_viewport(cam: Camera, v: Vector):
"""Check that Camera.translate_to_{frame,viewport} are inverse of one another."""
assert cam.translate_to_frame(cam.translate_to_viewport(v)).isclose(v)
assert cam.translate_to_viewport(cam.translate_to_frame(v)).isclose(v)


def test_camera_translate_to_frame():
cam = Camera(viewport=(0, 0, 800, 600), pixel_ratio=80)
assert cam.position == Vector(0, 0)
Expand Down

0 comments on commit ff4b3aa

Please sign in to comment.