From 17929a34430f526f01eb4ef29329d082643a6d03 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Sat, 29 Jun 2024 17:31:56 +0200 Subject: [PATCH] [Tests] Fix unit tests in template builds --- tests/core/math/test_vector2.h | 4 +++- tests/core/math/test_vector3.h | 4 +++- tests/core/object/test_class_db.h | 2 ++ tests/core/os/test_os.h | 2 ++ tests/scene/test_instance_placeholder.h | 2 ++ tests/scene/test_node.h | 2 ++ 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/core/math/test_vector2.h b/tests/core/math/test_vector2.h index fc3fd6a87d3e..7bd494ec8037 100644 --- a/tests/core/math/test_vector2.h +++ b/tests/core/math/test_vector2.h @@ -353,7 +353,6 @@ TEST_CASE("[Vector2] Plane methods") { const Vector2 vector = Vector2(1.2, 3.4); const Vector2 vector_y = Vector2(0, 1); const Vector2 vector_normal = Vector2(0.95879811270838721622267, 0.2840883296913739899919); - const Vector2 vector_non_normal = Vector2(5.4, 1.6); const real_t p_d = 99.1; CHECK_MESSAGE( vector.bounce(vector_y) == Vector2(1.2, -3.4), @@ -383,6 +382,8 @@ TEST_CASE("[Vector2] Plane methods") { vector.slide(vector_normal).is_equal_approx(Vector2(-0.8292559899117276166456, 2.798738965952080706179)), "Vector2 slide with normal should return expected value."); // There's probably a better way to test these ones? +#ifdef MATH_CHECKS + const Vector2 vector_non_normal = Vector2(5.4, 1.6); ERR_PRINT_OFF; CHECK_MESSAGE( vector.bounce(vector_non_normal).is_equal_approx(Vector2()), @@ -394,6 +395,7 @@ TEST_CASE("[Vector2] Plane methods") { vector.slide(vector_non_normal).is_equal_approx(Vector2()), "Vector2 slide should return empty Vector2 with non-normalized input."); ERR_PRINT_ON; +#endif // MATH_CHECKS } TEST_CASE("[Vector2] Rounding methods") { diff --git a/tests/core/math/test_vector3.h b/tests/core/math/test_vector3.h index ca0aa028824b..4cab753d6f6e 100644 --- a/tests/core/math/test_vector3.h +++ b/tests/core/math/test_vector3.h @@ -368,7 +368,6 @@ TEST_CASE("[Vector3] Plane methods") { const Vector3 vector = Vector3(1.2, 3.4, 5.6); const Vector3 vector_y = Vector3(0, 1, 0); const Vector3 vector_normal = Vector3(0.88763458893247992491, 0.26300284116517923701, 0.37806658417494515320); - const Vector3 vector_non_normal = Vector3(5.4, 1.6, 2.3); CHECK_MESSAGE( vector.bounce(vector_y) == Vector3(1.2, -3.4, 5.6), "Vector3 bounce on a plane with normal of the Y axis should."); @@ -394,6 +393,8 @@ TEST_CASE("[Vector3] Plane methods") { vector.slide(vector_normal).is_equal_approx(Vector3(-2.41848149148878681437, 2.32785733585517427722237, 4.0587949202918130235)), "Vector3 slide with normal should return expected value."); // There's probably a better way to test these ones? +#ifdef MATH_CHECKS + const Vector3 vector_non_normal = Vector3(5.4, 1.6, 2.3); ERR_PRINT_OFF; CHECK_MESSAGE( vector.bounce(vector_non_normal).is_equal_approx(Vector3()), @@ -405,6 +406,7 @@ TEST_CASE("[Vector3] Plane methods") { vector.slide(vector_non_normal).is_equal_approx(Vector3()), "Vector3 slide should return empty Vector3 with non-normalized input."); ERR_PRINT_ON; +#endif // MATH_CHECKS } TEST_CASE("[Vector3] Rounding methods") { diff --git a/tests/core/object/test_class_db.h b/tests/core/object/test_class_db.h index 381d759e5bc4..358bbc08a39f 100644 --- a/tests/core/object/test_class_db.h +++ b/tests/core/object/test_class_db.h @@ -375,8 +375,10 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co } void validate_argument(const Context &p_context, const ExposedClass &p_class, const String &p_owner_name, const String &p_owner_type, const ArgumentData &p_arg) { +#ifdef DEBUG_METHODS_ENABLED TEST_COND((p_arg.name.is_empty() || p_arg.name.begins_with("_unnamed_arg")), vformat("Unnamed argument in position %d of %s '%s.%s'.", p_arg.position, p_owner_type, p_class.name, p_owner_name)); +#endif // DEBUG_METHODS_ENABLED const ExposedClass *arg_class = p_context.find_exposed_class(p_arg.type); if (arg_class) { diff --git a/tests/core/os/test_os.h b/tests/core/os/test_os.h index 6ee0ff82e728..1e2f5e222b4e 100644 --- a/tests/core/os/test_os.h +++ b/tests/core/os/test_os.h @@ -163,12 +163,14 @@ TEST_CASE("[OS] Processor count and memory information") { CHECK_MESSAGE( OS::get_singleton()->get_processor_count() >= 1, "The returned processor count should be greater than zero."); +#ifdef DEBUG_ENABLED CHECK_MESSAGE( OS::get_singleton()->get_static_memory_usage() >= 1, "The returned static memory usage should be greater than zero."); CHECK_MESSAGE( OS::get_singleton()->get_static_memory_peak_usage() >= 1, "The returned static memory peak usage should be greater than zero."); +#endif // DEBUG_ENABLED } TEST_CASE("[OS] Execute") { diff --git a/tests/scene/test_instance_placeholder.h b/tests/scene/test_instance_placeholder.h index d915c5d961c8..17f2151d5434 100644 --- a/tests/scene/test_instance_placeholder.h +++ b/tests/scene/test_instance_placeholder.h @@ -333,6 +333,7 @@ TEST_CASE("[SceneTree][InstancePlaceholder] Instantiate from placeholder with ov } } +#ifdef TOOLS_ENABLED TEST_CASE("[SceneTree][InstancePlaceholder] Instance a PackedScene containing an InstancePlaceholder with no overrides") { GDREGISTER_CLASS(_TestInstancePlaceholderNode); @@ -526,6 +527,7 @@ TEST_CASE("[SceneTree][InstancePlaceholder] Instance a PackedScene containing an DirAccess::remove_file_or_error(internal_path); DirAccess::remove_file_or_error(main_path); } +#endif // TOOLS_ENABLED } //namespace TestInstancePlaceholder diff --git a/tests/scene/test_node.h b/tests/scene/test_node.h index 05764d8f29fd..e387c73f9f98 100644 --- a/tests/scene/test_node.h +++ b/tests/scene/test_node.h @@ -529,6 +529,7 @@ TEST_CASE("[SceneTree][Node]Exported node checks") { memdelete(dup); } +#ifdef TOOLS_ENABLED SUBCASE("Saving instance with exported nodes should not store the unchanged property") { Ref ps; ps.instantiate(); @@ -602,6 +603,7 @@ TEST_CASE("[SceneTree][Node]Exported node checks") { } CHECK_EQ(stored_properties, 2); } +#endif // TOOLS_ENABLED memdelete(node); }