1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-20 14:45:44 +00:00

Add is_finite method for checking built-in types

This commit is contained in:
Haoyu Qiu
2022-08-11 16:12:27 +08:00
parent 18177828ad
commit 5da515773d
46 changed files with 504 additions and 12 deletions

View File

@@ -465,6 +465,32 @@ TEST_CASE("[Vector2] Linear algebra methods") {
Math::is_equal_approx(Vector2(-a.x, a.y).dot(Vector2(b.x, -b.y)), (real_t)-57.3),
"Vector2 dot should return expected value.");
}
TEST_CASE("[Vector2] Finite number checks") {
const double infinite[] = { NAN, INFINITY, -INFINITY };
CHECK_MESSAGE(
Vector2(0, 1).is_finite(),
"Vector2(0, 1) should be finite");
for (double x : infinite) {
CHECK_FALSE_MESSAGE(
Vector2(x, 1).is_finite(),
"Vector2 with one component infinite should not be finite.");
CHECK_FALSE_MESSAGE(
Vector2(0, x).is_finite(),
"Vector2 with one component infinite should not be finite.");
}
for (double x : infinite) {
for (double y : infinite) {
CHECK_FALSE_MESSAGE(
Vector2(x, y).is_finite(),
"Vector2 with two components infinite should not be finite.");
}
}
}
} // namespace TestVector2
#endif // TEST_VECTOR2_H