13 #include <cppunit/extensions/HelperMacros.h>
14 #include <tst/Verify.h>
15 #include <utl/CountedObject.h>
16 #include <utl/CountedObjectRegistry.h>
17 #include <utl/ShadowPtr.h>
22 #define ASSERT_OBJECT_COUNTS(o, c, d, e) \
23 CPPUNIT_ASSERT(utl::CountedObject<o>::GetObjectsCreated() == c); \
24 CPPUNIT_ASSERT(utl::CountedObject<o>::GetObjectsDestroyed() == d); \
25 CPPUNIT_ASSERT(utl::CountedObject<o>::GetObjectsExisting() == e)
67 bool HasFoo1()
const {
return bool(fFoo1); }
72 bool HasFoo2()
const {
return bool(fFoo2); }
164 { ++fgConstructor; fData =
data; }
170 { ++fgCopyConstructor; fData = oc.
fData; }
173 { ++fgAssign; fData = oc.
fData;
return *
this; }
176 { fgConstructor = fgDestructor = fgCopyConstructor = fgAssign = fgSwap = 0; }
185 std::cout <<
'+' << fgConstructor <<
" ~" << fgDestructor
186 <<
" :" << fgCopyConstructor <<
" =" << fgAssign
187 <<
" s" << fgSwap << std::endl;
223 CPPUNIT_TEST(testALot);
225 CPPUNIT_TEST(testNoThrow);
226 CPPUNIT_TEST(testCloning);
228 CPPUNIT_TEST(testPrintStatistics);
229 CPPUNIT_TEST(testContainerOps);
230 CPPUNIT_TEST_SUITE_END();
246 ++created; ++existing;
249 ++destroyed; --existing;
253 ++created; ++existing;
255 CPPUNIT_ASSERT(bar1.
HasFoo1() ==
false);
256 CPPUNIT_ASSERT(bar1.
HasFoo2() ==
true);
258 ++created; ++existing;
260 CPPUNIT_ASSERT(bar1.
HasFoo1() ==
true);
261 CPPUNIT_ASSERT(bar1.
HasFoo2() ==
true);
267 created += 2; existing += 2;
269 CPPUNIT_ASSERT(bar2.GetFoo1().GetData() == 13);
270 CPPUNIT_ASSERT(bar2.GetFoo2().GetData() == 137);
271 CPPUNIT_ASSERT(&bar1.
GetFoo1() != &bar2.GetFoo1());
272 CPPUNIT_ASSERT(&bar1.
GetFoo2() != &bar2.GetFoo2());
274 created += 2; existing += 2;
276 CPPUNIT_ASSERT(bar3.GetFoo1().GetData() == 13);
277 CPPUNIT_ASSERT(bar3.GetFoo2().GetData() == 137);
278 CPPUNIT_ASSERT(&bar1.
GetFoo1() != &bar3.GetFoo1());
279 CPPUNIT_ASSERT(&bar1.
GetFoo2() != &bar3.GetFoo2());
280 CPPUNIT_ASSERT(bar3 == bar1);
281 CPPUNIT_ASSERT(bar3.GetFoo1() == bar1.
GetFoo1());
282 CPPUNIT_ASSERT(bar3.GetFoo2() == bar1.
GetFoo2());
284 ++created; ++existing;
285 CPPUNIT_ASSERT(bar4 != bar1);
287 destroyed += 7; existing -= 7;
311 CPPUNIT_ASSERT(mom.
HasChild() ==
false);
313 CPPUNIT_ASSERT(mom.
HasChild() ==
true);
316 CPPUNIT_ASSERT(stepMother.
HasChild() ==
true);
334 std::cerr << std::endl;
336 std::cerr << std::endl;
348 std::vector<utl::ShadowPtr<OverCounted> > vec;
364 std::vector<OverCountedShPtr> vec;
365 for (
int i = 0; i < 100; ++i)
366 vec.push_back(OverCountedShPtr(
new OverCounted(obj)));
373 std::vector<OverCounted> v2(1, obj);
375 std::vector<OverCounted>(v2).
swap(v2);
385 std::vector<std::vector<OverCounted> > v3(1, v2);
387 std::vector<std::vector<OverCounted> >(v3).
swap(v3);
pointer with built-in initialization, deletion, deep copying
const Child & GetChild() const
void swap(utl::Trace< T > &t1, utl::Trace< T > &t2)
const ns1::Foo & GetFoo1() const
bool operator==(const Foo &foo) const
void swap(utl::TabulatedFunction &t1, utl::TabulatedFunction &t2)
utl::ShadowPtr< ns1::Foo > fFoo1
void testPrintStatistics()
utl::InitializedShadowPtr< ns1::Foo > fFoo2
Foo & operator=(const Foo &foo)
Base class for exceptions trying to access non-existing components.
OverCounted(const OverCounted &oc)
utl::ShadowPtr< Child > fChild
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
OverCounted(const int data=0)
OverCounted & operator=(const OverCounted &oc)
bool operator!=(const Bar &bar) const
bool operator==(const TimeStamp &ts, const TimeRange &tr)
bool operator==(const Bar &bar) const
const ns1::Foo & GetFoo2() const
void Swap(OverCounted &oc)
static void PrintStatistics(std::ostream &theStream, const std::string &filter="")
void testDereferenceZeroThrow()
bool DeepEqual(const LameShadowPtr< T, D > &s1, const LameShadowPtr< T, D > &s2)
bool operator!=(const Foo &foo) const
void SetData(const int data)
#define ASSERT_OBJECT_COUNTS(o, c, d, e)
Mix-in class for counting creation and destruction of objects.
static int fgCopyConstructor