2021-10-30 17:31:09 -07:00
|
|
|
#include "pch.h"
|
2021-01-10 17:29:20 -08:00
|
|
|
|
2020-04-06 06:16:26 -07:00
|
|
|
#include "deadband.h"
|
|
|
|
|
|
|
|
TEST(Deadband, OutsideDeadband) {
|
|
|
|
Deadband<5> d;
|
|
|
|
|
|
|
|
EXPECT_TRUE(d.gt(100, 0));
|
|
|
|
EXPECT_FALSE(d.gt(0, 100));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Deadband, InsideDeadband) {
|
|
|
|
Deadband<5> d;
|
|
|
|
|
|
|
|
// stick the state to true
|
|
|
|
EXPECT_TRUE(d.gt(10, 0));
|
|
|
|
|
|
|
|
// Make sure it stays there while inside the deadband
|
|
|
|
EXPECT_TRUE(d.gt(0, 0));
|
|
|
|
EXPECT_TRUE(d.gt(0, 1));
|
|
|
|
EXPECT_TRUE(d.gt(0, 2));
|
|
|
|
EXPECT_TRUE(d.gt(0, 3));
|
|
|
|
EXPECT_TRUE(d.gt(0, 4));
|
|
|
|
EXPECT_TRUE(d.gt(0, 4.99));
|
|
|
|
|
|
|
|
// Flip the state - it should now stick false
|
|
|
|
EXPECT_FALSE(d.gt(0, 5.01));
|
|
|
|
|
|
|
|
// Make sure it stays there while inside the deadband
|
|
|
|
EXPECT_FALSE(d.gt(0, 4.99));
|
|
|
|
EXPECT_FALSE(d.gt(0, 1));
|
|
|
|
EXPECT_FALSE(d.gt(0, -1));
|
|
|
|
EXPECT_FALSE(d.gt(0, -1));
|
|
|
|
EXPECT_FALSE(d.gt(0, -4.99));
|
|
|
|
|
|
|
|
// Now it should flip back
|
|
|
|
EXPECT_TRUE(d.gt(0, -5.01));
|
|
|
|
}
|