51 bool throw_in_transfer =
false;
59 TRACE (
test,
"CTOR FixedDummy() --> this=%p val=%d",
this, getVal());
64 TRACE (
test,
"DTOR ~FixedDummy() this=%p val=%d",
this, getVal());
70 TRACE (
test,
"TRANSFER target=%p <-- source=%p (%d,%d)", &to,&from, to.getVal(),from.getVal());
72 if (throw_in_transfer)
89 typedef typename std::vector<HOL,Allo> Type;
113 cout <<
"checking ScopedHolder<Dummy>...\n";
114 buildVector<HolderD>();
115 growVector<HolderD>();
116 checkErrorHandling<HolderD>();
118 cout <<
"checking ScopedPtrHolder<Dummy>...\n";
119 buildVector<PtrHolderD>();
120 growVector<PtrHolderD>();
121 checkErrorHandling<PtrHolderD>();
124 void create_contained_object (
HolderD& holder) { holder.create(); }
125 void create_contained_object (
PtrHolderD& holder) { holder.reset(
new FixedDummy()); }
132 CHECK (0 == Dummy::checksum());
134 typedef typename Table<HO>::Type Vect;
137 CHECK (0 == Dummy::checksum());
139 for (uint i=0; i<10; ++i)
140 create_contained_object (table[i]);
142 CHECK (0 < Dummy::checksum());
146 Dummy *rawP = table[5].get();
149 CHECK (rawP == &(*table[5]));
150 CHECK (rawP->
acc(-555) == table[5]->acc(-555));
152 CHECK (0 == Dummy::checksum());
160 CHECK (0 == Dummy::checksum());
162 typedef typename Table<HO>::Type Vect;
166 CHECK (0 == Dummy::checksum());
168 cout <<
".\n..install one element at index[0]\n";
169 table.push_back(HO());
170 CHECK (0 == Dummy::checksum());
172 create_contained_object (table[0]);
173 CHECK (0 < Dummy::checksum());
174 int theSum = Dummy::checksum();
176 cout <<
".\n..*** resize table to 16 elements\n";
177 for (uint i=0; i<15; ++i)
178 table.push_back(HO());
180 CHECK (theSum == Dummy::checksum());
182 CHECK (0 == Dummy::checksum());
190 CHECK (0 == Dummy::checksum());
192 typedef typename Table<HO>::Type Vect;
196 CHECK (0 == Dummy::checksum());
198 create_contained_object (table[2]);
199 create_contained_object (table[4]);
200 CHECK (0 < Dummy::checksum());
201 int theSum = Dummy::checksum();
203 cout <<
".\n.throw some exceptions...\n";
204 Dummy::activateCtorFailure();
207 create_contained_object (table[3]);
208 NOTREACHED (
"ctor should throw");
212 CHECK (theSum < Dummy::checksum());
213 Dummy::checksum() -= val;
214 CHECK (theSum == Dummy::checksum());
220 Dummy::activateCtorFailure(
false);
221 throw_in_transfer=
true;
228 CHECK ( table.size() < 10);
230 CHECK (theSum == Dummy::checksum());
231 throw_in_transfer=
false;
233 CHECK (0 == Dummy::checksum());
Some wrappers for coping with ownership problems.
virtual long acc(int i)
a dummy API operation
Implementation namespace for support and library code.
unittest helper code: test dummy objects to track instances.
A mechanism to take ownership without allowing copy.
Addendum to scoped-holder.hpp for transferring the lifecycle management to another instance...
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Inline buffer holding and owning an object similar to unique_ptr.
A Dummy object for tests.
Extension to std::unique_ptr, allowing copy operations on empty pointers (i.e.