release-1.0.0 #39

Merged
ismail merged 78 commits from release-1.0.0 into main 2025-09-13 10:55:49 +02:00
6 changed files with 106 additions and 53 deletions
Showing only changes of commit da953846c9 - Show all commits

View File

@@ -21,14 +21,16 @@ TEST_CASE("relay_chn_create handles invalid arguments", "[relay_chn][core]")
// --- Basic Functionality Tests ---
// TEST_CASE: Test that relay channels initialize correctly to RELAY_CHN_STATE_IDLE
TEST_CASE("Relay channels initialize correctly to FREE state", "[relay_chn][core]") {
TEST_CASE("Relay channels initialize correctly to FREE state", "[relay_chn][core]")
{
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(i));
}
}
// TEST_CASE: Test that relays do nothing when an invlid channel id given
TEST_CASE("Run forward does nothing if channel id is invalid", "[relay_chn][core]") {
TEST_CASE("Run forward does nothing if channel id is invalid", "[relay_chn][core]")
{
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
int invalid_id = CONFIG_RELAY_CHN_COUNT * 2 + i;
relay_chn_run_forward(invalid_id); // relay_chn_run_forward returns void
@@ -39,7 +41,8 @@ TEST_CASE("Run forward does nothing if channel id is invalid", "[relay_chn][core
}
// TEST_CASE: Test that relays run in the forward direction and update their state
TEST_CASE("Relay channels run forward and update state", "[relay_chn][core]") {
TEST_CASE("Relay channels run forward and update state", "[relay_chn][core]")
{
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
relay_chn_run_forward(i); // relay_chn_run_forward returns void
// Short delay for state to update
@@ -49,7 +52,8 @@ TEST_CASE("Relay channels run forward and update state", "[relay_chn][core]") {
}
// TEST_CASE: Test that relays do nothing when an invlid channel id given
TEST_CASE("Run reverse does nothing if channel id is invalid", "[relay_chn][core]") {
TEST_CASE("Run reverse does nothing if channel id is invalid", "[relay_chn][core]")
{
// Verify that no valid channels were affected
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
int invalid_id = CONFIG_RELAY_CHN_COUNT * 2 + i;
@@ -61,7 +65,8 @@ TEST_CASE("Run reverse does nothing if channel id is invalid", "[relay_chn][core
}
// TEST_CASE: Test that relays run in the reverse direction and update their state
TEST_CASE("Relay channels run reverse and update state", "[relay_chn][core]") {
TEST_CASE("Relay channels run reverse and update state", "[relay_chn][core]")
{
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
relay_chn_run_reverse(i); // relay_chn_run_reverse returns void
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
@@ -111,7 +116,8 @@ TEST_CASE("stop_all stops all running channels", "[relay_chn][core][batch]")
// TEST_CASE: Test that relays stop and transition to RELAY_CHN_STATE_IDLE
// This test also verifies the transition to FREE state after a STOP command.
TEST_CASE("Relay channels stop and update to FREE state", "[relay_chn][core]") {
TEST_CASE("Relay channels stop and update to FREE state", "[relay_chn][core]")
{
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
// First, run forward to test stopping and transitioning to FREE state
relay_chn_run_forward(i); // relay_chn_run_forward returns void
@@ -131,7 +137,8 @@ TEST_CASE("Relay channels stop and update to FREE state", "[relay_chn][core]") {
}
// TEST_CASE: Get state should return UNDEFINED when id is not valid
TEST_CASE("Get state returns UNDEFINED when id is invalid", "[relay_chn][core]") {
TEST_CASE("Get state returns UNDEFINED when id is invalid", "[relay_chn][core]")
{
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
int invalid_id = CONFIG_RELAY_CHN_COUNT * 2 + i;
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_UNDEFINED, relay_chn_get_state(invalid_id));
@@ -146,7 +153,8 @@ TEST_CASE("Get state returns UNDEFINED when id is invalid", "[relay_chn][core]")
}
// TEST_CASE: Get state string should return "UNKNOWN" when id is not valid
TEST_CASE("Get state string returns UNKNOWN when id is invalid", "[relay_chn][core]") {
TEST_CASE("Get state string returns UNKNOWN when id is invalid", "[relay_chn][core]")
{
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
int invalid_id = CONFIG_RELAY_CHN_COUNT * 2 + i;
TEST_ASSERT_EQUAL_STRING("UNKNOWN", relay_chn_get_state_str(invalid_id));
@@ -161,7 +169,8 @@ TEST_CASE("Get state string returns UNKNOWN when id is invalid", "[relay_chn][co
}
// TEST_CASE: Test independent operation of multiple relay channels
TEST_CASE("Multiple channels can operate independently", "[relay_chn][core]") {
TEST_CASE("Multiple channels can operate independently", "[relay_chn][core]")
{
if (CONFIG_RELAY_CHN_COUNT >= 2) {
// Start Channel 0 in forward direction
relay_chn_run_forward(0); // relay_chn_run_forward returns void
@@ -198,7 +207,8 @@ TEST_CASE("Multiple channels can operate independently", "[relay_chn][core]") {
// TEST_CASE: Test transition from forward to reverse with inertia and state checks
// Scenario: RELAY_CHN_STATE_FORWARD -> (relay_chn_run_reverse) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_REVERSE
TEST_CASE("Forward to Reverse transition with opposite inertia", "[relay_chn][core][inertia]") {
TEST_CASE("Forward to Reverse transition with opposite inertia", "[relay_chn][core][inertia]")
{
uint8_t ch = 0; // Channel to test
// 1. Start in forward direction
@@ -219,7 +229,8 @@ TEST_CASE("Forward to Reverse transition with opposite inertia", "[relay_chn][co
// TEST_CASE: Test transition from reverse to forward with inertia and state checks
// Scenario: RELAY_CHN_STATE_REVERSE -> (relay_chn_run_forward) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_FORWARD
TEST_CASE("Reverse to Forward transition with opposite inertia", "[relay_chn][core][inertia]") {
TEST_CASE("Reverse to Forward transition with opposite inertia", "[relay_chn][core][inertia]")
{
uint8_t ch = 0;
// 1. Start in reverse direction
@@ -239,7 +250,8 @@ TEST_CASE("Reverse to Forward transition with opposite inertia", "[relay_chn][co
// TEST_CASE: Test issuing the same run command while already running (no inertia expected)
// Scenario: RELAY_CHN_STATE_FORWARD -> (relay_chn_run_forward) -> RELAY_CHN_STATE_FORWARD
TEST_CASE("Running in same direction does not incur inertia", "[relay_chn][core][inertia]") {
TEST_CASE("Running in same direction does not incur inertia", "[relay_chn][core][inertia]")
{
uint8_t ch = 0;
// 1. Start in forward direction
@@ -257,7 +269,8 @@ TEST_CASE("Running in same direction does not incur inertia", "[relay_chn][core]
// TEST_CASE: Test transition from FREE state to running (no inertia expected)
// Scenario: RELAY_CHN_STATE_IDLE -> (relay_chn_run_forward) -> RELAY_CHN_STATE_FORWARD
TEST_CASE("FREE to Running transition without inertia", "[relay_chn][core][inertia]") {
TEST_CASE("FREE to Running transition without inertia", "[relay_chn][core][inertia]")
{
uint8_t ch = 0;
// setUp() should have already brought the channel to FREE state

View File

@@ -21,12 +21,14 @@ TEST_CASE("relay_chn_create handles invalid arguments", "[relay_chn][core]")
// --- Basic Functionality Tests ---
// TEST_CASE: Test that relay channels initialize correctly to RELAY_CHN_STATE_IDLE
TEST_CASE("Relay channels initialize correctly to IDLE state", "[relay_chn][core]") {
TEST_CASE("Relay channels initialize correctly to IDLE state", "[relay_chn][core]")
{
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state());
}
// TEST_CASE: Test that relays run in the forward direction and update their state
TEST_CASE("Relay channels run forward and update state", "[relay_chn][core]") {
TEST_CASE("Relay channels run forward and update state", "[relay_chn][core]")
{
relay_chn_run_forward();
// Short delay for state to update
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
@@ -34,7 +36,8 @@ TEST_CASE("Relay channels run forward and update state", "[relay_chn][core]") {
}
// TEST_CASE: Test that relays run in the reverse direction and update their state
TEST_CASE("Relay channels run reverse and update state", "[relay_chn][core]") {
TEST_CASE("Relay channels run reverse and update state", "[relay_chn][core]")
{
relay_chn_run_reverse(); // relay_chn_run_reverse returns void
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state());
@@ -43,7 +46,8 @@ TEST_CASE("Relay channels run reverse and update state", "[relay_chn][core]") {
// TEST_CASE: Test that relays stop and transition to RELAY_CHN_STATE_IDLE
// This test also verifies the transition to IDLE state after a STOP command.
TEST_CASE("Relay channels stop and update to IDLE state", "[relay_chn][core]") {
TEST_CASE("Relay channels stop and update to IDLE state", "[relay_chn][core]")
{
// First, run forward to test stopping and transitioning to IDLE state
relay_chn_run_forward();
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
@@ -67,7 +71,8 @@ TEST_CASE("Relay channels stop and update to IDLE state", "[relay_chn][core]") {
// TEST_CASE: Test transition from forward to reverse with inertia and state checks
// Scenario: RELAY_CHN_STATE_FORWARD -> (relay_chn_run_reverse) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_REVERSE
TEST_CASE("Forward to Reverse transition with opposite inertia", "[relay_chn][core][inertia]") {
TEST_CASE("Forward to Reverse transition with opposite inertia", "[relay_chn][core][inertia]")
{
// 1. Start in forward direction
relay_chn_run_forward();
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); // Short delay for state stabilization
@@ -86,7 +91,8 @@ TEST_CASE("Forward to Reverse transition with opposite inertia", "[relay_chn][co
// TEST_CASE: Test transition from reverse to forward with inertia and state checks
// Scenario: RELAY_CHN_STATE_REVERSE -> (relay_chn_run_forward) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_FORWARD
TEST_CASE("Reverse to Forward transition with opposite inertia", "[relay_chn][core][inertia]") {
TEST_CASE("Reverse to Forward transition with opposite inertia", "[relay_chn][core][inertia]")
{
// 1. Start in reverse direction
relay_chn_run_reverse(); // relay_chn_run_reverse returns void
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
@@ -104,7 +110,8 @@ TEST_CASE("Reverse to Forward transition with opposite inertia", "[relay_chn][co
// TEST_CASE: Test issuing the same run command while already running (no inertia expected)
// Scenario: RELAY_CHN_STATE_FORWARD -> (relay_chn_run_forward) -> RELAY_CHN_STATE_FORWARD
TEST_CASE("Running in same direction does not incur inertia", "[relay_chn][core][inertia]") {
TEST_CASE("Running in same direction does not incur inertia", "[relay_chn][core][inertia]")
{
// 1. Start in forward direction
relay_chn_run_forward();
vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS));
@@ -120,7 +127,8 @@ TEST_CASE("Running in same direction does not incur inertia", "[relay_chn][core]
// TEST_CASE: Test transition from IDLE state to running (no inertia expected)
// Scenario: RELAY_CHN_STATE_IDLE -> (relay_chn_run_forward) -> RELAY_CHN_STATE_FORWARD
TEST_CASE("IDLE to Running transition without inertia", "[relay_chn][core][inertia]") {
TEST_CASE("IDLE to Running transition without inertia", "[relay_chn][core][inertia]")
{
// setUp() should have already brought the channel to IDLE state
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state());

View File

@@ -35,7 +35,8 @@ static void test_listener_2(uint8_t chn_id, relay_chn_state_t old_state, relay_c
// ### Listener Functionality Tests
TEST_CASE("Listener is called on state change", "[relay_chn][listener]") {
TEST_CASE("Listener is called on state change", "[relay_chn][listener]")
{
uint8_t ch = 0;
reset_listener_info(&listener1_info);
@@ -56,7 +57,8 @@ TEST_CASE("Listener is called on state change", "[relay_chn][listener]") {
relay_chn_unregister_listener(test_listener_1);
}
TEST_CASE("Unregistered listener is not called", "[relay_chn][listener]") {
TEST_CASE("Unregistered listener is not called", "[relay_chn][listener]")
{
uint8_t ch = 0;
reset_listener_info(&listener1_info);
@@ -72,7 +74,8 @@ TEST_CASE("Unregistered listener is not called", "[relay_chn][listener]") {
TEST_ASSERT_EQUAL(0, listener1_info.call_count);
}
TEST_CASE("Multiple listeners are called on state change", "[relay_chn][listener]") {
TEST_CASE("Multiple listeners are called on state change", "[relay_chn][listener]")
{
uint8_t ch = 0;
reset_listener_info(&listener1_info);
reset_listener_info(&listener2_info);
@@ -100,7 +103,8 @@ TEST_CASE("Multiple listeners are called on state change", "[relay_chn][listener
relay_chn_unregister_listener(test_listener_2);
}
TEST_CASE("Listener registration handles invalid arguments and duplicates", "[relay_chn][listener]") {
TEST_CASE("Listener registration handles invalid arguments and duplicates", "[relay_chn][listener]")
{
reset_listener_info(&listener1_info);
// 1. Registering a NULL listener should fail

View File

@@ -34,7 +34,8 @@ static void test_listener_2(uint8_t chn_id, relay_chn_state_t old_state, relay_c
// ### Listener Functionality Tests
TEST_CASE("Listener is called on state change", "[relay_chn][listener]") {
TEST_CASE("Listener is called on state change", "[relay_chn][listener]")
{
reset_listener_info(&listener1_info);
// 1. Register the listener
@@ -53,7 +54,8 @@ TEST_CASE("Listener is called on state change", "[relay_chn][listener]") {
relay_chn_unregister_listener(test_listener_1);
}
TEST_CASE("Unregistered listener is not called", "[relay_chn][listener]") {
TEST_CASE("Unregistered listener is not called", "[relay_chn][listener]")
{
reset_listener_info(&listener1_info);
// 1. Register and then immediately unregister the listener
@@ -68,7 +70,8 @@ TEST_CASE("Unregistered listener is not called", "[relay_chn][listener]") {
TEST_ASSERT_EQUAL(0, listener1_info.call_count);
}
TEST_CASE("Multiple listeners are called on state change", "[relay_chn][listener]") {
TEST_CASE("Multiple listeners are called on state change", "[relay_chn][listener]")
{
reset_listener_info(&listener1_info);
reset_listener_info(&listener2_info);
@@ -95,7 +98,8 @@ TEST_CASE("Multiple listeners are called on state change", "[relay_chn][listener
relay_chn_unregister_listener(test_listener_2);
}
TEST_CASE("Listener registration handles invalid arguments and duplicates", "[relay_chn][listener]") {
TEST_CASE("Listener registration handles invalid arguments and duplicates", "[relay_chn][listener]")
{
reset_listener_info(&listener1_info);
// 1. Registering a NULL listener should fail

View File

@@ -74,7 +74,8 @@ void prepare_all_channels_for_tilt(int initial_cmd) {
// TEST_CASE: Test transition from running forward to tilt forward
// Scenario: RELAY_CHN_STATE_FORWARD -> (relay_chn_tilt_forward) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_TILT_FORWARD
TEST_CASE("Run Forward to Tilt Forward transition with inertia", "[relay_chn][tilt][inertia]") {
TEST_CASE("Run Forward to Tilt Forward transition with inertia", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running forward first to set last_run_cmd
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
@@ -96,7 +97,8 @@ TEST_CASE("Run Forward to Tilt Forward transition with inertia", "[relay_chn][ti
// TEST_CASE: Test transition from running reverse to tilt reverse
// Scenario: RELAY_CHN_STATE_REVERSE -> (relay_chn_tilt_reverse) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_TILT_REVERSE
TEST_CASE("Run Reverse to Tilt Reverse transition with inertia", "[relay_chn][tilt][inertia]") {
TEST_CASE("Run Reverse to Tilt Reverse transition with inertia", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running reverse first to set last_run_cmd
prepare_all_channels_for_tilt(RELAY_CHN_CMD_REVERSE);
@@ -116,7 +118,8 @@ TEST_CASE("Run Reverse to Tilt Reverse transition with inertia", "[relay_chn][ti
// TEST_CASE: Test transition from FREE state to tilt forward (now with preparation)
// Scenario: RELAY_CHN_STATE_IDLE -> (prepare) -> RELAY_CHN_STATE_IDLE -> (relay_chn_tilt_forward) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_TILT_FORWARD
TEST_CASE("FREE to Tilt Forward transition with inertia (prepared)", "[relay_chn][tilt][inertia]") {
TEST_CASE("FREE to Tilt Forward transition with inertia (prepared)", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running forward first to set last_run_cmd
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
@@ -129,7 +132,8 @@ TEST_CASE("FREE to Tilt Forward transition with inertia (prepared)", "[relay_chn
// TEST_CASE: Test transition from FREE state to tilt reverse (now with preparation)
// Scenario: RELAY_CHN_STATE_IDLE -> (prepare) -> RELAY_CHN_STATE_IDLE -> (relay_chn_tilt_reverse) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_TILT_REVERSE
TEST_CASE("FREE to Tilt Reverse transition with inertia (prepared)", "[relay_chn][tilt][inertia]") {
TEST_CASE("FREE to Tilt Reverse transition with inertia (prepared)", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running reverse first to set last_run_cmd
prepare_all_channels_for_tilt(RELAY_CHN_CMD_REVERSE);
@@ -141,7 +145,8 @@ TEST_CASE("FREE to Tilt Reverse transition with inertia (prepared)", "[relay_chn
// TEST_CASE: Test transition from tilt forward to run forward (inertia expected for run)
// Scenario: RELAY_CHN_STATE_TILT_FORWARD -> (relay_chn_run_forward) -> RELAY_CHN_STATE_FORWARD
TEST_CASE("Tilt Forward to Run Forward transition with inertia", "[relay_chn][tilt][inertia]") {
TEST_CASE("Tilt Forward to Run Forward transition with inertia", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running forward first to set last_run_cmd, then tilt
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_forward_all(); // Go to tilt state
@@ -158,7 +163,8 @@ TEST_CASE("Tilt Forward to Run Forward transition with inertia", "[relay_chn][ti
// TEST_CASE: Test transition from tilt reverse to run reverse (no inertia expected for run)
// Scenario: RELAY_CHN_STATE_TILT_REVERSE -> (relay_chn_run_reverse) -> RELAY_CHN_STATE_REVERSE
TEST_CASE("Tilt Reverse to Run Reverse transition with inertia", "[relay_chn][tilt][inertia]") {
TEST_CASE("Tilt Reverse to Run Reverse transition with inertia", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running reverse first to set last_run_cmd, then tilt
prepare_all_channels_for_tilt(RELAY_CHN_CMD_REVERSE);
relay_chn_tilt_reverse_all(); // Go to tilt state
@@ -174,7 +180,8 @@ TEST_CASE("Tilt Reverse to Run Reverse transition with inertia", "[relay_chn][ti
// TEST_CASE: Test transition from tilt forward to run reverse (without inertia)
// Scenario: RELAY_CHN_STATE_TILT_FORWARD -> (relay_chn_run_reverse) -> RELAY_CHN_STATE_REVERSE
TEST_CASE("Tilt Forward to Run Reverse transition without inertia", "[relay_chn][tilt][inertia]") {
TEST_CASE("Tilt Forward to Run Reverse transition without inertia", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running forward first to set last_run_cmd, then tilt
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_forward_all(); // Go to tilt state
@@ -189,7 +196,8 @@ TEST_CASE("Tilt Forward to Run Reverse transition without inertia", "[relay_chn]
// TEST_CASE: Test stopping from a tilt state (no inertia for stop command itself)
// Scenario: RELAY_CHN_STATE_TILT_FORWARD -> (relay_chn_tilt_stop) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_IDLE
TEST_CASE("Tilt to Stop transition without immediate inertia for stop", "[relay_chn][tilt][inertia]") {
TEST_CASE("Tilt to Stop transition without immediate inertia for stop", "[relay_chn][tilt][inertia]")
{
// Prepare all channels by running forward first to set last_run_cmd, then tilt
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_forward_all(); // Go to tilt state
@@ -271,7 +279,8 @@ TEST_CASE("tilt_auto_all tilts channels based on last run direction", "[relay_ch
}
// Test relay_chn_tilt_auto() chooses correct tilt direction
TEST_CASE("relay_chn_tilt_auto chooses correct direction", "[relay_chn][tilt][auto]") {
TEST_CASE("relay_chn_tilt_auto chooses correct direction", "[relay_chn][tilt][auto]")
{
// Prepare FORWARD
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_auto_all();
@@ -291,7 +300,8 @@ TEST_CASE("relay_chn_tilt_auto chooses correct direction", "[relay_chn][tilt][au
}
// Test sensitivity set/get
TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivity]") {
TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivity]")
{
uint8_t ch = 0;
relay_chn_tilt_set_sensitivity(ch, 0);
TEST_ASSERT_EQUAL_UINT8(0, relay_chn_tilt_get_sensitivity(ch));
@@ -313,7 +323,8 @@ TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivi
}
// Test tilt counter logic: forward x3, reverse x3, extra reverse fails
TEST_CASE("tilt counter logic: forward and reverse consumption", "[relay_chn][tilt][counter]") {
TEST_CASE("tilt counter logic: forward and reverse consumption", "[relay_chn][tilt][counter]")
{
// Tilt execution time at 100% sensitivity in milliseconds (10 + 90)
#define TEST_TILT_EXECUTION_TIME_MS 100
@@ -346,7 +357,8 @@ TEST_CASE("tilt counter logic: forward and reverse consumption", "[relay_chn][ti
}
// Test run command during TILT state
TEST_CASE("run command during TILT state transitions correctly", "[relay_chn][tilt][run-during-tilt]") {
TEST_CASE("run command during TILT state transitions correctly", "[relay_chn][tilt][run-during-tilt]")
{
prepare_all_channels_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_forward_all();
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));

View File

@@ -32,7 +32,8 @@ void prepare_channel_for_tilt(int initial_cmd) {
// TEST_CASE: Test transition from running forward to tilt forward
// Scenario: RELAY_CHN_STATE_FORWARD -> (relay_chn_tilt_forward) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_TILT_FORWARD
TEST_CASE("Run Forward to Tilt Forward transition with inertia", "[relay_chn][tilt][inertia]") {
TEST_CASE("Run Forward to Tilt Forward transition with inertia", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running forward first to set last_run_cmd
prepare_channel_for_tilt(RELAY_CHN_CMD_FORWARD);
@@ -54,7 +55,8 @@ TEST_CASE("Run Forward to Tilt Forward transition with inertia", "[relay_chn][ti
// TEST_CASE: Test transition from running reverse to tilt reverse
// Scenario: RELAY_CHN_STATE_REVERSE -> (relay_chn_tilt_reverse) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_TILT_REVERSE
TEST_CASE("Run Reverse to Tilt Reverse transition with inertia", "[relay_chn][tilt][inertia]") {
TEST_CASE("Run Reverse to Tilt Reverse transition with inertia", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running reverse first to set last_run_cmd
prepare_channel_for_tilt(RELAY_CHN_CMD_REVERSE);
@@ -74,7 +76,8 @@ TEST_CASE("Run Reverse to Tilt Reverse transition with inertia", "[relay_chn][ti
// TEST_CASE: Test transition from FREE state to tilt forward (now with preparation)
// Scenario: RELAY_CHN_STATE_IDLE -> (prepare) -> RELAY_CHN_STATE_IDLE -> (relay_chn_tilt_forward) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_TILT_FORWARD
TEST_CASE("FREE to Tilt Forward transition with inertia (prepared)", "[relay_chn][tilt][inertia]") {
TEST_CASE("FREE to Tilt Forward transition with inertia (prepared)", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running forward first to set last_run_cmd
prepare_channel_for_tilt(RELAY_CHN_CMD_FORWARD);
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state()); // Ensure we are back to FREE
@@ -88,7 +91,8 @@ TEST_CASE("FREE to Tilt Forward transition with inertia (prepared)", "[relay_chn
// TEST_CASE: Test transition from FREE state to tilt reverse (now with preparation)
// Scenario: RELAY_CHN_STATE_IDLE -> (prepare) -> RELAY_CHN_STATE_IDLE -> (relay_chn_tilt_reverse) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_TILT_REVERSE
TEST_CASE("FREE to Tilt Reverse transition with inertia (prepared)", "[relay_chn][tilt][inertia]") {
TEST_CASE("FREE to Tilt Reverse transition with inertia (prepared)", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running reverse first to set last_run_cmd
prepare_channel_for_tilt(RELAY_CHN_CMD_REVERSE);
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state()); // Ensure we are back to FREE
@@ -101,7 +105,8 @@ TEST_CASE("FREE to Tilt Reverse transition with inertia (prepared)", "[relay_chn
// TEST_CASE: Test transition from tilt forward to run forward (inertia expected for run)
// Scenario: RELAY_CHN_STATE_TILT_FORWARD -> (relay_chn_run_forward) -> RELAY_CHN_STATE_FORWARD
TEST_CASE("Tilt Forward to Run Forward transition with inertia", "[relay_chn][tilt][inertia]") {
TEST_CASE("Tilt Forward to Run Forward transition with inertia", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running forward first to set last_run_cmd, then tilt
prepare_channel_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_forward(); // Go to tilt state
@@ -118,7 +123,8 @@ TEST_CASE("Tilt Forward to Run Forward transition with inertia", "[relay_chn][ti
// TEST_CASE: Test transition from tilt reverse to run reverse (no inertia expected for run)
// Scenario: RELAY_CHN_STATE_TILT_REVERSE -> (relay_chn_run_reverse) -> RELAY_CHN_STATE_REVERSE
TEST_CASE("Tilt Reverse to Run Reverse transition with inertia", "[relay_chn][tilt][inertia]") {
TEST_CASE("Tilt Reverse to Run Reverse transition with inertia", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running reverse first to set last_run_cmd, then tilt
prepare_channel_for_tilt(RELAY_CHN_CMD_REVERSE);
relay_chn_tilt_reverse(); // Go to tilt state
@@ -134,7 +140,8 @@ TEST_CASE("Tilt Reverse to Run Reverse transition with inertia", "[relay_chn][ti
// TEST_CASE: Test transition from tilt forward to run reverse (without inertia)
// Scenario: RELAY_CHN_STATE_TILT_FORWARD -> (relay_chn_run_reverse) -> RELAY_CHN_STATE_REVERSE
TEST_CASE("Tilt Forward to Run Reverse transition without inertia", "[relay_chn][tilt][inertia]") {
TEST_CASE("Tilt Forward to Run Reverse transition without inertia", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running forward first to set last_run_cmd, then tilt
prepare_channel_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_forward(); // Go to tilt state
@@ -149,7 +156,8 @@ TEST_CASE("Tilt Forward to Run Reverse transition without inertia", "[relay_chn]
// TEST_CASE: Test stopping from a tilt state (no inertia for stop command itself)
// Scenario: RELAY_CHN_STATE_TILT_FORWARD -> (relay_chn_stop) -> RELAY_CHN_STATE_STOPPED -> (inertia) -> RELAY_CHN_STATE_IDLE
TEST_CASE("Tilt to Stop transition without immediate inertia for stop", "[relay_chn][tilt][inertia]") {
TEST_CASE("Tilt to Stop transition without immediate inertia for stop", "[relay_chn][tilt][inertia]")
{
// Prepare channel by running forward first to set last_run_cmd, then tilt
prepare_channel_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_forward(); // Go to tilt state
@@ -164,7 +172,8 @@ TEST_CASE("Tilt to Stop transition without immediate inertia for stop", "[relay_
}
// Test relay_chn_tilt_auto() chooses correct tilt direction
TEST_CASE("relay_chn_tilt_auto chooses correct direction", "[relay_chn][tilt][auto]") {
TEST_CASE("relay_chn_tilt_auto chooses correct direction", "[relay_chn][tilt][auto]")
{
// Prepare FORWARD
prepare_channel_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_auto();
@@ -181,7 +190,8 @@ TEST_CASE("relay_chn_tilt_auto chooses correct direction", "[relay_chn][tilt][au
}
// Test sensitivity set/get
TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivity]") {
TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivity]")
{
relay_chn_tilt_set_sensitivity(0);
TEST_ASSERT_EQUAL_UINT8(0, relay_chn_tilt_get_sensitivity());
@@ -196,7 +206,8 @@ TEST_CASE("relay_chn_tilt_set_sensitivity and get", "[relay_chn][tilt][sensitivi
}
// Test tilt counter logic: forward x3, reverse x3, extra reverse fails
TEST_CASE("tilt counter logic: forward and reverse consumption", "[relay_chn][tilt][counter]") {
TEST_CASE("tilt counter logic: forward and reverse consumption", "[relay_chn][tilt][counter]")
{
prepare_channel_for_tilt(RELAY_CHN_CMD_FORWARD);
// Tilt forward 3 times
@@ -228,7 +239,8 @@ TEST_CASE("tilt counter logic: forward and reverse consumption", "[relay_chn][ti
}
// Test run command during TILT state
TEST_CASE("run command during TILT state transitions correctly", "[relay_chn][tilt][run-during-tilt]") {
TEST_CASE("run command during TILT state transitions correctly", "[relay_chn][tilt][run-during-tilt]")
{
prepare_channel_for_tilt(RELAY_CHN_CMD_FORWARD);
relay_chn_tilt_forward();
vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS));