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

Function FL_TEST_FILE

tests/fl/stl/unordered_set.cpp:8–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "fl/stl/string.h"
7
8FL_TEST_FILE(FL_FILEPATH) {
9
10
11FL_TEST_CASE("Empty set properties") {
12 fl::unordered_set<int> s;
13 FL_REQUIRE_EQ(s.size(), 0u);
14 FL_REQUIRE(s.empty());
15 FL_REQUIRE(s.find(42) == s.end());
16 // begin() == end() on empty set
17 FL_REQUIRE(s.begin() == s.end());
18}
19
20FL_TEST_CASE("Single insert and lookup") {
21 fl::unordered_set<int> s;
22 s.insert(10);
23 FL_REQUIRE_EQ(s.size(), 1u);
24 FL_REQUIRE(!s.empty());
25
26 auto it = s.find(10);
27 FL_REQUIRE(it != s.end());
28 FL_REQUIRE_EQ((*it), 10); // unordered_set stores key as first in pair
29
30 // Test non-existent element
31 FL_REQUIRE(s.find(20) == s.end());
32}
33
34FL_TEST_CASE("Insert duplicate key does not increase size") {
35 fl::unordered_set<int> s;
36 s.insert(5);
37 FL_REQUIRE_EQ(s.size(), 1u);
38
39 // Insert same key again
40 s.insert(5);
41 FL_REQUIRE_EQ(s.size(), 1u); // Size should remain 1
42 FL_REQUIRE(s.find(5) != s.end());
43}
44
45FL_TEST_CASE("Multiple distinct inserts and lookups") {
46 fl::unordered_set<char> s;
47
48 // Insert multiple elements
49 for (char c = 'a'; c <= 'j'; ++c) {
50 s.insert(c);
51 }
52
53 FL_REQUIRE_EQ(s.size(), 10u);
54
55 // Verify all elements are present
56 for (char c = 'a'; c <= 'j'; ++c) {
57 FL_REQUIRE(s.find(c) != s.end());
58 }
59
60 // Verify non-existent element
61 FL_REQUIRE(s.find('z') == s.end());
62}
63
64FL_TEST_CASE("Erase behavior") {
65 fl::unordered_set<int> s;

Callers

nothing calls this directly

Calls 11

sizeMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45
clearMethod · 0.45
cbeginMethod · 0.45
cendMethod · 0.45
capacityMethod · 0.45

Tested by

no test coverage detected