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

Function FL_TEST_FILE

tests/fl/stl/stdio.cpp:14–790  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include "fl/stl/string.h"
13
14FL_TEST_FILE(FL_FILEPATH) {
15
16
17
18
19
20// Test helper for capturing platform output
21namespace test_helper {
22 // Forward declarations to satisfy -Werror=missing-declarations
23 void capture_print(const char* str);
24 void clear_capture();
25 fl::string get_capture();
26
27 static fl::string captured_output;
28
29 void capture_print(const char* str) {
30 captured_output += str;
31 }
32
33 void clear_capture() {
34 captured_output.clear();
35 }
36
37 fl::string get_capture() {
38 return captured_output;
39 }
40}
41
42FL_TEST_CASE("fl::printf basic functionality") {
43 // Setup capture for testing platform output
44 fl::inject_print_handler(test_helper::capture_print);
45
46 FL_SUBCASE("simple string formatting") {
47 test_helper::clear_capture();
48 fl::printf("Hello, %s!", "world");
49 fl::string result = test_helper::get_capture();
50 fl::string expected = fl::string("Hello, world!");
51
52 // Debug output to see what's happening
53 fl::cout << "[DEBUG] Result: '" << result.c_str() << "' (length: " << result.size() << ")" << fl::endl;
54 fl::cout << "[DEBUG] Expected: '" << expected.c_str() << "' (length: " << expected.size() << ")" << fl::endl;
55
56 // Use basic string comparison
57 FL_REQUIRE_EQ(result.size(), expected.size());
58 FL_REQUIRE_EQ(fl::strcmp(result.c_str(), expected.c_str()), 0);
59 }
60
61 FL_SUBCASE("integer formatting") {
62 test_helper::clear_capture();
63 fl::printf("Value: %d", 42);
64 fl::string result = test_helper::get_capture();
65 fl::string expected = fl::string("Value: 42");
66 FL_REQUIRE_EQ(fl::strcmp(result.c_str(), expected.c_str()), 0);
67 }
68
69 FL_SUBCASE("multiple arguments") {
70 test_helper::clear_capture();
71 fl::printf("Name: %s, Age: %d", "Alice", 25);

Callers

nothing calls this directly

Calls 14

inject_print_handlerFunction · 0.85
printfFunction · 0.85
strcmpFunction · 0.85
clear_io_handlersFunction · 0.85
snprintfFunction · 0.85
strstrFunction · 0.85
strlenFunction · 0.85
sprintfFunction · 0.85
clear_captureFunction · 0.70
get_captureFunction · 0.70
stringClass · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected