forked from rusefi/rusefi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_nitrous_tps_condition.cpp
More file actions
94 lines (82 loc) · 3.42 KB
/
Copy pathtest_nitrous_tps_condition.cpp
File metadata and controls
94 lines (82 loc) · 3.42 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//
// Created by kifir on 11/28/24.
//
#include "pch.h"
#include "engine_configuration_defaults.h"
#include "util/test_base.h"
namespace {
struct TpsConditionTestData {
const std::optional<float> tps;
const bool expectedTpsCondition;
const char* const context;
};
class NitrousTpsConditionTest : public TestBase<> {
protected:
static constexpr int TEST_MIN_TPS = 34;
void checkTpsCondition(const std::vector<TpsConditionTestData>& testData);
};
void NitrousTpsConditionTest::checkTpsCondition(const std::vector<TpsConditionTestData>& testData) {
for (const TpsConditionTestData& item: testData) {
updateApp(item.tps, &TestBase::periodicSlowCallback);
EXPECT_EQ(getModule<NitrousController>().isNitrousTpsCondition, item.expectedTpsCondition)
<< item.context;
}
}
TEST_F(NitrousTpsConditionTest, checkDefault) {
checkTpsCondition({
{ {}, false, "default" },
{ { 0.0f }, false, "0.0" },
{ { TEST_MIN_TPS - EPS5D }, false, "TEST_MIN_TPS - EPS5D" },
{ { TEST_MIN_TPS }, false, "TEST_MIN_TPS" },
{ { TEST_MIN_TPS + EPS5D }, false, "TEST_MIN_TPS + EPS5D" },
});
}
TEST_F(NitrousTpsConditionTest, checkDefaultWithDisabledNitrousControl) {
setUpEngineConfiguration(EngineConfig().setNitrousControlEnabled({ false }));
checkTpsCondition({
{ {}, false, "default" },
{ { 0.0f }, false, "0.0" },
{ { TEST_MIN_TPS - EPS5D }, false, "TEST_MIN_TPS - EPS5D" },
{ { TEST_MIN_TPS }, false, "TEST_MIN_TPS" },
{ { TEST_MIN_TPS + EPS5D }, false, "TEST_MIN_TPS + EPS5D" },
});
}
TEST_F(NitrousTpsConditionTest, checkDefaultWithEnabledNitrousControl) {
setUpEngineConfiguration(EngineConfig().setNitrousControlEnabled({ true }));
checkTpsCondition({
{ {}, false, "default" },
{ { 0.0f }, false, "0.0" },
{ { engine_configuration_defaults::NITROUS_MINIMUM_TPS - EPS5D }, false, "NITROUS_MINIMUM_TPS - EPS5D" },
{ { engine_configuration_defaults::NITROUS_MINIMUM_TPS }, true, "NITROUS_MINIMUM_TPS" },
{ { engine_configuration_defaults::NITROUS_MINIMUM_TPS + EPS5D }, true, "NITROUS_MINIMUM_TPS + EPS5D" },
});
}
TEST_F(NitrousTpsConditionTest, checkZeroMinimumTps) {
setUpEngineConfiguration(
EngineConfig()
.setNitrousControlEnabled({ true })
.setNitrousMinimumTps(0.0f)
);
checkTpsCondition({
{ {}, true, "default" },
{ { 0.0f }, true, "0.0" },
{ { TEST_MIN_TPS - EPS5D }, true, "TEST_MIN_TPS - EPS5D" },
{ { TEST_MIN_TPS }, true, "TEST_MIN_TPS" },
{ { TEST_MIN_TPS + EPS5D }, true, "TEST_MIN_TPS + EPS5D" },
});
}
TEST_F(NitrousTpsConditionTest, checkMinimumTps) {
setUpEngineConfiguration(
EngineConfig()
.setNitrousControlEnabled({ true })
.setNitrousMinimumTps({ TEST_MIN_TPS })
);
checkTpsCondition({
{ {}, false, "default" },
{ { 0.0f }, false, "0.0" },
{ { TEST_MIN_TPS - EPS5D }, false, "TEST_MIN_TPS - EPS5D" },
{ { TEST_MIN_TPS }, true, "TEST_MIN_TPS" },
{ { TEST_MIN_TPS + EPS5D }, true, "TEST_MIN_TPS + EPS5D" },
});
}
}