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

Function testConversionFunction

tests/fl/hsv2rgb_accuracy.cpp:75–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73// Test a specific conversion function with RGB -> HSV -> RGB round trip
74template<typename ConversionFunc>
75static AccuracyStats testConversionFunction(ConversionFunc hsv2rgb_func, const char* func_name) {
76 (void)func_name; // Suppress unused parameter warning
77 AccuracyStats stats;
78
79 // Test a comprehensive set of RGB colors
80 // We'll test every 16th value to get good coverage without taking too long
81 // Increased step from 8 to 16 for performance (32^3 -> 16^3 iterations = 32K -> 4K = 87.5% reduction)
82 // Still provides excellent coverage: 16^3 = 4,096 test cases per conversion function
83 const int step = 16;
84
85 for (int r = 0; r < 256; r += step) {
86 for (int g = 0; g < 256; g += step) {
87 for (int b = 0; b < 256; b += step) {
88 // Original RGB color
89 CRGB original_rgb(r, g, b);
90
91 // Convert RGB -> HSV
92 CHSV hsv = rgb2hsv_approximate(original_rgb);
93
94 // Convert HSV -> RGB using the test function
95 CRGB converted_rgb;
96 hsv2rgb_func(hsv, converted_rgb);
97
98 // Calculate deviation
99 float deviation = calculateRGBDeviation(original_rgb, converted_rgb);
100 stats.deviations.push_back(deviation);
101 }
102 }
103 }
104
105 stats.calculate();
106 return stats;
107}
108
109FL_TEST_CASE("HSV to RGB Conversion Accuracy Comparison") {
110 FL_WARN("=== HSV to RGB Conversion Accuracy Test ===");

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 4

rgb2hsv_approximateFunction · 0.85
calculateRGBDeviationFunction · 0.85
calculateMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected