mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Fix swerve kinematics util classes equals function (#4907)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/geometry/Rotation2d.h"
|
||||
#include "frc/kinematics/SwerveModulePosition.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(SwerveModulePositionTest, Equality) {
|
||||
frc::SwerveModulePosition position1{2_m, 90_deg};
|
||||
frc::SwerveModulePosition position2{2_m, 90_deg};
|
||||
|
||||
EXPECT_EQ(position1, position2);
|
||||
}
|
||||
|
||||
TEST(SwerveModulePositionTest, Inequality) {
|
||||
frc::SwerveModulePosition position1{1_m, 90_deg};
|
||||
frc::SwerveModulePosition position2{2_m, 90_deg};
|
||||
frc::SwerveModulePosition position3{1_m, 89_deg};
|
||||
|
||||
EXPECT_NE(position1, position2);
|
||||
EXPECT_NE(position1, position3);
|
||||
}
|
||||
@@ -39,3 +39,19 @@ TEST(SwerveModuleStateTest, NoOptimize) {
|
||||
EXPECT_NEAR(optimizedB.speed.value(), -2.0, kEpsilon);
|
||||
EXPECT_NEAR(optimizedB.angle.Degrees().value(), -2.0, kEpsilon);
|
||||
}
|
||||
|
||||
TEST(SwerveModuleStateTest, Equality) {
|
||||
frc::SwerveModuleState state1{2_mps, 90_deg};
|
||||
frc::SwerveModuleState state2{2_mps, 90_deg};
|
||||
|
||||
EXPECT_EQ(state1, state2);
|
||||
}
|
||||
|
||||
TEST(SwerveModuleStateTest, Inequality) {
|
||||
frc::SwerveModuleState state1{1_mps, 90_deg};
|
||||
frc::SwerveModuleState state2{2_mps, 90_deg};
|
||||
frc::SwerveModuleState state3{1_mps, 89_deg};
|
||||
|
||||
EXPECT_NE(state1, state2);
|
||||
EXPECT_NE(state1, state3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user