You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-25 15:37:42 +00:00
Add is_finite method for checking built-in types
This commit is contained in:
@@ -479,6 +479,51 @@ TEST_CASE("[Vector3] Linear algebra methods") {
|
||||
Math::is_equal_approx(Vector3(-a.x, a.y, -a.z).dot(Vector3(b.x, -b.y, b.z)), (real_t)-75.24),
|
||||
"Vector3 dot should return expected value.");
|
||||
}
|
||||
|
||||
TEST_CASE("[Vector3] Finite number checks") {
|
||||
const double infinite[] = { NAN, INFINITY, -INFINITY };
|
||||
|
||||
CHECK_MESSAGE(
|
||||
Vector3(0, 1, 2).is_finite(),
|
||||
"Vector3(0, 1, 2) should be finite");
|
||||
|
||||
for (double x : infinite) {
|
||||
CHECK_FALSE_MESSAGE(
|
||||
Vector3(x, 1, 2).is_finite(),
|
||||
"Vector3 with one component infinite should not be finite.");
|
||||
CHECK_FALSE_MESSAGE(
|
||||
Vector3(0, x, 2).is_finite(),
|
||||
"Vector3 with one component infinite should not be finite.");
|
||||
CHECK_FALSE_MESSAGE(
|
||||
Vector3(0, 1, x).is_finite(),
|
||||
"Vector3 with one component infinite should not be finite.");
|
||||
}
|
||||
|
||||
for (double x : infinite) {
|
||||
for (double y : infinite) {
|
||||
CHECK_FALSE_MESSAGE(
|
||||
Vector3(x, y, 2).is_finite(),
|
||||
"Vector3 with two components infinite should not be finite.");
|
||||
CHECK_FALSE_MESSAGE(
|
||||
Vector3(x, 1, y).is_finite(),
|
||||
"Vector3 with two components infinite should not be finite.");
|
||||
CHECK_FALSE_MESSAGE(
|
||||
Vector3(0, x, y).is_finite(),
|
||||
"Vector3 with two components infinite should not be finite.");
|
||||
}
|
||||
}
|
||||
|
||||
for (double x : infinite) {
|
||||
for (double y : infinite) {
|
||||
for (double z : infinite) {
|
||||
CHECK_FALSE_MESSAGE(
|
||||
Vector3(x, y, z).is_finite(),
|
||||
"Vector3 with three components infinite should not be finite.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TestVector3
|
||||
|
||||
#endif // TEST_VECTOR3_H
|
||||
|
||||
Reference in New Issue
Block a user