Skip to content

Commit 2d94da0

Browse files
authored
test(autoware_kalman_filter): add tests for missed lines (#263)
Signed-off-by: NorahXiong <norah.xiong@autocore.ai>
1 parent 4cad2fe commit 2d94da0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

common/autoware_kalman_filter/test/test_kalman_filter.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ TEST(kalman_filter, kf)
8686
EXPECT_NEAR(x_update(1, 0), x_update_expected(1, 0), 1e-5);
8787
EXPECT_NEAR(P_update(0, 0), P_update_expected(0, 0), 1e-5);
8888
EXPECT_NEAR(P_update(1, 1), P_update_expected(1, 1), 1e-5);
89+
90+
// Add tests to cover missed lines
91+
92+
KalmanFilter kf_new(x_t, A_t, B_t, C_t, Q_t, R_t, P_t);
93+
kf_new.init(x_t, P_t);
94+
kf_new.setA(A_t);
95+
kf_new.setB(B_t);
96+
kf_new.setC(C_t);
97+
kf_new.setQ(Q_t);
98+
kf_new.setR(R_t);
99+
100+
EXPECT_TRUE(kf_new.predict(x_predict_expected, A_t));
101+
P_predict_expected = A_t * P_t * A_t.transpose() + Q_t;
102+
kf_new.getP(P_predict);
103+
EXPECT_NEAR(P_predict(0, 0), P_predict_expected(0, 0), 1e-5);
104+
EXPECT_NEAR(P_predict(1, 1), P_predict_expected(1, 1), 1e-5);
89105
}
90106

91107
int main(int argc, char * argv[])

0 commit comments

Comments
 (0)