diff options
author | Jakub Marcowski <01158831@pw.edu.pl> | 2023-10-11 12:04:57 +0200 |
---|---|---|
committer | Jakub Marcowski <01158831@pw.edu.pl> | 2023-10-12 13:46:49 +0200 |
commit | cb954c6babccbd9fe59013d8ed14098df0cdf8af (patch) | |
tree | 71e4c80fac2ffe02a2bc086da2aae91e2bbf39cf /tests | |
parent | 9957f1ad4e24235a1266754bb8be9fbba5499141 (diff) | |
download | redot-engine-cb954c6babccbd9fe59013d8ed14098df0cdf8af.tar.gz |
Implement `Vector2i/3i/4i` methods: `distance_to` and `distance_squared_to`
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/math/test_vector2i.h | 6 | ||||
-rw-r--r-- | tests/core/math/test_vector3i.h | 6 | ||||
-rw-r--r-- | tests/core/math/test_vector4i.h | 6 |
3 files changed, 18 insertions, 0 deletions
diff --git a/tests/core/math/test_vector2i.h b/tests/core/math/test_vector2i.h index 743c87f486..0f33400f7f 100644 --- a/tests/core/math/test_vector2i.h +++ b/tests/core/math/test_vector2i.h @@ -87,6 +87,12 @@ TEST_CASE("[Vector2i] Length methods") { CHECK_MESSAGE( vector2.length() == doctest::Approx(36.05551275463989293119), "Vector2i length should work as expected."); + CHECK_MESSAGE( + vector1.distance_squared_to(vector2) == 500, + "Vector2i distance_squared_to should work as expected and return exact result."); + CHECK_MESSAGE( + vector1.distance_to(vector2) == doctest::Approx(22.36067977499789696409), + "Vector2i distance_to should work as expected."); } TEST_CASE("[Vector2i] Operators") { diff --git a/tests/core/math/test_vector3i.h b/tests/core/math/test_vector3i.h index 485a500715..3914b85a75 100644 --- a/tests/core/math/test_vector3i.h +++ b/tests/core/math/test_vector3i.h @@ -90,6 +90,12 @@ TEST_CASE("[Vector3i] Length methods") { CHECK_MESSAGE( vector2.length() == doctest::Approx(53.8516480713450403125), "Vector3i length should work as expected."); + CHECK_MESSAGE( + vector1.distance_squared_to(vector2) == 1400, + "Vector3i distance_squared_to should work as expected and return exact result."); + CHECK_MESSAGE( + vector1.distance_to(vector2) == doctest::Approx(37.41657386773941385584), + "Vector3i distance_to should work as expected."); } TEST_CASE("[Vector3i] Operators") { diff --git a/tests/core/math/test_vector4i.h b/tests/core/math/test_vector4i.h index 5fda6f1778..31f68696c0 100644 --- a/tests/core/math/test_vector4i.h +++ b/tests/core/math/test_vector4i.h @@ -90,6 +90,12 @@ TEST_CASE("[Vector4i] Length methods") { CHECK_MESSAGE( vector2.length() == doctest::Approx(73.4846922835), "Vector4i length should work as expected."); + CHECK_MESSAGE( + vector1.distance_squared_to(vector2) == 3000, + "Vector4i distance_squared_to should work as expected."); + CHECK_MESSAGE( + vector1.distance_to(vector2) == doctest::Approx(54.772255750517), + "Vector4i distance_to should work as expected."); } TEST_CASE("[Vector4i] Operators") { |