| 73 | // Test a specific conversion function with RGB -> HSV -> RGB round trip |
| 74 | template<typename ConversionFunc> |
| 75 | static 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 | |
| 109 | FL_TEST_CASE("HSV to RGB Conversion Accuracy Comparison") { |
| 110 | FL_WARN("=== HSV to RGB Conversion Accuracy Test ==="); |
no test coverage detected