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

Function FL_TEST_FILE

tests/fl/channels/all_drivers.cpp:31–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29#include "test.h"
30
31FL_TEST_FILE(FL_FILEPATH) {
32
33using namespace fl;
34
35namespace {
36
37// Reset the shared singleton so each case starts from a known-empty registry.
38// Returns the manager reference for convenience.
39fl::ChannelManager& freshManager() {
40 auto& mgr = fl::ChannelManager::instance();
41 mgr.clearAllDrivers();
42 return mgr;
43}
44
45void checkHostDriversRegistered(fl::ChannelManager& mgr) {
46 auto bitbang = mgr.getDriverByName(fl::string::from_literal("BIT_BANG"));
47 FL_REQUIRE(bitbang != nullptr);
48 FL_CHECK(bitbang->getName() == fl::string::from_literal("BIT_BANG"));
49 auto bitbangCaps = bitbang->getCapabilities();
50 FL_CHECK(bitbangCaps.supportsClockless);
51 FL_CHECK(bitbangCaps.supportsSpi);
52
53 auto stub = mgr.getDriverByName(fl::string::from_literal("STUB"));
54 FL_REQUIRE(stub != nullptr);
55 FL_CHECK(stub->getName() == fl::string::from_literal("STUB"));
56 auto stubCaps = stub->getCapabilities();
57 FL_CHECK(stubCaps.supportsClockless);
58 FL_CHECK(!stubCaps.supportsSpi);
59}
60
61} // namespace
62
63FL_TEST_CASE("enableAllDrivers() registers Bus::STUB and Bus::BIT_BANG on host") {
64 auto& mgr = freshManager();
65 FL_REQUIRE(mgr.getDriverCount() == 0);
66
67 fl::enableAllDrivers();
68
69 checkHostDriversRegistered(mgr);
70}
71
72FL_TEST_CASE("FastLED.enableAllDrivers() forwards to fl::enableAllDrivers()") {
73 auto& mgr = freshManager();
74 FL_REQUIRE(mgr.getDriverCount() == 0);
75
76 // Drive the member-function entry point on an empty registry. If the
77 // member did nothing, the lookups below would return null because the
78 // precondition above guarantees no prior registration leaked in.
79 FastLED.enableAllDrivers();
80
81 checkHostDriversRegistered(mgr);
82}
83
84FL_TEST_CASE("enableAllDrivers() is idempotent") {
85 auto& mgr = freshManager();
86 FL_REQUIRE(mgr.getDriverCount() == 0);
87
88 fl::enableAllDrivers();

Callers

nothing calls this directly

Calls 5

enableAllDriversFunction · 0.85
clearAllDriversMethod · 0.80
enableAllDriversMethod · 0.80
getDriverCountMethod · 0.45

Tested by

no test coverage detected