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

Function FL_TEST_FILE

tests/platforms/esp/32/drivers/spi/spi_peripheral.cpp:25–634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23#include "platforms/esp/32/drivers/spi/ispi_peripheral.h"
24
25FL_TEST_FILE(FL_FILEPATH) {
26
27using namespace fl;
28using namespace fl::detail;
29
30// Disambiguate SpiTransaction from fl::SpiTransaction (in fl/spi.h)
31using SpiTrans = fl::detail::SpiTransaction;
32
33//=============================================================================
34// Test Fixtures and Helpers
35//=============================================================================
36
37/// @brief Reset mock to clean state before each test
38struct SpiPeripheralFixture {
39 SpiPeripheralMock& mock = SpiPeripheralMock::instance();
40
41 SpiPeripheralFixture() {
42 // Reset mock to clean state
43 mock.reset();
44 mock.clearTransactionHistory();
45 }
46
47 ~SpiPeripheralFixture() {
48 // Cleanup after test
49 if (mock.hasDevice()) {
50 mock.removeDevice();
51 }
52 if (mock.isInitialized()) {
53 mock.freeBus();
54 }
55 mock.reset();
56 }
57};
58
59/// @brief Callback function for transaction completion testing
60static int gCallbackCount = 0;
61static void testCallback(void* trans) {
62 (void)trans; // Unused
63 gCallbackCount++;
64}
65
66//=============================================================================
67// Bus Lifecycle Tests
68//=============================================================================
69
70FL_TEST_CASE("SpiPeripheralMock - initialize bus") {
71 SpiPeripheralFixture fixture;
72 auto& mock = fixture.mock;
73
74 // Valid configuration
75 SpiBusConfig config(/*mosi=*/23, /*sclk=*/18);
76 FL_CHECK(mock.initializeBus(config));
77 FL_CHECK(mock.isInitialized());
78
79 // Verify stored configuration
80 const auto& stored = mock.getBusConfig();
81 FL_CHECK_EQ(stored.mosi_pin, 23);
82 FL_CHECK_EQ(stored.sclk_pin, 18);

Callers

nothing calls this directly

Calls 15

hasDeviceMethod · 0.80
getTransactionCountMethod · 0.80
setTransactionFailureMethod · 0.80
canQueueTransactionMethod · 0.80
initializeBusMethod · 0.45
isInitializedMethod · 0.45
freeBusMethod · 0.45
addDeviceMethod · 0.45

Tested by

no test coverage detected