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

Function FL_TEST_FILE

tests/fl/stl/allocator.cpp:12–1511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "fl/stl/static_assert.h"
11
12FL_TEST_FILE(FL_FILEPATH) {
13
14using namespace fl;
15
16// Test allocation_result struct
17FL_TEST_CASE("fl::allocation_result") {
18 FL_SUBCASE("basic construction") {
19 allocation_result<int*, fl::size> result{nullptr, 0};
20 FL_CHECK_EQ(result.ptr, nullptr);
21 FL_CHECK_EQ(result.count, 0);
22
23 int value = 42;
24 allocation_result<int*, fl::size> result2{&value, 1};
25 FL_CHECK_EQ(result2.ptr, &value);
26 FL_CHECK_EQ(result2.count, 1);
27 }
28}
29
30// Test allocator_traits
31FL_TEST_CASE("fl::allocator_traits") {
32 FL_SUBCASE("basic allocator traits") {
33 using traits = allocator_traits<allocator<int>>;
34 FL_CHECK((fl::is_same<traits::value_type, int>::value));
35 FL_CHECK((fl::is_same<traits::pointer, int*>::value));
36 FL_CHECK((fl::is_same<traits::size_type, fl::size>::value));
37 }
38
39 FL_SUBCASE("allocator_realloc has both capabilities") {
40 // allocator_realloc should support both reallocate() and allocate_at_least()
41 FL_STATIC_ASSERT(allocator_traits<allocator_realloc<int>>::has_reallocate_v,
42 "allocator_realloc should support reallocate()");
43 FL_STATIC_ASSERT(allocator_traits<allocator_realloc<int>>::has_allocate_at_least_v,
44 "allocator_realloc should support allocate_at_least()");
45 FL_CHECK(true); // Compile-time checks passed
46 }
47
48 FL_SUBCASE("base allocator<T> has allocate_at_least") {
49 // Standard allocator should have allocate_at_least() (with default implementation)
50 FL_STATIC_ASSERT(allocator_traits<allocator<int>>::has_allocate_at_least_v,
51 "allocator<T> should support allocate_at_least()");
52 FL_CHECK(true);
53 }
54
55 FL_SUBCASE("base allocator<T> has default reallocate") {
56 // Standard allocator has reallocate() that returns nullptr (no-op)
57 FL_STATIC_ASSERT(allocator_traits<allocator<int>>::has_reallocate_v,
58 "allocator<T> should have reallocate() method");
59 FL_CHECK(true);
60 }
61
62 FL_SUBCASE("allocator_psram capabilities") {
63 // PSRam allocator may or may not have the optional methods
64 // Just verify the traits can be queried without errors
65 (void)allocator_traits<allocator_psram<int>>::has_allocate_at_least_v;
66 (void)allocator_traits<allocator_psram<int>>::has_reallocate_v;
67 FL_CHECK(true); // Just checking it compiles
68 }
69

Callers

nothing calls this directly

Calls 15

ClearTrackingDataFunction · 0.85
SetMallocFreeHookFunction · 0.85
ClearMallocFreeHookFunction · 0.85
PSRamAllocateFunction · 0.85
PSRamDeallocateFunction · 0.85
MallocFunction · 0.85
FreeFunction · 0.85
getTotalAllocatedMethod · 0.80
getTotalDeallocatedMethod · 0.80
getActiveAllocationsMethod · 0.80
getSlabCountMethod · 0.80
cleanupMethod · 0.65

Tested by

no test coverage detected