From 66ea0471a00075c383711fe4060172dffae93d96 Mon Sep 17 00:00:00 2001 From: Jerome Date: Sun, 7 Apr 2019 18:40:37 +0800 Subject: [PATCH] tests: Add unit test for CollisionRay into CollisionBox Closes #613 --- tests/collide/test_into_box.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/collide/test_into_box.py b/tests/collide/test_into_box.py index 6e12012c14..5cda4c51a2 100644 --- a/tests/collide/test_into_box.py +++ b/tests/collide/test_into_box.py @@ -26,3 +26,20 @@ def test_plane_into_box(): entry = make_collision(plane, box)[0] assert entry is None + + +def test_ray_into_box(): + ray = CollisionRay(1, 1, 1, 0, 1, 0) + box = CollisionBox((0, 0, 0), 3, 3, 5) + entry = make_collision(ray, box)[0] + assert entry is not None + assert entry.get_from() == ray + assert entry.get_into() == box + + # Colliding just on the edge + entry, np_from, np_into = make_collision(CollisionRay(3, 3, 0, 1, -1, 0), box) + assert entry.get_surface_point(np_from) == Point3(3, 3, 0) + + # No collision + entry = make_collision(CollisionRay(0, 0, 100, 1, 0, 0), box)[0] + assert entry is None