FastLED 3.9.15
Loading...
Searching...
No Matches
result_formatter.cpp.hpp
Go to the documentation of this file.
1// src/fl/channels/detail/validation/result_formatter.cpp.hpp
2//
3// Result formatting implementation
4
7#include "fl/stl/sstream.h"
8#include "fl/log/log.h"
9
10namespace fl {
11namespace validation {
12
14 fl::sstream ss;
15 ss << "\n╔════════════════════════════════════════════════════════════════╗\n";
16 ss << "║ DRIVER VALIDATION SUMMARY ║\n";
17 ss << "╠════════════════════════════════════════════════════════════════╣\n";
18 ss << "║ Driver │ Status │ Tests Passed │ Total Tests ║\n";
19 ss << "╠══════════════╪═════════════╪══════════════╪═══════════════════╣\n";
20
21 for (fl::size i = 0; i < driver_results.size(); i++) {
22 const auto& result = driver_results[i];
23 const char* status;
24 if (result.skipped) {
25 status = "SKIPPED ";
26 } else if (result.allPassed()) {
27 status = "PASS ✓ ";
28 } else if (result.anyFailed()) {
29 status = "FAIL ✗ ";
30 } else {
31 status = "NO TESTS ";
32 }
33
34 // Build table row
35 ss << "║ ";
36
37 // Driver name (12 chars, left-aligned)
38 fl::string driver_name = result.driver_name;
39 if (driver_name.length() > 12) {
40 driver_name = driver_name.substr(0, 12);
41 }
42 ss << driver_name;
43 for (size_t j = driver_name.length(); j < 12; j++) {
44 ss << " ";
45 }
46 ss << " │ " << status << " │ ";
47
48 // Tests passed (12 chars, left-aligned)
49 if (result.skipped) {
50 ss << "-";
51 for (int j = 1; j < 12; j++) ss << " ";
52 } else {
53 fl::string passed = fl::to_string(result.passed_tests);
54 ss << passed;
55 for (size_t j = passed.length(); j < 12; j++) ss << " ";
56 }
57 ss << " │ ";
58
59 // Total tests (17 chars, left-aligned)
60 if (result.skipped) {
61 ss << "-";
62 for (int j = 1; j < 17; j++) ss << " ";
63 } else {
64 fl::string total = fl::to_string(result.total_tests);
65 ss << total;
66 for (size_t j = total.length(); j < 17; j++) ss << " ";
67 }
68 ss << " ║\n";
69 }
70
71 ss << "╚══════════════╧═════════════╧══════════════╧═══════════════════╝";
72 return ss.str();
73}
74
76 FL_WARN(formatSummaryTable(driver_results).c_str());
77}
78
79} // namespace validation
80} // namespace fl
fl::size length() const FL_NOEXCEPT
string str() const FL_NOEXCEPT
Definition strstream.h:43
string substr(fl::size start, fl::size length) const FL_NOEXCEPT
fl::size size() const FL_NOEXCEPT
#define FL_WARN(X)
Definition log.h:276
Centralized logging categories for FastLED hardware interfaces and subsystems.
string formatSummaryTable(const fl::vector< fl::DriverTestResult > &driver_results)
Format driver validation results as a summary table.
void printSummaryTable(const fl::vector< fl::DriverTestResult > &driver_results)
Print driver validation summary table to log.
string to_string(T value) FL_NOEXCEPT
Definition string.h:450
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
Base definition for an LED controller.
Definition crgb.hpp:179