summaryrefslogtreecommitdiff
path: root/tests/core
diff options
context:
space:
mode:
authorAndrés Botero <0xafbf@gmail.com>2023-01-29 11:45:22 -0500
committerAndrés Botero <boterock@gmail.com>2023-02-11 15:03:11 -0500
commita90e151b2a9981049f5710c4efa7fb8af6c524d7 (patch)
tree1bc1c80e4a7688177e6978b7cad3732c75150c2e /tests/core
parent44b41ded82229ca7614403f74234a4282002458b (diff)
Added component-wise `min` and `max` functions for vectors
Diffstat (limited to 'tests/core')
-rw-r--r--tests/core/math/test_vector3.h8
-rw-r--r--tests/core/math/test_vector3i.h7
-rw-r--r--tests/core/math/test_vector4.h8
-rw-r--r--tests/core/math/test_vector4i.h8
4 files changed, 31 insertions, 0 deletions
diff --git a/tests/core/math/test_vector3.h b/tests/core/math/test_vector3.h
index c3488954ce..ca0aa02882 100644
--- a/tests/core/math/test_vector3.h
+++ b/tests/core/math/test_vector3.h
@@ -354,6 +354,14 @@ TEST_CASE("[Vector3] Other methods") {
CHECK_MESSAGE(
vector.snapped(Vector3(0.25, 0.25, 0.25)) == Vector3(1.25, 3.5, 5.5),
"Vector3 snapped to 0.25 should give exact results.");
+
+ CHECK_MESSAGE(
+ Vector3(1.2, 2.5, 2.0).is_equal_approx(vector.min(Vector3(3.0, 2.5, 2.0))),
+ "Vector3 min should return expected value.");
+
+ CHECK_MESSAGE(
+ Vector3(5.3, 3.4, 5.6).is_equal_approx(vector.max(Vector3(5.3, 2.0, 3.0))),
+ "Vector3 max should return expected value.");
}
TEST_CASE("[Vector3] Plane methods") {
diff --git a/tests/core/math/test_vector3i.h b/tests/core/math/test_vector3i.h
index 6eef129a36..485a500715 100644
--- a/tests/core/math/test_vector3i.h
+++ b/tests/core/math/test_vector3i.h
@@ -131,6 +131,13 @@ TEST_CASE("[Vector3i] Other methods") {
const Vector3i vector = Vector3i(1, 3, -7);
CHECK_MESSAGE(
+ vector.min(Vector3i(3, 2, 5)) == Vector3i(1, 2, -7),
+ "Vector3i min should return expected value.");
+ CHECK_MESSAGE(
+ vector.max(Vector3i(5, 2, 4)) == Vector3i(5, 3, 4),
+ "Vector3i max should return expected value.");
+
+ CHECK_MESSAGE(
vector.snapped(Vector3i(4, 2, 5)) == Vector3i(0, 4, -5),
"Vector3i snapped should work as expected.");
}
diff --git a/tests/core/math/test_vector4.h b/tests/core/math/test_vector4.h
index b85cc710e0..331e0fcfd5 100644
--- a/tests/core/math/test_vector4.h
+++ b/tests/core/math/test_vector4.h
@@ -255,6 +255,14 @@ TEST_CASE("[Vector4] Other methods") {
CHECK_MESSAGE(
vector.snapped(Vector4(0.25, 0.25, 0.25, 0.25)) == Vector4(1.25, 3.5, 5.5, 1.5),
"Vector4 snapped to 0.25 should give exact results.");
+
+ CHECK_MESSAGE(
+ Vector4(1.2, 2.5, 2.0, 1.6).is_equal_approx(vector.min(Vector4(3.0, 2.5, 2.0, 3.4))),
+ "Vector4 min should return expected value.");
+
+ CHECK_MESSAGE(
+ Vector4(5.3, 3.4, 5.6, 4.2).is_equal_approx(vector.max(Vector4(5.3, 2.0, 3.0, 4.2))),
+ "Vector4 max should return expected value.");
}
TEST_CASE("[Vector4] Rounding methods") {
diff --git a/tests/core/math/test_vector4i.h b/tests/core/math/test_vector4i.h
index e5b47af7c4..5fda6f1778 100644
--- a/tests/core/math/test_vector4i.h
+++ b/tests/core/math/test_vector4i.h
@@ -134,6 +134,14 @@ TEST_CASE("[Vector3i] Other methods") {
const Vector4i vector = Vector4i(1, 3, -7, 13);
CHECK_MESSAGE(
+ vector.min(Vector4i(3, 2, 5, 8)) == Vector4i(1, 2, -7, 8),
+ "Vector4i min should return expected value.");
+
+ CHECK_MESSAGE(
+ vector.max(Vector4i(5, 2, 4, 8)) == Vector4i(5, 3, 4, 13),
+ "Vector4i max should return expected value.");
+
+ CHECK_MESSAGE(
vector.snapped(Vector4i(4, 2, 5, 8)) == Vector4i(0, 4, -5, 16),
"Vector4i snapped should work as expected.");
}