From ff4b3aade9b3d691ec07785b42bde94aff4dd4b7 Mon Sep 17 00:00:00 2001
From: Nicolas Braud-Santoni <nicolas@braud-santoni.eu>
Date: Thu, 4 Apr 2019 13:03:58 +0200
Subject: [PATCH] tests/camera: Roundtrip through viewport and frame
 coordinates

---
 tests/test_camera.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/test_camera.py b/tests/test_camera.py
index b97c5523..cdcd1a12 100644
--- a/tests/test_camera.py
+++ b/tests/test_camera.py
@@ -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)