Files
allwpilib/wpimath/src/test/native/cpp/controller/BangBangToleranceTest.cpp
Tyler Veness 9e8d37c03b [wpimath] Remove unhelpful test fixtures (#7344)
These test fixtures were adding complexity while only saving one line of
object initialization per test. Our other tests like this just make the
object at the top of each test.
2024-11-05 09:49:38 -07:00

24 lines
649 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"
TEST(BangBangToleranceTest, InTolerance) {
frc::BangBangController controller{0.1};
controller.SetSetpoint(1);
controller.Calculate(1);
EXPECT_TRUE(controller.AtSetpoint());
}
TEST(BangBangToleranceTest, OutOfTolerance) {
frc::BangBangController controller{0.1};
controller.SetSetpoint(1);
controller.Calculate(0);
EXPECT_FALSE(controller.AtSetpoint());
}