mirror of
https://gitlvb.teallvbs.xyz/IQ.Lvbs/IQ.Pilot.git
synced 2026-08-24 05:33:43 +08:00
IQ.Pilot Release Commit @ 2b39aa6
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from cereal import car
|
||||
|
||||
from openpilot.selfdrive.selfdrived.selfdrived import _cleanup_startup_params
|
||||
from openpilot.selfdrive.selfdrived.selfdrived import _cleanup_startup_params, get_sanitize_int_param
|
||||
|
||||
|
||||
class DummyParams:
|
||||
@@ -21,3 +21,20 @@ class TestLongitudinalPrefPersistence:
|
||||
_cleanup_startup_params(cp, params)
|
||||
|
||||
assert params.removed == []
|
||||
|
||||
def test_invalid_personality_is_clamped_before_use(self):
|
||||
class ParamsWithInvalidPersonality:
|
||||
def __init__(self):
|
||||
self.value = 3
|
||||
|
||||
def get(self, key: str, return_default: bool = False) -> int:
|
||||
assert key == "LongitudinalPersonality"
|
||||
return self.value
|
||||
|
||||
def put(self, key: str, value: int) -> None:
|
||||
assert key == "LongitudinalPersonality"
|
||||
self.value = value
|
||||
|
||||
params = ParamsWithInvalidPersonality()
|
||||
assert get_sanitize_int_param("LongitudinalPersonality", 0, 2, params) == 2
|
||||
assert params.value == 2
|
||||
|
||||
Reference in New Issue
Block a user