| 8 | #include "platforms/init.h" |
| 9 | |
| 10 | FL_TEST_FILE(FL_FILEPATH) { |
| 11 | |
| 12 | FL_TEST_CASE("platform_init") { |
| 13 | FL_SUBCASE("fl::platforms::init() can be called") { |
| 14 | // Test that the platform init function exists and can be called |
| 15 | // This should be a no-op on most platforms, but ESP32 will initialize |
| 16 | // channel drivers and SPI bus manager |
| 17 | fl::platforms::init(); |
| 18 | |
| 19 | // If we got here without crashing, the function worked |
| 20 | FL_CHECK(true); |
| 21 | } |
| 22 | |
| 23 | FL_SUBCASE("fl::platforms::init() is safe to call multiple times") { |
| 24 | // Test that calling init() multiple times is safe (idempotent) |
| 25 | fl::platforms::init(); |
| 26 | fl::platforms::init(); |
| 27 | fl::platforms::init(); |
| 28 | |
| 29 | // Should not crash or cause issues |
| 30 | FL_CHECK(true); |
| 31 | } |
| 32 | |
| 33 | FL_SUBCASE("FastLED.init() can be called") { |
| 34 | // Test that the CFastLED::init() method exists and can be called |
| 35 | FastLED.init(); |
| 36 | |
| 37 | // If we got here without crashing, the function worked |
| 38 | FL_CHECK(true); |
| 39 | } |
| 40 | |
| 41 | FL_SUBCASE("FastLED.init() is safe to call multiple times") { |
| 42 | // Test that calling FastLED.init() multiple times is safe (idempotent) |
| 43 | FastLED.init(); |
| 44 | FastLED.init(); |
| 45 | FastLED.init(); |
| 46 | |
| 47 | // Should not crash or cause issues |
| 48 | FL_CHECK(true); |
| 49 | } |
| 50 | |
| 51 | FL_SUBCASE("FastLED.init() calls fl::platforms::init()") { |
| 52 | // This is more of a structural test - we can't directly verify the call chain |
| 53 | // in a unit test, but we can verify both functions exist and work together |
| 54 | |
| 55 | // Reset by calling platform init directly |
| 56 | fl::platforms::init(); |
| 57 | |
| 58 | // Then call through FastLED API |
| 59 | FastLED.init(); |
| 60 | |
| 61 | // Both should work without issues |
| 62 | FL_CHECK(true); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | } // FL_TEST_FILE |