From 129911f61af35fa2aed03349368f7e94772b682e Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Fri, 15 Oct 2021 15:32:26 -0500 Subject: Improve Curve with const and real_t --- tests/scene/test_curve.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/scene/test_curve.h b/tests/scene/test_curve.h index 60eafad460..4ee1a1c15c 100644 --- a/tests/scene/test_curve.h +++ b/tests/scene/test_curve.h @@ -219,35 +219,33 @@ TEST_CASE("[Curve] Custom curve with linear tangents") { TEST_CASE("[Curve2D] Linear sampling should return exact value") { Ref curve = memnew(Curve2D); - int len = 2048; + real_t len = 2048.0; curve->add_point(Vector2(0, 0)); - curve->add_point(Vector2((float)len, 0)); + curve->add_point(Vector2(len, 0)); - float baked_length = curve->get_baked_length(); - CHECK((float)len == baked_length); + real_t baked_length = curve->get_baked_length(); + CHECK(len == baked_length); for (int i = 0; i < len; i++) { - float expected = (float)i; - Vector2 pos = curve->interpolate_baked(expected); - CHECK_MESSAGE(pos.x == expected, "interpolate_baked should return exact value"); + Vector2 pos = curve->interpolate_baked(i); + CHECK_MESSAGE(pos.x == i, "interpolate_baked should return exact value"); } } TEST_CASE("[Curve3D] Linear sampling should return exact value") { Ref curve = memnew(Curve3D); - int len = 2048; + real_t len = 2048.0; curve->add_point(Vector3(0, 0, 0)); - curve->add_point(Vector3((float)len, 0, 0)); + curve->add_point(Vector3(len, 0, 0)); - float baked_length = curve->get_baked_length(); - CHECK((float)len == baked_length); + real_t baked_length = curve->get_baked_length(); + CHECK(len == baked_length); for (int i = 0; i < len; i++) { - float expected = (float)i; - Vector3 pos = curve->interpolate_baked(expected); - CHECK_MESSAGE(pos.x == expected, "interpolate_baked should return exact value"); + Vector3 pos = curve->interpolate_baked(i); + CHECK_MESSAGE(pos.x == i, "interpolate_baked should return exact value"); } } -- cgit v1.2.3