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

Function FL_TEST_FILE

tests/fl/stl/priority_queue.cpp:10–482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "fl/stl/cstddef.h"
9
10FL_TEST_FILE(FL_FILEPATH) {
11
12using namespace fl;
13
14// ============================================================================
15// Tests for fl::PriorityQueue (standard max-heap priority queue)
16// ============================================================================
17
18FL_TEST_CASE("fl::PriorityQueue basic operations") {
19 FL_SUBCASE("default constructor") {
20 PriorityQueue<int> pq;
21 FL_CHECK(pq.empty());
22 FL_CHECK_EQ(pq.size(), 0u);
23 }
24
25 FL_SUBCASE("push and top") {
26 PriorityQueue<int> pq;
27 pq.push(5);
28 FL_CHECK(!pq.empty());
29 FL_CHECK_EQ(pq.size(), 1u);
30 FL_CHECK_EQ(pq.top(), 5);
31
32 pq.push(3);
33 FL_CHECK_EQ(pq.size(), 2u);
34 FL_CHECK_EQ(pq.top(), 5); // Max heap by default
35
36 pq.push(7);
37 FL_CHECK_EQ(pq.size(), 3u);
38 FL_CHECK_EQ(pq.top(), 7);
39 }
40
41 FL_SUBCASE("pop operations") {
42 PriorityQueue<int> pq;
43 pq.push(5);
44 pq.push(3);
45 pq.push(7);
46 pq.push(1);
47 pq.push(9);
48
49 FL_CHECK_EQ(pq.top(), 9);
50 pq.pop();
51 FL_CHECK_EQ(pq.top(), 7);
52 pq.pop();
53 FL_CHECK_EQ(pq.top(), 5);
54 pq.pop();
55 FL_CHECK_EQ(pq.top(), 3);
56 pq.pop();
57 FL_CHECK_EQ(pq.top(), 1);
58 pq.pop();
59 FL_CHECK(pq.empty());
60 }
61}
62
63FL_TEST_CASE("fl::PriorityQueue with custom comparator") {
64 FL_SUBCASE("min heap with custom comparator") {
65 // Use custom comparator for min heap (opposite of default)
66 struct Greater {
67 bool operator()(int a, int b) const { return a > b; }

Callers

nothing calls this directly

Calls 15

push_heapFunction · 0.85
pop_heapFunction · 0.85
ApproxFunction · 0.50
sift_downFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
pushMethod · 0.45
popMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected