mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
27 lines
694 B
C++
27 lines
694 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.
|
||
|
|
|
||
|
|
#include "frc/simulation/PWMMotorControllerSim.h" // NOLINT(build/include_order)
|
||
|
|
|
||
|
|
#include <gtest/gtest.h>
|
||
|
|
#include <hal/HAL.h>
|
||
|
|
|
||
|
|
#include "frc/motorcontrol/Spark.h"
|
||
|
|
|
||
|
|
namespace frc::sim {
|
||
|
|
TEST(PWMMotorControllerSimTest, TestMotor) {
|
||
|
|
frc::Spark spark{0};
|
||
|
|
frc::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());
|
||
|
|
}
|
||
|
|
} // namespace frc::sim
|