Skip to content

Added missing equality operations for DCMotor class #7888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jonathandao0
Copy link

Added missing equality operations for the DCMotor class. Currently, the following case fails:

var gearboxA = DCMotor.getKrakenX60(2);
var gearboxB = DCMotor.getKrakenX60(2);

gearboxA.equals(gearboxB); // returns false, should return true

@jonathandao0 jonathandao0 requested a review from a team as a code owner April 5, 2025 23:56
@github-actions github-actions bot added the component: wpimath Math library label Apr 5, 2025

using namespace frc;

TEST(DCMotorTest, Equality) {
Copy link
Member

@calcmogul calcmogul Apr 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test isn't really necessary. It's a compiler-generated equality operator, and we don't write equality tests for other objects like this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't Pose2dTest.cpp implement this? Or is this just auto generated? I was looking at other cpp tests for reference of what to add (I'm not a heavy cpp user).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only test the ones with non-default implementations.

[tav@myriad cpp]$ rg Equality
kinematics/SwerveModuleStateTest.cpp
130:TEST(SwerveModuleStateTest, Equality) {

kinematics/SwerveModulePositionTest.cpp
10:TEST(SwerveModulePositionTest, Equality) {

geometry/Rotation2dTest.cpp
65:TEST(Rotation2dTest, Equality) {

geometry/Pose2dTest.cpp
65:TEST(Pose2dTest, Equality) {

geometry/Translation3dTest.cpp
132:TEST(Translation3dTest, Equality) {

geometry/QuaternionTest.cpp
216:TEST(QuaternionTest, DotProductAsEquality) {

geometry/Twist3dTest.cpp
58:TEST(Twist3dTest, Equality) {

geometry/Translation2dTest.cpp
85:TEST(Translation2dTest, Equality) {

geometry/Rotation3dTest.cpp
290:TEST(Rotation3dTest, Equality) {

geometry/Twist2dTest.cpp
42:TEST(Twist2dTest, Equality) {

geometry/Pose3dTest.cpp
99:TEST(Pose3dTest, Equality) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants