From 2c35a8cd292f4e0cada5785cfb5738e715c78eaa Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 13 Oct 2024 23:48:24 +0000 Subject: [PATCH] Add test for wrong parameterization --- test/speed_limiter.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/speed_limiter.cpp b/test/speed_limiter.cpp index 887df9a5..8668629a 100644 --- a/test/speed_limiter.cpp +++ b/test/speed_limiter.cpp @@ -13,10 +13,63 @@ // limitations under the License. #include +#include #include "control_toolbox/speed_limiter.hpp" +TEST(SpeedLimiterTest, testWrongParams) +{ + EXPECT_THROW(control_toolbox::SpeedLimiter limiter(true, true, true, + -1.0, std::numeric_limits::quiet_NaN(), + -1.0, 1.0, -1.0, 1.0), + std::runtime_error); + EXPECT_THROW(control_toolbox::SpeedLimiter limiter(true, true, true, + std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), + -1.0, 1.0, -1.0, 1.0), + std::runtime_error); + EXPECT_NO_THROW(control_toolbox::SpeedLimiter limiter(true, true, true, + std::numeric_limits::quiet_NaN(), -1.0, + -1.0, 1.0, -1.0, 1.0)); + EXPECT_NO_THROW(control_toolbox::SpeedLimiter limiter(false, true, true, + std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), + -1.0, 1.0, -1.0, 1.0)); + + EXPECT_THROW(control_toolbox::SpeedLimiter limiter(true, true, true, + -1.0, 1.0, + -1.0, std::numeric_limits::quiet_NaN(), + -1.0, 1.0), + std::runtime_error); + EXPECT_THROW(control_toolbox::SpeedLimiter limiter(true, true, true, + -1.0, 1.0, + std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), + -1.0, 1.0), + std::runtime_error); + EXPECT_NO_THROW(control_toolbox::SpeedLimiter limiter(true, true, true, + -1.0, 1.0, + std::numeric_limits::quiet_NaN(), -1.0, + -1.0, 1.0)); + EXPECT_NO_THROW(control_toolbox::SpeedLimiter limiter(true, false, true, + -1.0, 1.0, + std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), + -1.0, 1.0)); + + EXPECT_THROW(control_toolbox::SpeedLimiter limiter(true, true, true, + -1.0, 1.0, -1.0, 1.0, + -1.0, std::numeric_limits::quiet_NaN()), + std::runtime_error); + EXPECT_THROW(control_toolbox::SpeedLimiter limiter(true, true, true, + -1.0, 1.0, -1.0, 1.0, + std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN()), + std::runtime_error); + EXPECT_NO_THROW(control_toolbox::SpeedLimiter limiter(true, true, true, + -1.0, 1.0, -1.0, 1.0, + std::numeric_limits::quiet_NaN(), 1.0)); + EXPECT_NO_THROW(control_toolbox::SpeedLimiter limiter(true, true, false, + -1.0, 1.0, -1.0, 1.0, + std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN())); +} + TEST(SpeedLimiterTest, testNoLimits) { control_toolbox::SpeedLimiter limiter;