27 lines
641 B
C++
27 lines
641 B
C++
#ifndef FILTER_TEST_CPP
|
|
#define FILTER_TEST_CPP
|
|
#include <gtest/gtest.h>
|
|
#include "filter.h"
|
|
|
|
TEST(PT1FilterTest, InitialOutputIsZero) {
|
|
PT1Filter filter(0.1, 0.01);
|
|
EXPECT_DOUBLE_EQ(filter.update(0.0), 0.0);
|
|
}
|
|
|
|
TEST(PT1FilterTest, StepResponse) {
|
|
PT1Filter filter(0.1, 0.01);
|
|
double output = 0.0;
|
|
for (int i = 0; i < 100; ++i) {
|
|
output = filter.update(1.0);
|
|
}
|
|
EXPECT_NEAR(output, 1.0, 0.01);
|
|
}
|
|
|
|
TEST(PT1FilterTest, FilterFactorEffect) {
|
|
PT1Filter fastFilter(0.01, 0.01);
|
|
PT1Filter slowFilter(0.5, 0.01);
|
|
EXPECT_GT(fastFilter.update(1.0), slowFilter.update(1.0));
|
|
}
|
|
|
|
#endif // FILTER_TEST_CPP
|