Skip to content

Commit

Permalink
Add test for wrong parameterization
Browse files Browse the repository at this point in the history
  • Loading branch information
christophfroehlich committed Oct 13, 2024
1 parent 840b0e6 commit 2c35a8c
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test/speed_limiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,63 @@
// limitations under the License.

#include <gmock/gmock.h>
#include <limits>

#include "control_toolbox/speed_limiter.hpp"


TEST(SpeedLimiterTest, testWrongParams)
{
EXPECT_THROW(control_toolbox::SpeedLimiter limiter(true, true, true,
-1.0, std::numeric_limits<double>::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<double>::quiet_NaN(), std::numeric_limits<double>::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<double>::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<double>::quiet_NaN(), std::numeric_limits<double>::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<double>::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<double>::quiet_NaN(), std::numeric_limits<double>::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<double>::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<double>::quiet_NaN(), std::numeric_limits<double>::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<double>::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<double>::quiet_NaN(), std::numeric_limits<double>::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<double>::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<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()));
}

TEST(SpeedLimiterTest, testNoLimits)
{
control_toolbox::SpeedLimiter limiter;
Expand Down

0 comments on commit 2c35a8c

Please sign in to comment.