* @brief Test Approach 1: Simple Flag Driven Blinking * * TESTS: Boolean state management, isFirstIteration(), isLastIteration() * * PURPOSE: Validate the simplest blinking approach using a boolean flag * to track LED state. Verifies proper first/last iteration detection, * state toggling logic, and task lifecycle management. * * IMPORTANCE: This is the most fundamental blinking pattern, e
| 475 | * for understanding basic TaskScheduler usage and state management. |
| 476 | */ |
| 477 | TEST_F(BlinkExampleTest, Approach1_SimpleFlagDriven) { |
| 478 | Scheduler ts; |
| 479 | global_scheduler = &ts; |
| 480 | |
| 481 | Task tBlink1(PERIOD1, DURATION / PERIOD1, &blink1CB, &ts, true); |
| 482 | tBlink1_ptr = &tBlink1; |
| 483 | |
| 484 | // Should execute first iteration |
| 485 | bool success = runBlinkSchedulerUntil(ts, condition_output_count_1); |
| 486 | EXPECT_TRUE(success); |
| 487 | EXPECT_EQ(getBlinkTestOutput(0), "BLINK1_START"); |
| 488 | EXPECT_TRUE(simulated_led_state); // Should turn LED on first |
| 489 | |
| 490 | // Let it run several cycles |
| 491 | success = runBlinkSchedulerUntil(ts, condition_led_changes_6, 3000); |
| 492 | EXPECT_TRUE(success); |
| 493 | EXPECT_GE(led_state_changes, 6); |
| 494 | |
| 495 | // Wait for completion |
| 496 | success = runBlinkSchedulerUntil(ts, condition_tBlink1_disabled, 15000); |
| 497 | EXPECT_TRUE(success); |
| 498 | EXPECT_FALSE(tBlink1.isEnabled()); |
| 499 | |
| 500 | // Check that it recorded the end |
| 501 | bool found_end = false; |
| 502 | for (const auto& output : blink_test_output) { |
| 503 | if (output == "BLINK1_END") { |
| 504 | found_end = true; |
| 505 | break; |
| 506 | } |
| 507 | } |
| 508 | EXPECT_TRUE(found_end); |
| 509 | EXPECT_FALSE(simulated_led_state); // LED should be off at end |
| 510 | |
| 511 | tBlink1_ptr = nullptr; |
| 512 | } |
| 513 | |
| 514 | // ================== APPROACH 2 TESTS ================== |
| 515 |
nothing calls this directly
no test coverage detected