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

Function FL_TEST_FILE

tests/fl/fx/frame.cpp:14–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include "fl/stl/shared_ptr.h"
13
14FL_TEST_FILE(FL_FILEPATH) {
15using namespace fl;
16namespace {
17 int allocation_count = 0;
18
19 void* custom_malloc(size_t size) {
20 allocation_count++;
21 return ::malloc(size);
22 }
23
24 void custom_free(void* ptr) {
25 allocation_count--;
26 ::free(ptr);
27 }
28}
29
30FL_TEST_CASE("test frame custom allocator") {
31 // Set our custom allocator
32 SetPSRamAllocator(custom_malloc, custom_free);
33
34 FramePtr frame = fl::make_shared<Frame>(100); // 100 pixels.
35 FL_CHECK(allocation_count == 1); // One for RGB.
36 frame.reset();
37
38 // Frame should be destroyed here
39 FL_CHECK(allocation_count == 0);
40}
41
42
43FL_TEST_CASE("test blend by black") {
44 SetPSRamAllocator(custom_malloc, custom_free);
45 FramePtr frame = fl::make_shared<Frame>(1); // 1 pixels.
46 frame->rgb()[0] = CRGB(255, 0, 0); // Red
47 CRGB out[1];
48 frame->draw(out, DrawMode::DRAW_MODE_BLEND_BY_MAX_BRIGHTNESS);
49 FL_CHECK(out[0] == CRGB(255, 0, 0)); // full red because max luma is 255
50 out[0] = CRGB(0, 0, 0);
51 frame->rgb()[0] = CRGB(128, 0, 0); // Red
52 frame->draw(out, DrawMode::DRAW_MODE_BLEND_BY_MAX_BRIGHTNESS);
53 FL_CHECK(out[0] == CRGB(64, 0, 0));
54}
55
56} // FL_TEST_FILE

Callers

nothing calls this directly

Calls 5

SetPSRamAllocatorFunction · 0.85
CRGBClass · 0.50
resetMethod · 0.45
rgbMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected