mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
25 lines
677 B
C++
25 lines
677 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 <gtest/gtest.h>
|
|
|
|
#include "frc/controller/BangBangController.h"
|
|
|
|
class BangBangToleranceTest : public testing::Test {
|
|
protected:
|
|
frc::BangBangController controller{0.1};
|
|
};
|
|
|
|
TEST_F(BangBangToleranceTest, InTolerance) {
|
|
controller.SetSetpoint(1);
|
|
controller.Calculate(1);
|
|
EXPECT_TRUE(controller.AtSetpoint());
|
|
}
|
|
|
|
TEST_F(BangBangToleranceTest, OutOfTolerance) {
|
|
controller.SetSetpoint(1);
|
|
controller.Calculate(0);
|
|
EXPECT_FALSE(controller.AtSetpoint());
|
|
}
|