2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2021-03-14 16:31:46 -07:00
|
|
|
#include "vvt.h"
|
|
|
|
|
|
|
|
using ::testing::StrictMock;
|
|
|
|
using ::testing::Return;
|
|
|
|
|
|
|
|
TEST(Vvt, setpoint) {
|
|
|
|
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
|
|
|
|
|
|
|
// Set up a mock target map
|
|
|
|
StrictMock<MockVp3d> targetMap;
|
|
|
|
EXPECT_CALL(targetMap, getValue(4321, 55))
|
|
|
|
.WillOnce(Return(20));
|
|
|
|
|
|
|
|
// Mock necessary inputs
|
|
|
|
engine->engineState.fuelingLoad = 55;
|
|
|
|
engine->rpmCalculator.mockRpm = 4321;
|
|
|
|
|
|
|
|
VvtController dut;
|
|
|
|
INJECT_ENGINE_REFERENCE(&dut);
|
2021-03-25 04:39:23 -07:00
|
|
|
dut.init(0, 0, 0, &targetMap);
|
2021-03-14 16:31:46 -07:00
|
|
|
|
|
|
|
// Test dut
|
|
|
|
EXPECT_EQ(20, dut.getSetpoint().value_or(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Vvt, observePlant) {
|
|
|
|
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
|
|
|
|
|
|
|
engine->triggerCentral.vvtPosition[0][0] = 23;
|
|
|
|
|
|
|
|
VvtController dut;
|
|
|
|
INJECT_ENGINE_REFERENCE(&dut);
|
2021-03-25 04:39:23 -07:00
|
|
|
dut.init(0, 0, 0, nullptr);
|
2021-03-14 16:31:46 -07:00
|
|
|
|
|
|
|
EXPECT_EQ(23, dut.observePlant().value_or(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Vvt, openLoop) {
|
|
|
|
VvtController dut;
|
|
|
|
|
|
|
|
// No open loop for now
|
|
|
|
EXPECT_EQ(dut.getOpenLoop(10), 0);
|
|
|
|
}
|