Fixed (copilot) unit tests
This commit is contained in:
parent
585a3b0fe5
commit
97d937e77c
@ -29,43 +29,43 @@ TEST(Polar, FromVector2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Polar, FromSpherical) {
|
TEST(Polar, FromSpherical) {
|
||||||
Spherical s;
|
SphericalSingle s;
|
||||||
Polar p;
|
Polar p;
|
||||||
|
|
||||||
s = Spherical(1, Angle::Degrees(0), Angle::Degrees(0));
|
s = SphericalSingle(1, Angle::Degrees(0), Angle::Degrees(0));
|
||||||
p = Polar::FromSpherical(s);
|
p = Polar::FromSpherical(s);
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ(p.distance, 1.0F) << "p.distance FromSpherical(1 0 0)";
|
EXPECT_FLOAT_EQ(p.distance, 1.0F) << "p.distance FromSpherical(1 0 0)";
|
||||||
EXPECT_FLOAT_EQ(p.angle.InDegrees(), 0.0F) << "p.angle FromSpherical(1 0 0)";
|
EXPECT_FLOAT_EQ(p.angle.InDegrees(), 0.0F) << "p.angle FromSpherical(1 0 0)";
|
||||||
|
|
||||||
s = Spherical(1, Angle::Degrees(45), Angle::Degrees(0));
|
s = SphericalSingle(1, Angle::Degrees(45), Angle::Degrees(0));
|
||||||
p = Polar::FromSpherical(s);
|
p = Polar::FromSpherical(s);
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ(p.distance, 1.0F) << "p.distance FromSpherical(1 45 0)";
|
EXPECT_FLOAT_EQ(p.distance, 1.0F) << "p.distance FromSpherical(1 45 0)";
|
||||||
EXPECT_FLOAT_EQ(p.angle.InDegrees(), 45.0F)
|
EXPECT_FLOAT_EQ(p.angle.InDegrees(), 45.0F)
|
||||||
<< "p.angle FromSpherical(1 45 0)";
|
<< "p.angle FromSpherical(1 45 0)";
|
||||||
|
|
||||||
s = Spherical(1, Angle::Degrees(-45), Angle::Degrees(0));
|
s = SphericalSingle(1, Angle::Degrees(-45), Angle::Degrees(0));
|
||||||
p = Polar::FromSpherical(s);
|
p = Polar::FromSpherical(s);
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ(p.distance, 1.0F) << "p.distance FromSpherical(1 -45 0)";
|
EXPECT_FLOAT_EQ(p.distance, 1.0F) << "p.distance FromSpherical(1 -45 0)";
|
||||||
EXPECT_FLOAT_EQ(p.angle.InDegrees(), -45.0F)
|
EXPECT_FLOAT_EQ(p.angle.InDegrees(), -45.0F)
|
||||||
<< "p.angle FromSpherical(1 -45 0)";
|
<< "p.angle FromSpherical(1 -45 0)";
|
||||||
|
|
||||||
s = Spherical(0, Angle::Degrees(0), Angle::Degrees(0));
|
s = SphericalSingle(0, Angle::Degrees(0), Angle::Degrees(0));
|
||||||
p = Polar::FromSpherical(s);
|
p = Polar::FromSpherical(s);
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ(p.distance, 0.0F) << "p.distance FromSpherical(0 0 0)";
|
EXPECT_FLOAT_EQ(p.distance, 0.0F) << "p.distance FromSpherical(0 0 0)";
|
||||||
EXPECT_FLOAT_EQ(p.angle.InDegrees(), 0.0F) << "p.angle FromSpherical(0 0 0)";
|
EXPECT_FLOAT_EQ(p.angle.InDegrees(), 0.0F) << "p.angle FromSpherical(0 0 0)";
|
||||||
|
|
||||||
s = Spherical(-1, Angle::Degrees(0), Angle::Degrees(0));
|
s = SphericalSingle(-1, Angle::Degrees(0), Angle::Degrees(0));
|
||||||
p = Polar::FromSpherical(s);
|
p = Polar::FromSpherical(s);
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ(p.distance, 1.0F) << "p.distance FromSpherical(-1 0 0)";
|
EXPECT_FLOAT_EQ(p.distance, 1.0F) << "p.distance FromSpherical(-1 0 0)";
|
||||||
EXPECT_FLOAT_EQ(p.angle.InDegrees(), -180.0F)
|
EXPECT_FLOAT_EQ(p.angle.InDegrees(), -180.0F)
|
||||||
<< "p.angle FromSpherical(-1 0 0)";
|
<< "p.angle FromSpherical(-1 0 0)";
|
||||||
|
|
||||||
s = Spherical(0, Angle::Degrees(0), Angle::Degrees(90));
|
s = SphericalSingle(0, Angle::Degrees(0), Angle::Degrees(90));
|
||||||
p = Polar::FromSpherical(s);
|
p = Polar::FromSpherical(s);
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ(p.distance, 0.0F) << "p.distance FromSpherical(0 0 90)";
|
EXPECT_FLOAT_EQ(p.distance, 0.0F) << "p.distance FromSpherical(0 0 90)";
|
||||||
@ -212,20 +212,19 @@ TEST(PolarOfTest, TestDistanceZero) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Edge Case 2: Testing with negative distance, angle should be adjusted
|
// Edge Case 2: Testing with negative distance, angle should be adjusted
|
||||||
// TEST(PolarOfTest, TestNegativeDistance) {
|
TEST(PolarOfTest, TestNegativeDistance) {
|
||||||
// PolarOf<float> p2(-10.0f, AngleOf<float>::Degrees(90.0f));
|
PolarOf<float> p2(-10.0f, AngleOf<float>::Degrees(90.0f));
|
||||||
// EXPECT_EQ(p2.distance, 10.0f); // Ensure distance is positive
|
EXPECT_EQ(p2.distance, 10.0f); // Ensure distance is positive
|
||||||
// EXPECT_NEAR(p2.angle.InDegrees(), 270.0f,
|
EXPECT_NEAR(p2.angle.InDegrees(), -90.0f,
|
||||||
// 0.0001f); // Ensure angle is normalized to 270 degrees (180 +
|
0.0001f); // Ensure angle is normalized to 270 degrees (180 + 90)
|
||||||
// 90)
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// Edge Case 3: Testing with positive distance and angle = 180
|
// Edge Case 3: Testing with positive distance and angle = 180
|
||||||
// TEST(PolarOfTest, TestPositiveDistance) {
|
TEST(PolarOfTest, TestPositiveDistance) {
|
||||||
// PolarOf<float> p3(100.0f, AngleOf<float>::Degrees(180.0f));
|
PolarOf<float> p3(100.0f, AngleOf<float>::Degrees(180.0f));
|
||||||
// EXPECT_EQ(p3.distance, 100.0f); // Ensure distance is correct
|
EXPECT_EQ(p3.distance, 100.0f); // Ensure distance is correct
|
||||||
// EXPECT_NEAR(p3.angle.InDegrees(), 180.0f, 0.0001f); // Ensure angle is
|
EXPECT_NEAR(p3.angle.InDegrees(), -180.0f,
|
||||||
// correct
|
0.0001f); // Ensure angle is correct
|
||||||
// }
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user