Files
allwpilib/wpilibcIntegrationTests/src/main/native/cpp/AnalogPotentiometerTest.cpp
Tyler Veness 93523d572e [wpilibc] Clean up integration tests (#3400)
The command and shuffleboard integration tests were removed because
their unit tests counterparts already provide adequate coverage. Java
already removed these.
2021-05-31 10:21:34 -07:00

35 lines
1.2 KiB
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/AnalogPotentiometer.h" // NOLINT(build/include_order)
#include "TestBench.h"
#include "frc/AnalogOutput.h"
#include "frc/RobotController.h"
#include "frc/Timer.h"
#include "gtest/gtest.h"
static constexpr double kScale = 270.0;
static constexpr double kAngle = 180.0;
TEST(AnalogPotentiometerTest, TestInitialSettings) {
frc::AnalogOutput m_fakePot{TestBench::kAnalogOutputChannel};
frc::AnalogPotentiometer m_pot{TestBench::kFakeAnalogOutputChannel, kScale};
m_fakePot.SetVoltage(0.0);
frc::Wait(100_ms);
EXPECT_NEAR(0.0, m_pot.Get(), 5.0)
<< "The potentiometer did not initialize to 0.";
}
TEST(AnalogPotentiometerTest, TestRangeValues) {
frc::AnalogOutput m_fakePot{TestBench::kAnalogOutputChannel};
frc::AnalogPotentiometer m_pot{TestBench::kFakeAnalogOutputChannel, kScale};
m_fakePot.SetVoltage(kAngle / kScale * frc::RobotController::GetVoltage5V());
frc::Wait(100_ms);
EXPECT_NEAR(kAngle, m_pot.Get(), 2.0)
<< "The potentiometer did not measure the correct angle.";
}