forked from rusefi/rusefi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_nitrous_fuel_adder.cpp
More file actions
59 lines (48 loc) · 2.02 KB
/
Copy pathtest_nitrous_fuel_adder.cpp
File metadata and controls
59 lines (48 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// Created by kifir on 12/5/24.
//
#include "pch.h"
#include "nitrous_test_base.h"
namespace {
class NitrousFuelAdderTest : public NitrousTestBase {
protected:
static constexpr int8_t TEST_NITROUS_FUEL_ADDER_PERCENT = 17;
static constexpr float DEFAULT_FUEL_CORRECTION = 1.009999f;
static const CltFuelCorrCurve TEST_CLT_FUEL_CORR;
void checkTotalFuelCorrection(
bool expectedNitrousCondition,
float expectedTotalFuelCorrection,
const char* context
);
public:
static CltFuelCorrCurve generateTestCltFuelCorrCurve();
};
void NitrousFuelAdderTest::checkTotalFuelCorrection(
const bool expectedNitrousCondition,
const float expectedTotalFuelCorrection,
const char* const context
) {
periodicFastCallback(); // to recalculate total fuel correction
checkNitrousCondition(expectedNitrousCondition, context);
EXPECT_NEAR(engine->fuelComputer.totalFuelCorrection, expectedTotalFuelCorrection, EPS5D) << context;
}
CltFuelCorrCurve NitrousFuelAdderTest::generateTestCltFuelCorrCurve() {
CltFuelCorrCurve result;
result.fill(DEFAULT_FUEL_CORRECTION);
return result;
}
const CltFuelCorrCurve NitrousFuelAdderTest::TEST_CLT_FUEL_CORR = NitrousFuelAdderTest::generateTestCltFuelCorrCurve();
TEST_F(NitrousFuelAdderTest, checkFuelCorrection) {
setUpTestConfiguration({ TEST_NITROUS_FUEL_ADDER_PERCENT });
getTestPersistentConfiguration().setCltFuelCorrCurve(TEST_CLT_FUEL_CORR); // constant fuel CLT correction
checkTotalFuelCorrection(false, DEFAULT_FUEL_CORRECTION, "Default");
activateNitrousControl();
checkTotalFuelCorrection(
true,
DEFAULT_FUEL_CORRECTION * (1.0f + TEST_NITROUS_FUEL_ADDER_PERCENT / 100.0f),
"All conditions are satisfied"
);
deactivateNitrousControl();
checkTotalFuelCorrection(false, DEFAULT_FUEL_CORRECTION, "No conditions are satisfied");
}
}