44 bool printNewDel =
false;
53 return liveList.size();
59 static int oldLive = 0;
61 int diff = newLive - oldLive;
70 LiveList::iterator liveIt;
73 TestRC(
const char *newTag) : _tag(newTag)
76 cprintf(
" Creating object \"%s\"\n", _tag);
77 liveList.push_front(
this);
78 liveIt = liveList.begin();
84 cprintf(
" Destroying object \"%s\"\n", _tag);
85 liveList.erase(liveIt);
105 assert(liveChange() == 0);
115 setCase(
"construction from pointer");
116 Ptr constFromPointer =
new TestRC(
"construction from pointer");
121 setCase(
"construction from a Ptr");
122 Ptr constFromPtr = constFromPointer;
128 Ptr *ptrPtr =
new Ptr(
new TestRC(
"destroying a ptr"));
134 setCase(
"assignment operators");
135 Ptr assignmentTarget;
136 TestRC *assignmentSourcePointer =
new TestRC(
"assignment source 1");
138 assignmentTarget = assignmentSourcePointer;
140 assignmentTarget = NULL;
142 Ptr assignmentSourcePtr(
new TestRC(
"assignment source 2"));
144 assignmentTarget = assignmentSourcePtr;
146 assignmentSourcePtr = NULL;
148 assignmentTarget = NULL;
153 TestRC *accessTest =
new TestRC(
"access test");
154 Ptr accessTestPtr = accessTest;
155 accessTest->testVal = 1;
158 accessTest->testVal = 2;
161 accessTestPtr->testVal = 3;
163 (*accessTestPtr).testVal = 4;
165 accessTestPtr = NULL;
170 setCase(
"conversion to bool and ! overload");
171 Ptr boolTest =
new TestRC(
"bool test");
181 TestRC *equalTestA =
new TestRC(
"equal test a");
182 Ptr equalTestAPtr = equalTestA;
183 Ptr equalTestAPtr2 = equalTestA;
184 TestRC *equalTestB =
new TestRC(
"equal test b");
185 Ptr equalTestBPtr = equalTestB;
If you want a reference counting pointer to a mutable object, create it like this: ...
#define EXPECT_TRUE(expr)
A macro which verifies that expr evaluates to true.
Classes for managing reference counted objects.
Derive from RefCounted if you want to enable reference counting of this class.
void setCase(const char *newCase)
Sets the current test case.
unsigned printResults()
Function to call at the end of a test that prints an overall result and a summary of how many checks ...
#define EXPECT_EQ(lhs, rhs)
A macro which verifies that lhs and rhs are equal to each other.
void cprintf(const char *format, const Args &...args)