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

Function FL_TEST_FILE

tests/fl/remote/remote.cpp:12–1716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "test.h"
11
12FL_TEST_FILE(FL_FILEPATH) {
13
14// =============================================================================
15// Test Fixtures and Helpers
16// =============================================================================
17
18// Test helper to create JSON-RPC request
19fl::json makeRequest(const char* method, fl::json params = fl::json::array(), int id = 1, fl::u32 timestamp = 0) {
20 fl::json req = fl::json::object();
21 req.set("method", method);
22 req.set("params", params);
23 req.set("id", id);
24 if (timestamp > 0) {
25 req.set("timestamp", static_cast<fl::i64>(timestamp));
26 }
27 return req;
28}
29
30// Request/Response queues for testing
31struct TestIO {
32 fl::vector<fl::json> requests;
33 fl::vector<fl::json> responses;
34 size_t requestIndex = 0;
35
36 fl::optional<fl::json> pullRequest() {
37 if (requestIndex >= requests.size()) {
38 return fl::nullopt;
39 }
40 return requests[requestIndex++];
41 }
42
43 void pushResponse(const fl::json& response) {
44 responses.push_back(response);
45 }
46
47 void reset() {
48 requests.clear();
49 responses.clear();
50 requestIndex = 0;
51 }
52};
53
54// =============================================================================
55// Construction Tests
56// =============================================================================
57
58FL_TEST_CASE("Remote: Construction with callbacks") {
59 TestIO io;
60
61 fl::Remote remote(
62 [&io]() { return io.pullRequest(); },
63 [&io](const fl::json& r) { io.pushResponse(r); }
64 );
65
66 FL_REQUIRE(remote.count() == 0); // No methods registered yet
67}
68
69// =============================================================================

Callers

nothing calls this directly

Calls 15

makeRequestFunction · 0.85
strlenFunction · 0.85
isspaceFunction · 0.85
processRpcMethod · 0.80
pullMethod · 0.80
addInputMethod · 0.80
remove_prefixMethod · 0.80
remove_suffixMethod · 0.80
value_orMethod · 0.80
arrayClass · 0.50
jsonClass · 0.50
stringClass · 0.50

Tested by

no test coverage detected