Skip to content

Commit

Permalink
boost test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Jan 8, 2025
1 parent 56b20eb commit 4a49882
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion unit_tests/tests/actuators/test_boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ TEST(BoostControl, Setpoint) {
// Configure TPS, should get passthru of tps value
Sensor::setMockValue(SensorType::DriverThrottleIntent, 35.0f);
EXPECT_FLOAT_EQ(bc.getSetpoint().value_or(-1), 35.0f);

// Back in open loop mode, setpoint should be 0
engineConfiguration->boostType = OPEN_LOOP;
EXPECT_FLOAT_EQ(bc.getSetpoint().value_or(-1), 0);
}

TEST(BoostControl, ObservePlant) {
Expand Down Expand Up @@ -90,14 +94,16 @@ TEST(BoostControl, TestClosedLoop) {
Sensor::setMockValue(SensorType::Rpm, 0);
EXPECT_EQ(0, bc.getClosedLoop(150, 100).value_or(-1000));

// too low MAP, disable closed loop
// Stopped engine, disable closed loop
Sensor::setMockValue(SensorType::Rpm, 0);
EXPECT_EQ(0, bc.getClosedLoop(150, 50).value_or(-1000));

// With RPM, we should get an output
Sensor::setMockValue(SensorType::Rpm, 1000);
// Actual is below target -> positive output
EXPECT_FLOAT_EQ(50, bc.getClosedLoop(150, 100).value_or(-1000));
// MAP below target -> returns 0, closed loop disabled
EXPECT_FLOAT_EQ(0, bc.getClosedLoop(150, 50).value_or(-1000));
// Actual is above target -> negative output
EXPECT_FLOAT_EQ(-25.0f, bc.getClosedLoop(150, 175).value_or(-1000));

Expand Down

0 comments on commit 4a49882

Please sign in to comment.