Files
allwpilib/wpilibc/src/test/native/cpp/simulation/PWMMotorControlllerSimTest.cpp

28 lines
686 B
C++
Raw Normal View History

// 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.
// clang-format off
#include "wpi/simulation/PWMMotorControllerSim.hpp"
// clang-format on
#include <gtest/gtest.h>
2025-11-07 19:56:21 -05:00
#include "wpi/hardware/motor/Spark.hpp"
2025-11-07 20:00:05 -05:00
namespace wpi::sim {
TEST(PWMMotorControllerSimTest, TestMotor) {
2025-11-07 20:00:05 -05:00
wpi::Spark spark{0};
wpi::sim::PWMMotorControllerSim sim{spark};
spark.Set(0);
EXPECT_EQ(0, sim.GetSpeed());
spark.Set(0.354);
EXPECT_EQ(0.354, sim.GetSpeed());
spark.Set(-0.785);
EXPECT_EQ(-0.785, sim.GetSpeed());
}
2025-11-07 20:00:05 -05:00
} // namespace wpi::sim