mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
28 lines
719 B
C++
28 lines
719 B
C++
// 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>
|
|
|
|
#include "wpi/hardware/motor/Spark.hpp"
|
|
|
|
namespace wpi::sim {
|
|
TEST(PWMMotorControllerSimTest, TestMotor) {
|
|
wpi::Spark spark{0};
|
|
wpi::sim::PWMMotorControllerSim sim{spark};
|
|
|
|
spark.SetThrottle(0);
|
|
EXPECT_EQ(0, sim.GetThrottle());
|
|
|
|
spark.SetThrottle(0.354);
|
|
EXPECT_EQ(0.354, sim.GetThrottle());
|
|
|
|
spark.SetThrottle(-0.785);
|
|
EXPECT_EQ(-0.785, sim.GetThrottle());
|
|
}
|
|
} // namespace wpi::sim
|