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

Function FL_TEST_FILE

tests/fl/stl/shared_ptr.cpp:8–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "fl/stl/vector.h"
7
8FL_TEST_FILE(FL_FILEPATH) {
9
10namespace shared_ptr_test {
11
12// Test class that does NOT inherit from fl::Referent (non-intrusive)
13class TestClass {
14public:
15 TestClass() : mValue(0), mDestructorCalled(nullptr) {}
16 TestClass(int value) : mValue(value), mDestructorCalled(nullptr) {}
17 TestClass(int a, int b) : mValue(a + b), mDestructorCalled(nullptr) {}
18
19 // Constructor that allows tracking destructor calls
20 TestClass(int value, bool* destructor_flag) : mValue(value), mDestructorCalled(destructor_flag) {}
21
22 ~TestClass() {
23 if (mDestructorCalled) {
24 *mDestructorCalled = true;
25 }
26 }
27
28 int getValue() const { return mValue; }
29 void setValue(int value) { mValue = value; }
30
31private:
32 int mValue;
33 bool* mDestructorCalled;
34};
35
36// Derived class for testing polymorphism
37class DerivedTestClass : public TestClass {
38public:
39 DerivedTestClass() : TestClass(), mExtraValue(0) {}
40 DerivedTestClass(int value, int extra) : TestClass(value), mExtraValue(extra) {}
41
42 int getExtraValue() const { return mExtraValue; }
43
44private:
45 int mExtraValue;
46};
47
48// Custom deleter for testing
49struct CustomDeleter {
50 mutable fl::shared_ptr<bool> called_flag;
51
52 CustomDeleter() : called_flag(fl::make_shared<bool>(false)) {}
53
54 void operator()(TestClass* ptr) const {
55 *called_flag = true;
56 delete ptr; // ok bare allocation
57 }
58
59 bool called() const { return *called_flag; }
60};
61
62FL_TEST_CASE("fl::shared_ptr default construction") {
63 fl::shared_ptr<TestClass> ptr;
64 FL_CHECK(!ptr);
65 FL_CHECK_EQ(ptr.get(), nullptr);

Callers

nothing calls this directly

Calls 13

make_shared_no_trackingFunction · 0.85
calledMethod · 0.80
getMethod · 0.45
use_countMethod · 0.45
uniqueMethod · 0.45
getValueMethod · 0.45
resetMethod · 0.45
swapMethod · 0.45
setValueMethod · 0.45
push_backMethod · 0.45
pop_backMethod · 0.45
setNextMethod · 0.45

Tested by

no test coverage detected