Add upper boundary checks for tilt sensitivity settings

The tilt sensitivity values were passed to the NVS module without
the boundaries being checked, even though the maximum
percent value is 100. This commit fixes this issue.
Also test cases are added to cover the upper boundary checks
for the tilt sensitivity settings.

Fixes #1086
This commit is contained in:
2025-08-26 17:43:19 +03:00
parent 0b75df35d1
commit 9a6b8c9f80
3 changed files with 46 additions and 0 deletions

View File

@@ -205,6 +205,18 @@ TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivi
TEST_ASSERT_EQUAL_UINT8(42, relay_chn_tilt_get_sensitivity());
}
// Test sensitivity upper boundary
TEST_CASE("relay_chn_tilt_set_sensitivity handles upper boundary", "[relay_chn][tilt][sensitivity]")
{
// Set sensitivity to a value greater than 100
relay_chn_tilt_set_sensitivity(101);
// It should be capped at 100
TEST_ASSERT_EQUAL_UINT8(100, relay_chn_tilt_get_sensitivity());
relay_chn_tilt_set_sensitivity(200);
TEST_ASSERT_EQUAL_UINT8(100, relay_chn_tilt_get_sensitivity());
}
// Test tilt counter logic: forward x3, reverse x3, extra reverse fails
TEST_CASE("tilt counter logic: forward and reverse consumption", "[relay_chn][tilt][counter]")
{