summaryrefslogtreecommitdiff
path: root/tests/core
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2021-12-02 15:45:18 +0100
committerRémi Verschelde <rverschelde@gmail.com>2021-12-02 15:45:55 +0100
commit2017590ef6ebb27a6c3ae0d9d7880a0fa6dd9b3c (patch)
tree1948e51aada93f862818a8156d6392d8983a9563 /tests/core
parent837e6bdf1859d2054b31730fb71c636f681300da (diff)
AABB: Improve docs and test for `has_point`
Contrarily to the 2D Rect2i counterpart, it doesn't make much sense in 3D and for floating-point AABBs to exclude points on some of its faces.
Diffstat (limited to 'tests/core')
-rw-r--r--tests/core/math/test_aabb.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/core/math/test_aabb.h b/tests/core/math/test_aabb.h
index b838bed171..f5076ce1ed 100644
--- a/tests/core/math/test_aabb.h
+++ b/tests/core/math/test_aabb.h
@@ -349,14 +349,27 @@ TEST_CASE("[AABB] Has point") {
aabb.has_point(Vector3(2, 3, 0)),
"has_point() with contained point should return the expected value.");
CHECK_MESSAGE(
+ !aabb.has_point(Vector3(-20, 0, 0)),
+ "has_point() with non-contained point should return the expected value.");
+
+ CHECK_MESSAGE(
aabb.has_point(Vector3(-1.5, 3, 0)),
- "has_point() with contained point on negative edge should return the expected value.");
+ "has_point() with positive size should include point on near face (X axis).");
CHECK_MESSAGE(
aabb.has_point(Vector3(2.5, 3, 0)),
- "has_point() with contained point on positive edge should return the expected value.");
+ "has_point() with positive size should include point on far face (X axis).");
CHECK_MESSAGE(
- !aabb.has_point(Vector3(-20, 0, 0)),
- "has_point() with non-contained point should return the expected value.");
+ aabb.has_point(Vector3(0, 2, 0)),
+ "has_point() with positive size should include point on near face (Y axis).");
+ CHECK_MESSAGE(
+ aabb.has_point(Vector3(0, 7, 0)),
+ "has_point() with positive size should include point on far face (Y axis).");
+ CHECK_MESSAGE(
+ aabb.has_point(Vector3(0, 3, -2.5)),
+ "has_point() with positive size should include point on near face (Z axis).");
+ CHECK_MESSAGE(
+ aabb.has_point(Vector3(0, 3, 3.5)),
+ "has_point() with positive size should include point on far face (Z axis).");
}
TEST_CASE("[AABB] Expanding") {