From db55c0b7e4e6f4f6c73b163bcd6b42ad7a3a5ae1 Mon Sep 17 00:00:00 2001 From: ismail Date: Fri, 29 Aug 2025 17:41:42 +0300 Subject: [PATCH] Fix single channel tests in multi mode tests Some test cases that were testing for only one channel in multi-channel mode are fixed to test all available channels. Fixes #1094 --- test_apps/main/test_relay_chn_core_multi.c | 248 +++++++++++---------- 1 file changed, 133 insertions(+), 115 deletions(-) diff --git a/test_apps/main/test_relay_chn_core_multi.c b/test_apps/main/test_relay_chn_core_multi.c index ffb15e5..7796039 100644 --- a/test_apps/main/test_relay_chn_core_multi.c +++ b/test_apps/main/test_relay_chn_core_multi.c @@ -1,5 +1,22 @@ #include "test_common.h" +relay_chn_state_t states[CONFIG_RELAY_CHN_COUNT], expect_states[CONFIG_RELAY_CHN_COUNT]; +relay_chn_direction_t directions[CONFIG_RELAY_CHN_COUNT], expect_directions[CONFIG_RELAY_CHN_COUNT]; + +static void test_set_expected_state_all(relay_chn_state_t state) +{ + for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { + expect_states[i] = state; + } +} + +static void test_set_expected_direction_all(relay_chn_direction_t direction) +{ + for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { + expect_directions[i] = direction; + } +} + // --- Initialization Tests --- @@ -33,7 +50,7 @@ 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 + relay_chn_run_forward(invalid_id); // Short delay for state to update vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(i)); @@ -44,7 +61,7 @@ TEST_CASE("Run forward does nothing if channel id is invalid", "[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 + relay_chn_run_forward(i); // Short delay for state to update vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(i)); @@ -120,7 +137,7 @@ 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 + relay_chn_run_forward(i); vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(i)); @@ -171,33 +188,29 @@ 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]") { - if (CONFIG_RELAY_CHN_COUNT >= 2) { - // Start Channel 0 in forward direction - relay_chn_run_forward(0); // relay_chn_run_forward returns void - vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(0)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(1)); // Other channel should not be affected + // Start Channel 0 in forward direction + relay_chn_run_forward(0); + vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); + TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(0)); + TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(1)); // Other channel should not be affected - // Start Channel 1 in reverse direction - relay_chn_run_reverse(1); // relay_chn_run_reverse returns void - vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(0)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state(1)); + // Start Channel 1 in reverse direction + relay_chn_run_reverse(1); // relay_chn_run_reverse returns void + vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); + TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(0)); + TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state(1)); - // Stop Channel 0 and wait for it to become FREE - relay_chn_stop(0); // relay_chn_stop returns void - vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(0)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state(1)); // Other channel should continue running + // Stop Channel 0 and wait for it to become FREE + relay_chn_stop(0); // relay_chn_stop returns void + vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); + TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(0)); + TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state(1)); // Other channel should continue running - // Stop Channel 1 and wait for it to become FREE - relay_chn_stop(1); // relay_chn_stop returns void - vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(0)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(1)); - } else { - ESP_LOGW("TEST", "Skipping 'Multiple channels can operate independently' test: Not enough channels available."); - } + // Stop Channel 1 and wait for it to become FREE + relay_chn_stop(1); // relay_chn_stop returns void + vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); + TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(0)); + TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(1)); } @@ -209,102 +222,105 @@ TEST_CASE("Multiple channels can operate independently", "[relay_chn][core]") // 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]") { - uint8_t ch = 0; // Channel to test - // 1. Start in forward direction - relay_chn_run_forward(ch); // relay_chn_run_forward returns void + relay_chn_run_forward_all(); vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); // Short delay for state stabilization - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(ch)); + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_FORWARD); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); // 2. Issue reverse command - relay_chn_run_reverse(ch); // relay_chn_run_reverse returns void + relay_chn_run_reverse_all(); // relay_chn_run_reverse returns void // Immediately after the command, the motor should be stopped vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE_PENDING, relay_chn_get_state(ch)); + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_REVERSE_PENDING); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); // Wait for the inertia period (after which the reverse command will be dispatched) vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, relay_chn_get_state(ch)); // Should now be in reverse state + // Should now be in reverse state + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_REVERSE); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); } // 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]") { - uint8_t ch = 0; - // 1. Start in reverse direction - relay_chn_run_reverse(ch); // relay_chn_run_reverse returns void + relay_chn_run_reverse_all(); // 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(ch)); + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_REVERSE); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); // 2. Issue forward command - relay_chn_run_forward(ch); // relay_chn_run_forward returns void + relay_chn_run_forward_all(); vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD_PENDING, relay_chn_get_state(ch)); + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_FORWARD_PENDING); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); // Wait for inertia vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(ch)); + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_FORWARD); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); } // 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]") { - uint8_t ch = 0; - // 1. Start in forward direction - relay_chn_run_forward(ch); // relay_chn_run_forward returns void + relay_chn_run_forward_all(); vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(ch)); + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_FORWARD); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); // 2. Issue the same forward command again - relay_chn_run_forward(ch); // relay_chn_run_forward returns void + relay_chn_run_forward_all(); // As per the code, is_direction_opposite_to_current_motion should return false, so no inertia. // Just a short delay to check state remains the same. - vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(ch)); -} - -// 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]") -{ - uint8_t ch = 0; - - // setUp() should have already brought the channel to FREE state - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(ch)); - - // Start in forward direction - relay_chn_run_forward(ch); // relay_chn_run_forward returns void - // No inertia is expected when starting from FREE state. vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(ch)); + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_FORWARD); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); } // ### Direction Flipping Tests -TEST_CASE("Single channel direction can be flipped", "[relay_chn][core][direction]") +TEST_CASE("Direction can be flipped for each channel independently", "[relay_chn][core][direction]") { - const uint8_t ch = 0; - // 1. Initial direction should be default - TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_DEFAULT, relay_chn_get_direction(ch)); - + for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { + TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_DEFAULT, relay_chn_get_direction(i)); + } + // 2. Flip the direction - relay_chn_flip_direction(ch); + for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { + relay_chn_flip_direction(i); + } vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); // Wait for flip inertia // 3. Verify direction is flipped - TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_FLIPPED, relay_chn_get_direction(ch)); + for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { + TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_FLIPPED, relay_chn_get_direction(i)); + } // 4. Flip back - relay_chn_flip_direction(ch); + for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { + relay_chn_flip_direction(i); + } vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); // Wait for flip inertia // 5. Verify direction is back to default - TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_DEFAULT, relay_chn_get_direction(ch)); + for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { + TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_DEFAULT, relay_chn_get_direction(i)); + } } TEST_CASE("All channels direction can be flipped simultaneously", "[relay_chn][core][direction][batch]") @@ -314,38 +330,44 @@ TEST_CASE("All channels direction can be flipped simultaneously", "[relay_chn][c vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); // 2. Verify all channels are flipped - for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { - TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_FLIPPED, relay_chn_get_direction(i)); - } - + TEST_ESP_OK(relay_chn_get_direction_all(directions)); + test_set_expected_direction_all(RELAY_CHN_DIRECTION_FLIPPED); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_directions, directions, CONFIG_RELAY_CHN_COUNT); + // 3. Flip all back relay_chn_flip_direction_all(); vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); // 4. Verify all channels are back to default - for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { - TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_DEFAULT, relay_chn_get_direction(i)); - } + TEST_ESP_OK(relay_chn_get_direction_all(directions)); + test_set_expected_direction_all(RELAY_CHN_DIRECTION_DEFAULT); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_directions, directions, CONFIG_RELAY_CHN_COUNT); } TEST_CASE("Flipping a running channel stops it and flips direction", "[relay_chn][core][direction]") { - const uint8_t ch = 0; - // 1. Start channel running and verify state - relay_chn_run_forward(ch); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, relay_chn_get_state(ch)); - + relay_chn_run_forward_all(); + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_FORWARD); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); // 2. Flip the direction while running - relay_chn_flip_direction(ch); - + relay_chn_flip_direction_all(); // 3. The channel should stop as part of the flip process - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_STOPPED, relay_chn_get_state(ch)); + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_STOPPED); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); - // 4. Wait for the flip inertia to pass, after which it should be FREE and FLIPPED + // 4. Wait for the flip inertia to pass, after which it should be idle and FLIPPED vTaskDelay(pdMS_TO_TICKS(CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS + TEST_DELAY_MARGIN_MS)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(ch)); - TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_FLIPPED, relay_chn_get_direction(ch)); + + TEST_ESP_OK(relay_chn_get_state_all(states)); + test_set_expected_state_all(RELAY_CHN_STATE_IDLE); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); + + TEST_ESP_OK(relay_chn_get_direction_all(directions)); + test_set_expected_direction_all(RELAY_CHN_DIRECTION_FLIPPED); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_directions, directions, CONFIG_RELAY_CHN_COUNT); } TEST_CASE("Direction flip handles invalid channel ID gracefully", "[relay_chn][core][direction]") @@ -355,43 +377,40 @@ TEST_CASE("Direction flip handles invalid channel ID gracefully", "[relay_chn][c relay_chn_flip_direction(invalid_ch); // Call with an invalid ID TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_DEFAULT, relay_chn_get_direction(invalid_ch)); } + TEST_CASE("get_state_all retrieves all channel states", "[relay_chn][core][batch]") { - relay_chn_state_t states[CONFIG_RELAY_CHN_COUNT]; - // 1. All should be IDLE initially TEST_ESP_OK(relay_chn_get_state_all(states)); - for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, states[i]); - } + test_set_expected_state_all(RELAY_CHN_STATE_IDLE); // 2. Set some states - if (CONFIG_RELAY_CHN_COUNT >= 2) { - relay_chn_run_forward(0); - relay_chn_run_reverse(1); - vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); - } else { - relay_chn_run_forward(0); - vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); + for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { + if (i % 2 == 0) { + relay_chn_run_forward(i); + } else { + relay_chn_run_reverse(i); + } } + vTaskDelay(pdMS_TO_TICKS(TEST_DELAY_MARGIN_MS)); // 3. Get all states and verify - TEST_ESP_OK(relay_chn_get_state_all(states)); - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_FORWARD, states[0]); - if (CONFIG_RELAY_CHN_COUNT >= 2) { - TEST_ASSERT_EQUAL(RELAY_CHN_STATE_REVERSE, states[1]); + for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { + if (i % 2 == 0) { + expect_states[i] = RELAY_CHN_STATE_FORWARD; + } else { + expect_states[i] = RELAY_CHN_STATE_REVERSE; + } } + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_states, states, CONFIG_RELAY_CHN_COUNT); } TEST_CASE("get_direction_all retrieves all channel directions", "[relay_chn][core][direction][batch]") { - relay_chn_direction_t directions[CONFIG_RELAY_CHN_COUNT]; - - // 1. All should be default initially + // 1. All should be default initially TEST_ESP_OK(relay_chn_get_direction_all(directions)); - for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { - TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_DEFAULT, directions[i]); - } + test_set_expected_direction_all(RELAY_CHN_DIRECTION_DEFAULT); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_directions, directions, CONFIG_RELAY_CHN_COUNT); // 2. Flip all relay_chn_flip_direction_all(); @@ -399,9 +418,8 @@ TEST_CASE("get_direction_all retrieves all channel directions", "[relay_chn][cor // 3. Get all directions and verify TEST_ESP_OK(relay_chn_get_direction_all(directions)); - for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) { - TEST_ASSERT_EQUAL(RELAY_CHN_DIRECTION_FLIPPED, directions[i]); - } + test_set_expected_direction_all(RELAY_CHN_DIRECTION_FLIPPED); + TEST_ASSERT_EQUAL_UINT_ARRAY(expect_directions, directions, CONFIG_RELAY_CHN_COUNT); } TEST_CASE("get_all functions handle NULL arguments", "[relay_chn][core][batch]")