Skip to content

Commit

Permalink
Merge pull request #93745 from AThousandShips/test_template_fix
Browse files Browse the repository at this point in the history
[Tests] Fix unit tests in template builds
  • Loading branch information
akien-mga committed Jun 29, 2024
2 parents 37ea017 + 17929a3 commit 2f7973f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/core/math/test_vector2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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()),
Expand All @@ -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") {
Expand Down
4 changes: 3 additions & 1 deletion tests/core/math/test_vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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()),
Expand All @@ -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") {
Expand Down
2 changes: 2 additions & 0 deletions tests/core/object/test_class_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions tests/core/os/test_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
2 changes: 2 additions & 0 deletions tests/scene/test_instance_placeholder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tests/scene/test_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PackedScene> ps;
ps.instantiate();
Expand Down Expand Up @@ -602,6 +603,7 @@ TEST_CASE("[SceneTree][Node]Exported node checks") {
}
CHECK_EQ(stored_properties, 2);
}
#endif // TOOLS_ENABLED

memdelete(node);
}
Expand Down

0 comments on commit 2f7973f

Please sign in to comment.