| 8 | #include "hsv2rgb.h" |
| 9 | |
| 10 | FL_TEST_FILE(FL_FILEPATH) { |
| 11 | |
| 12 | struct ScopedPowerScalingExponent { |
| 13 | explicit ScopedPowerScalingExponent(float exponent) |
| 14 | : previous_model(get_power_model()) { |
| 15 | PowerModelRGB updated_model = previous_model; |
| 16 | updated_model.exponent = exponent; |
| 17 | set_power_model(updated_model); |
| 18 | } |
| 19 | |
| 20 | ~ScopedPowerScalingExponent() { |
| 21 | set_power_model(previous_model); |
| 22 | } |
| 23 | |
| 24 | PowerModelRGB previous_model; |
| 25 | }; |
| 26 | |
| 27 | FL_TEST_CASE("PowerModelRGB - constructor") { |
| 28 | PowerModelRGB model(40, 40, 40, 2); |
| 29 | FL_CHECK(model.red_mW == 40); |
| 30 | FL_CHECK(model.green_mW == 40); |
| 31 | FL_CHECK(model.blue_mW == 40); |
| 32 | FL_CHECK(model.dark_mW == 2); |
| 33 | } |
| 34 | |
| 35 | FL_TEST_CASE("PowerModelRGB - default constructor") { |
| 36 | PowerModelRGB model; |
| 37 | FL_CHECK(model.red_mW == 80); // WS2812 @ 5V |
| 38 | FL_CHECK(model.green_mW == 55); |
| 39 | FL_CHECK(model.blue_mW == 75); |
| 40 | FL_CHECK(model.dark_mW == 5); |
| 41 | } |
| 42 | |
| 43 | FL_TEST_CASE("PowerModelRGBW - constructor") { |
| 44 | PowerModelRGBW model(90, 70, 90, 100, 5); |
| 45 | FL_CHECK(model.red_mW == 90); |
| 46 | FL_CHECK(model.green_mW == 70); |
| 47 | FL_CHECK(model.blue_mW == 90); |
| 48 | FL_CHECK(model.white_mW == 100); |
| 49 | FL_CHECK(model.dark_mW == 5); |
| 50 | } |
| 51 | |
| 52 | FL_TEST_CASE("PowerModelRGBWW - constructor") { |
| 53 | PowerModelRGBWW model(85, 65, 85, 95, 95, 5); |
| 54 | FL_CHECK(model.red_mW == 85); |
| 55 | FL_CHECK(model.green_mW == 65); |
| 56 | FL_CHECK(model.blue_mW == 85); |
| 57 | FL_CHECK(model.white_mW == 95); |
| 58 | FL_CHECK(model.warm_white_mW == 95); |
| 59 | FL_CHECK(model.dark_mW == 5); |
| 60 | } |
| 61 | |
| 62 | FL_TEST_CASE("PowerModelRGBW - toRGB conversion") { |
| 63 | PowerModelRGBW rgbw(90, 70, 90, 100, 5); |
| 64 | PowerModelRGB rgb = rgbw.toRGB(); |
| 65 | |
| 66 | // Only RGB + dark should be extracted |
| 67 | FL_CHECK(rgb.red_mW == 90); |
nothing calls this directly
no test coverage detected