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

Function FL_TEST_FILE

tests/fl/stl/set.cpp:15–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include "fl/stl/int.h"
14
15FL_TEST_FILE(FL_FILEPATH) {
16
17using namespace fl;
18
19// ========================================
20// Tests from test_fixed_set.cpp
21// ========================================
22
23FL_TEST_CASE("FixedSet operations") {
24 fl::FixedSet<int, 5> set;
25
26 FL_SUBCASE("Insert and find") {
27 FL_CHECK(set.insert(1));
28 FL_CHECK(set.insert(2));
29 FL_CHECK(set.insert(3));
30 FL_CHECK(set.find(1) != set.end());
31 FL_CHECK(set.find(2) != set.end());
32 FL_CHECK(set.find(3) != set.end());
33 FL_CHECK(set.find(4) == set.end());
34 FL_CHECK_FALSE(set.insert(1)); // Duplicate insert should fail
35 }
36
37 FL_SUBCASE("Erase") {
38 FL_CHECK(set.insert(1));
39 FL_CHECK(set.insert(2));
40 FL_CHECK(set.erase(1));
41 FL_CHECK(set.find(1) == set.end());
42 FL_CHECK(set.find(2) != set.end());
43 FL_CHECK_FALSE(set.erase(3)); // Erasing non-existent element should fail
44 }
45
46 FL_SUBCASE("Next and prev") {
47 FL_CHECK(set.insert(1));
48 FL_CHECK(set.insert(2));
49 FL_CHECK(set.insert(3));
50
51 int next_value;
52 FL_CHECK(set.next(1, &next_value));
53 FL_CHECK(next_value == 2);
54 FL_CHECK(set.next(3, &next_value, true));
55 FL_CHECK(next_value == 1);
56
57 int prev_value;
58 FL_CHECK(set.prev(3, &prev_value));
59 FL_CHECK(prev_value == 2);
60 FL_CHECK(set.prev(1, &prev_value, true));
61 FL_CHECK(prev_value == 3);
62 }
63
64 FL_SUBCASE("Size and capacity") {
65 FL_CHECK(set.size() == 0);
66 FL_CHECK(set.capacity() == 5);
67 FL_CHECK(set.empty());
68
69 set.insert(1);
70 set.insert(2);
71 FL_CHECK(set.size() == 2);
72 FL_CHECK_FALSE(set.empty());

Callers

nothing calls this directly

Calls 15

ptr_to_intFunction · 0.85
TestStructClass · 0.70
insertMethod · 0.45
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
nextMethod · 0.45
prevMethod · 0.45
sizeMethod · 0.45
capacityMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected