refactoring: extracting method

This commit is contained in:
Andrey 2022-11-29 20:11:34 -05:00
parent ddc9971a2a
commit b97745496e
1 changed files with 21 additions and 3 deletions

View File

@ -3,8 +3,7 @@
#include "electronic_throttle_impl.h" #include "electronic_throttle_impl.h"
#include "live_data.h" #include "live_data.h"
TEST(etb, integrated) { static EtbController * initEtbIntegratedTest() {
EngineTestHelper eth(TEST_ENGINE);
etbPidReset(); // ETB controlles are global shared instances :( etbPidReset(); // ETB controlles are global shared instances :(
engineConfiguration->tps1_1AdcChannel = EFI_ADC_3; engineConfiguration->tps1_1AdcChannel = EFI_ADC_3;
@ -20,8 +19,13 @@ TEST(etb, integrated) {
initTps(); initTps();
doInitElectronicThrottle(); doInitElectronicThrottle();
return (EtbController*)engine->etbControllers[0];
}
TEST(etb, integrated) {
EngineTestHelper eth(TEST_ENGINE); // we have a distractor so cannot move EngineTestHelper into utility method
EtbController *etb = initEtbIntegratedTest();
EtbController *etb = (EtbController*)engine->etbControllers[0];
etb->update(); etb->update();
ASSERT_EQ(engine->outputChannels.etbTarget, 40); ASSERT_EQ(engine->outputChannels.etbTarget, 40);
@ -38,3 +42,17 @@ TEST(etb, integrated) {
copyRange((uint8_t*)&destination, getLiveDataFragments(), offset, sizeof(destination)); copyRange((uint8_t*)&destination, getLiveDataFragments(), offset, sizeof(destination));
ASSERT_EQ(destination, -75); ASSERT_EQ(destination, -75);
} }
TEST(etb, integratedTpsJitter) {
EngineTestHelper eth(TEST_ENGINE); // we have a distractor so cannot move EngineTestHelper into utility method
EtbController *etb = initEtbIntegratedTest();
ASSERT_FALSE(isTps1Error());
ASSERT_FALSE(isTps2Error());
ASSERT_FALSE(isPedalError());
etb->update();
}