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

Function FL_TEST_FILE

tests/fl/codec/decode_file.hpp:34–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32#include "fl/fx/frame.h"
33
34FL_TEST_FILE(FL_FILEPATH) {
35
36// ---------------------------------------------------------------------------
37// TestIO — same pattern as tests/fl/remote/remote.cpp
38// ---------------------------------------------------------------------------
39
40struct TestIO {
41 fl::vector<fl::json> requests;
42 fl::vector<fl::json> responses;
43 size_t requestIndex = 0;
44
45 fl::optional<fl::json> pullRequest() {
46 if (requestIndex >= requests.size()) {
47 return fl::nullopt;
48 }
49 return requests[requestIndex++];
50 }
51
52 void pushResponse(const fl::json& response) {
53 responses.push_back(response);
54 }
55};
56
57// ---------------------------------------------------------------------------
58// Constants & helpers
59// ---------------------------------------------------------------------------
60
61static const char* DEFAULT_PAYLOAD_PATH = ".build/decode_payload.json";
62
63static const char* getPayloadPath() {
64 const char* env = ::getenv("FASTLED_DECODE_PAYLOAD");
65 if (env && env[0]) {
66 return env;
67 }
68 return DEFAULT_PAYLOAD_PATH;
69}
70
71static fl::string readFileToString(const char* path) {
72 fl::FILE* f = fl::fopen(path, "rb");
73 if (!f) {
74 return fl::string();
75 }
76 fl::fseek(f, 0, fl::io::seek_end);
77 long len = fl::ftell(f);
78 fl::fseek(f, 0, fl::io::seek_set);
79 if (len <= 0) {
80 fl::fclose(f);
81 return fl::string();
82 }
83 fl::vector<char> buf(len);
84 size_t read = fl::fread(buf.data(), 1, len, f);
85 fl::fclose(f);
86 return fl::string(buf.data(), read);
87}
88
89// ---------------------------------------------------------------------------
90// Codec validation helpers
91// ---------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 15

base64_encodeFunction · 0.85
getPayloadPathFunction · 0.85
readFileToStringFunction · 0.85
validateMp4Function · 0.85
validateMpegFunction · 0.85
validateGifFunction · 0.85
validateJpegFunction · 0.85
validateMp3Function · 0.85
validateWebPFunction · 0.85
arrayClass · 0.50
jsonClass · 0.50
stringClass · 0.50

Tested by

no test coverage detected