mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add equality comparator to geometry classes (#1882)
This commit is contained in:
committed by
Peter Johnson
parent
62f07c182c
commit
86b666bba9
@@ -40,3 +40,15 @@ TEST(Pose2dTest, RelativeTo) {
|
||||
EXPECT_NEAR(finalRelativeToInitial.Rotation().Degrees().to<double>(), 0.0,
|
||||
kEpsilon);
|
||||
}
|
||||
|
||||
TEST(Pose2dTest, Equality) {
|
||||
const Pose2d a{0_m, 5_m, Rotation2d(43_deg)};
|
||||
const Pose2d b{0_m, 5_m, Rotation2d(43_deg)};
|
||||
EXPECT_TRUE(a == b);
|
||||
}
|
||||
|
||||
TEST(Pose2dTest, Inequality) {
|
||||
const Pose2d a{0_m, 5_m, Rotation2d(43_deg)};
|
||||
const Pose2d b{0_m, 5_ft, Rotation2d(43_deg)};
|
||||
EXPECT_TRUE(a != b);
|
||||
}
|
||||
|
||||
@@ -53,3 +53,15 @@ TEST(Rotation2dTest, Minus) {
|
||||
|
||||
EXPECT_NEAR((one - two).Degrees().to<double>(), 40.0, kEpsilon);
|
||||
}
|
||||
|
||||
TEST(Rotation2dTest, Equality) {
|
||||
const auto one = Rotation2d(43_deg);
|
||||
const auto two = Rotation2d(43_deg);
|
||||
EXPECT_TRUE(one == two);
|
||||
}
|
||||
|
||||
TEST(Rotation2dTest, Inequality) {
|
||||
const auto one = Rotation2d(43_deg);
|
||||
const auto two = Rotation2d(43.5_deg);
|
||||
EXPECT_TRUE(one != two);
|
||||
}
|
||||
|
||||
@@ -76,3 +76,15 @@ TEST(Translation2dTest, UnaryMinus) {
|
||||
EXPECT_NEAR(inverted.X().to<double>(), 4.5, kEpsilon);
|
||||
EXPECT_NEAR(inverted.Y().to<double>(), -7, kEpsilon);
|
||||
}
|
||||
|
||||
TEST(Translation2dTest, Equality) {
|
||||
const Translation2d one{9_m, 5.5_m};
|
||||
const Translation2d two{9_m, 5.5_m};
|
||||
EXPECT_TRUE(one == two);
|
||||
}
|
||||
|
||||
TEST(Translation2dTest, Inequality) {
|
||||
const Translation2d one{9_m, 5.5_m};
|
||||
const Translation2d two{9_m, 5.7_m};
|
||||
EXPECT_TRUE(one != two);
|
||||
}
|
||||
|
||||
@@ -44,3 +44,15 @@ TEST(Twist2dTest, DiagonalNoDtheta) {
|
||||
EXPECT_NEAR(diagonalPose.Translation().Y().to<double>(), 2.0, kEpsilon);
|
||||
EXPECT_NEAR(diagonalPose.Rotation().Degrees().to<double>(), 0.0, kEpsilon);
|
||||
}
|
||||
|
||||
TEST(Twist2dTest, Equality) {
|
||||
const Twist2d one{5.0_m, 1.0_m, 3.0_rad};
|
||||
const Twist2d two{5.0_m, 1.0_m, 3.0_rad};
|
||||
EXPECT_TRUE(one == two);
|
||||
}
|
||||
|
||||
TEST(Twist2dTest, Inequality) {
|
||||
const Twist2d one{5.0_m, 1.0_m, 3.0_rad};
|
||||
const Twist2d two{5.0_m, 1.2_m, 3.0_rad};
|
||||
EXPECT_TRUE(one != two);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user