MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/channels/rx.cpp:17–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include "fl/stl/static_assert.h"
16
17FL_TEST_FILE(FL_FILEPATH) {
18
19using namespace fl;
20
21FL_TEST_CASE("RxDevice - default template returns non-null device") {
22 // Factory always returns a non-null device on all platforms
23 auto device = RxDevice::create<RxDeviceType::RMT>(6); // GPIO 6
24 FL_REQUIRE(device != nullptr);
25 FL_REQUIRE(device->name() != nullptr);
26
27#ifdef FL_IS_STUB
28 // On stub platform, returns NativeRxDevice
29 FL_CHECK(fl::strcmp(device->name(), "native") == 0);
30#elif defined(ESP32)
31 // On ESP32, returns real device (name varies)
32 FL_CHECK(device->name() != nullptr);
33#else
34 // On other platforms, returns dummy device
35 FL_CHECK(fl::strcmp(device->name(), "dummy") == 0);
36#endif
37}
38
39FL_TEST_CASE("RxDevice - non-stub non-esp32 returns dummy that fails") {
40#if !defined(FL_IS_STUB) && !defined(ESP32)
41 // On non-ESP32, non-stub platforms, factory returns dummy device
42 auto device = RxDevice::create<RxDeviceType::RMT>(6);
43 FL_REQUIRE(device != nullptr);
44 FL_CHECK(fl::strcmp(device->name(), "dummy") == 0);
45
46 // begin() should return false
47 RxConfig config;
48 config.buffer_size = 512;
49 FL_CHECK(device->begin(config) == false);
50
51 // finished() should return true (always "done")
52 FL_CHECK(device->finished() == true);
53
54 // wait() should timeout
55 FL_CHECK(device->wait(100) == RxWaitResult::TIMEOUT);
56
57 // decode() should fail
58 ChipsetTiming4Phase timing{};
59 uint8_t buffer[10];
60 auto result = device->decode(timing, buffer);
61 FL_CHECK(!result.ok());
62 FL_CHECK(result.error() == DecodeError::INVALID_ARGUMENT);
63
64 // getRawEdgeTimes should return 0
65 EdgeTime edges[10];
66 size_t count = device->getRawEdgeTimes(edges);
67 FL_CHECK(count == 0);
68#endif
69}
70
71FL_TEST_CASE("RxDevice - template factory creates devices by type") {
72 // Template-based factory should work with enum
73 auto rmt_device = RxDevice::create<RxDeviceType::RMT>(6); // GPIO 6
74 auto isr_device = RxDevice::create<RxDeviceType::ISR>(7); // GPIO 7

Callers

nothing calls this directly

Calls 15

strcmpFunction · 0.85
createFunction · 0.85
RxChannelConfigClass · 0.85
configMethod · 0.80
addRxMethod · 0.80
nameMethod · 0.45
beginMethod · 0.45
finishedMethod · 0.45
waitMethod · 0.45
decodeMethod · 0.45
okMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected