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

Function FL_TEST_FILE

tests/fl/gfx/rectangular_draw_buffer.cpp:12–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "fl/stl/span.h"
11
12FL_TEST_FILE(FL_FILEPATH) {
13
14
15FL_TEST_CASE("Rectangular Buffer") {
16 fl::RectangularDrawBuffer buffer;
17
18 FL_SUBCASE("Empty buffer has no LEDs") {
19 FL_CHECK(buffer.getTotalBytes() == 0);
20 FL_CHECK(buffer.getMaxBytesInStrip() == 0);
21 }
22
23 FL_SUBCASE("Add one strip of 10 RGB LEDs") {
24 buffer.queue(fl::DrawItem(1, 10, false));
25
26 FL_CHECK(buffer.getMaxBytesInStrip() == 30);
27 FL_CHECK(buffer.getTotalBytes() == 30);
28 }
29
30 FL_SUBCASE("Add two strips of 10 RGB LEDs") {
31 buffer.queue(fl::DrawItem(1, 10, false));
32 buffer.queue(fl::DrawItem(2, 10, false));
33
34 FL_CHECK(buffer.getMaxBytesInStrip() == 30);
35 FL_CHECK(buffer.getTotalBytes() == 60);
36 }
37
38 FL_SUBCASE("Add one strip of 10 RGBW LEDs") {
39 buffer.queue(fl::DrawItem(1, 10, true));
40
41 uint32_t num_bytes = Rgbw::size_as_rgb(10) * 3;
42
43 FL_CHECK(buffer.getMaxBytesInStrip() == num_bytes);
44 FL_CHECK(buffer.getTotalBytes() == num_bytes);
45 }
46
47 FL_SUBCASE("Add one strip of 10 RGBW LEDs and one strip of 10 RGB LEDs") {
48 buffer.queue(fl::DrawItem(1, 10, true));
49 buffer.queue(fl::DrawItem(2, 10, false));
50
51 uint32_t max_size_strip_bytes = Rgbw::size_as_rgb(10) * 3;
52
53 FL_CHECK(buffer.getMaxBytesInStrip() == max_size_strip_bytes);
54 FL_CHECK(buffer.getTotalBytes() == max_size_strip_bytes * 2);
55 }
56};
57
58FL_TEST_CASE("Rectangular Buffer queue tests") {
59 fl::RectangularDrawBuffer buffer;
60
61 FL_SUBCASE("Queueing start and done") {
62 FL_CHECK(buffer.mQueueState == fl::RectangularDrawBuffer::IDLE);
63 buffer.onQueuingStart();
64 FL_CHECK(buffer.mQueueState == fl::RectangularDrawBuffer::QUEUEING);
65 buffer.onQueuingDone();
66 FL_CHECK(buffer.mQueueState == fl::RectangularDrawBuffer::QUEUE_DONE);
67 buffer.onQueuingStart();
68 FL_CHECK(buffer.mQueueState == fl::RectangularDrawBuffer::QUEUEING);
69 }

Callers

nothing calls this directly

Calls 14

DrawItemClass · 0.85
getTotalBytesMethod · 0.80
getMaxBytesInStripMethod · 0.80
queueMethod · 0.45
onQueuingStartMethod · 0.45
onQueuingDoneMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45
pop_frontMethod · 0.45

Tested by

no test coverage detected