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

Function FL_TEST_FILE

tests/fl/math/lut.cpp:10–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "test.h"
9
10FL_TEST_FILE(FL_FILEPATH) {
11
12
13
14FL_TEST_CASE("LUT interp8") {
15 fl::LUT<uint16_t> lut(2);
16 uint16_t* data = lut.getDataMutable();
17 data[0] = 0;
18 data[1] = 255;
19 FL_CHECK_EQ(lut.interp8(0), 0);
20 FL_CHECK_EQ(lut.interp8(255), 255);
21 FL_CHECK_EQ(lut.interp8(128), 128);
22
23 // Check the LUT interpolation for all values.
24 for (uint16_t i = 0; i < 256; i++) {
25 uint16_t expected = (i * 255) / 255;
26 FL_CHECK_EQ(lut.interp8(i), expected);
27 }
28}
29
30FL_TEST_CASE("LUT interp16") {
31 fl::LUT<uint16_t> lut(2);
32 uint16_t* data = lut.getDataMutable();
33 data[0] = 0;
34 data[1] = 255;
35 FL_CHECK_EQ(lut.interp16(0), 0);
36 FL_CHECK_EQ(lut.interp16(0xffff), 255);
37 FL_CHECK_EQ(lut.interp16(0xffff / 2), 127);
38
39 // Check the LUT interpolation for all values.
40 for (int i = 0; i < 256; i++) {
41 uint16_t alpha16 = fl::map8_to_16(i);
42 FL_CHECK_EQ(i, lut.interp16(alpha16));
43 }
44}
45
46} // FL_TEST_FILE

Callers

nothing calls this directly

Calls 4

map8_to_16Function · 0.85
getDataMutableMethod · 0.80
interp8Method · 0.80
interp16Method · 0.80

Tested by

no test coverage detected