Add default tilt sensitivity get function
Added `relay_chn_tilt_get_default_sensitivity` function and test cases. Refs #1085 and fixes #1101
This commit is contained in:
@@ -322,6 +322,17 @@ TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivi
|
||||
TEST_ASSERT_EQUAL_UINT8_ARRAY(expect, vals, CONFIG_RELAY_CHN_COUNT);
|
||||
}
|
||||
|
||||
TEST_CASE("relay_chn_tilt_get_default_sensitivity returns correct value", "[relay_chn][tilt][sensitivity]")
|
||||
{
|
||||
// The default sensitivity is calculated from default timing values.
|
||||
// Default run time: 15ms, Min run time: 50ms, Max run time: 10ms.
|
||||
// Formula: ( (DEFAULT_RUN - MIN_RUN) * 100 ) / (MAX_RUN - MIN_RUN)
|
||||
// ( (15 - 50) * 100 ) / (10 - 50) = (-35 * 100) / -40 = -3500 / -40 = 87.5
|
||||
// As integer arithmetic, this is 87.
|
||||
uint8_t expected_sensitivity = 87;
|
||||
TEST_ASSERT_EQUAL_UINT8(expected_sensitivity, relay_chn_tilt_get_default_sensitivity());
|
||||
}
|
||||
|
||||
// Test sensitivity upper boundary for all set functions
|
||||
TEST_CASE("relay_chn_tilt_set_sensitivity functions handle upper boundary", "[relay_chn][tilt][sensitivity]")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user