From 2f2489d1a72377f43fe224435f835c573ebb3380 Mon Sep 17 00:00:00 2001 From: FrancoisCarouge Date: Sun, 19 Jan 2025 14:57:47 -0800 Subject: [PATCH] [test] strongly typed test for expression template correctness --- test/kalman_f.cpp | 4 ++-- test/kalman_f_5x4x3.cpp | 8 ++++---- test/kalman_h_5x4x3.cpp | 8 ++++---- test/linalg_assign.cpp | 4 ++-- test/linalg_copy.cpp | 4 ++-- test/linalg_identity.cpp | 2 +- test/linalg_multiplication_sxc.cpp | 6 +++--- test/linalg_operator_equality.cpp | 6 +++--- test/linalg_zero.cpp | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/test/kalman_f.cpp b/test/kalman_f.cpp index 5e3cb23ebc..163a5f59ae 100644 --- a/test/kalman_f.cpp +++ b/test/kalman_f.cpp @@ -50,13 +50,13 @@ namespace { assert(filter.f() == 1); { - const auto f{2.}; + const double f{2.}; filter.f(f); assert(filter.f() == 2); } { - const auto f{3.}; + const double f{3.}; filter.f(f); assert(filter.f() == 3); } diff --git a/test/kalman_f_5x4x3.cpp b/test/kalman_f_5x4x3.cpp index d6e807d836..7e066e8b50 100644 --- a/test/kalman_f_5x4x3.cpp +++ b/test/kalman_f_5x4x3.cpp @@ -49,8 +49,8 @@ template using matrix = matrix; //! @test Verifies the state transition matrix F management overloads for //! the Eigen filter type. [[maybe_unused]] auto test{[] { - const auto i5x5{identity>}; - const auto z5x5{zero>}; + const matrix<5, 5> i5x5{identity>}; + const matrix<5, 5> z5x5{zero>}; kalman filter{state{vector<5>{0., 0., 0., 0., 0.}}, output>, input>, update_types, prediction_types}; @@ -58,13 +58,13 @@ template using matrix = matrix; assert(filter.f() == i5x5); { - const auto f{z5x5}; + const matrix<5, 5> f{z5x5}; filter.f(f); assert(filter.f() == z5x5); } { - const auto f{i5x5}; + const matrix<5, 5> f{i5x5}; filter.f(f); assert(filter.f() == i5x5); } diff --git a/test/kalman_h_5x4x3.cpp b/test/kalman_h_5x4x3.cpp index 00cf0da786..16b4369730 100644 --- a/test/kalman_h_5x4x3.cpp +++ b/test/kalman_h_5x4x3.cpp @@ -49,8 +49,8 @@ template using matrix = matrix; //! @test Verifies the observation transition matrix H management overloads for //! the Eigen filter type. [[maybe_unused]] auto test{[] { - const auto i4x5{identity>}; - const auto z4x5{zero>}; + const matrix<4, 5> i4x5{identity>}; + const matrix<4, 5> z4x5{zero>}; kalman filter{state{vector<5>{0., 0., 0., 0., 0.}}, output>, input>, update_types, prediction_types}; @@ -58,13 +58,13 @@ template using matrix = matrix; assert(filter.h() == i4x5); { - const auto h{z4x5}; + const matrix<4, 5> h{z4x5}; filter.h(h); assert(filter.h() == z4x5); } { - const auto h{i4x5}; + const matrix<4, 5> h{i4x5}; filter.h(h); assert(filter.h() == i4x5); } diff --git a/test/linalg_assign.cpp b/test/linalg_assign.cpp index 898b4d29da..a2efda8bde 100644 --- a/test/linalg_assign.cpp +++ b/test/linalg_assign.cpp @@ -44,8 +44,8 @@ namespace fcarouge::test { namespace { //! @test Verifies the assignment operator. [[maybe_unused]] auto test{[] { - auto m{identity>}; - auto c = m; + const matrix m{identity>}; + const matrix c = m; assert((c == identity>)); diff --git a/test/linalg_copy.cpp b/test/linalg_copy.cpp index f72dd24653..715495d70b 100644 --- a/test/linalg_copy.cpp +++ b/test/linalg_copy.cpp @@ -44,8 +44,8 @@ namespace fcarouge::test { namespace { //! @test Verifies the copy constructor. [[maybe_unused]] auto test{[] { - auto m{identity>}; - auto c{m}; + const matrix m{identity>}; + const matrix c{m}; assert((c == identity>)); diff --git a/test/linalg_identity.cpp b/test/linalg_identity.cpp index afd51d3151..6e9c055713 100644 --- a/test/linalg_identity.cpp +++ b/test/linalg_identity.cpp @@ -44,7 +44,7 @@ namespace fcarouge::test { namespace { //! @test Verifies the identity matrices values are unit diagonals. [[maybe_unused]] auto test{[] { - auto i{identity>}; + const matrix i{identity>}; assert(i(0, 0) == 1.0); assert(i(0, 1) == 0.0); diff --git a/test/linalg_multiplication_sxc.cpp b/test/linalg_multiplication_sxc.cpp index b964f8e017..cc0aa70c82 100644 --- a/test/linalg_multiplication_sxc.cpp +++ b/test/linalg_multiplication_sxc.cpp @@ -44,9 +44,9 @@ namespace fcarouge::test { namespace { //! @test Verifies the assignment operator. [[maybe_unused]] auto test{[] { - matrix a{{1.0, 2.0}, {3.0, 4.0}}; - matrix b{3.0, 4.0}; - auto r{a * b}; + const matrix a{{1.0, 2.0}, {3.0, 4.0}}; + const matrix b{3.0, 4.0}; + const matrix r{a * b}; assert(r(0, 0) == 11.0); assert(r(1, 0) == 25.0); diff --git a/test/linalg_operator_equality.cpp b/test/linalg_operator_equality.cpp index c35019a4a1..df254a480d 100644 --- a/test/linalg_operator_equality.cpp +++ b/test/linalg_operator_equality.cpp @@ -44,9 +44,9 @@ namespace fcarouge::test { namespace { //! @test Verifies the equality operator. [[maybe_unused]] auto test{[] { - auto m{zero>}; - auto i{identity>}; - auto z{zero>}; + const matrix m{zero>}; + const matrix i{identity>}; + const matrix z{zero>}; assert(m == z); assert(m != i); diff --git a/test/linalg_zero.cpp b/test/linalg_zero.cpp index a59509a50a..a735e5545a 100644 --- a/test/linalg_zero.cpp +++ b/test/linalg_zero.cpp @@ -44,7 +44,7 @@ namespace fcarouge::test { namespace { //! @test Verifies the zero matrices values are null. [[maybe_unused]] auto test{[] { - auto z{zero>}; + const matrix z{zero>}; assert(z(0, 0) == 0.0); assert(z(0, 1) == 0.0);