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

Function FL_TEST_FILE

tests/fl/stl/cstdio.cpp:16–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include "test.h"
15
16FL_TEST_FILE(FL_FILEPATH) {
17
18FL_TEST_CASE("fl::readStringUntil basic") {
19 // Inject simple read handler that returns "hello\n"
20 const char* testData = "hello\n";
21 size_t pos = 0;
22
23 fl::inject_available_handler([&]() {
24 return (pos < fl::strlen(testData)) ? 1 : 0;
25 });
26
27 fl::inject_read_handler([&]() {
28 return (pos < fl::strlen(testData)) ? testData[pos++] : -1;
29 });
30
31 // Test readStringUntil directly to sstream
32 fl::sstream buffer;
33 bool success = fl::readStringUntil(buffer, '\n', '\r', fl::nullopt);
34
35 FL_CHECK(success);
36 FL_CHECK_EQ(buffer.str(), "hello");
37
38 fl::clear_io_handlers();
39}
40
41FL_TEST_CASE("fl::readStringUntil with skipChar") {
42 // Inject handler that returns "hello\r\nworld\n" (Windows line ending)
43 const char* testData = "hello\r\nworld\n";
44 size_t pos = 0;
45
46 fl::inject_available_handler([&]() {
47 return (pos < fl::strlen(testData)) ? 1 : 0;
48 });
49
50 fl::inject_read_handler([&]() {
51 return (pos < fl::strlen(testData)) ? testData[pos++] : -1;
52 });
53
54 // Read first line - should skip '\r' and stop at first '\n'
55 fl::sstream buffer;
56 bool success = fl::readStringUntil(buffer, '\n', '\r', fl::nullopt);
57
58 FL_CHECK(success);
59 FL_CHECK_EQ(buffer.str(), "hello"); // '\r' should be skipped
60
61 // Read second line - pos should auto-advance from first read
62 buffer.clear();
63 success = fl::readStringUntil(buffer, '\n', '\r', fl::nullopt);
64
65 FL_CHECK(success);
66 FL_CHECK_EQ(buffer.str(), "world");
67
68 fl::clear_io_handlers();
69}
70
71FL_TEST_CASE("fl::readLine delegation") {
72 // Inject handler that returns "test data\n"
73 const char* testData = "test data\n";

Callers

nothing calls this directly

Calls 15

inject_available_handlerFunction · 0.85
strlenFunction · 0.85
inject_read_handlerFunction · 0.85
readStringUntilFunction · 0.85
clear_io_handlersFunction · 0.85
readLineFunction · 0.85
snprintfFunction · 0.85
inject_print_handlerFunction · 0.85
inject_flush_handlerFunction · 0.85
stringClass · 0.50
millisFunction · 0.50

Tested by

no test coverage detected