42 bool throw_in_transfer =
false;
50 TRACE (
test,
"CTOR FixedDummy() --> this=%p val=%d",
this, getVal());
55 TRACE (
test,
"DTOR ~FixedDummy() this=%p val=%d",
this, getVal());
61 TRACE (
test,
"TRANSFER target=%p <-- source=%p (%d,%d)", &to,&from, to.getVal(),from.getVal());
63 if (throw_in_transfer)
80 typedef typename std::vector<HOL,Allo> Type;
104 cout <<
"checking ScopedHolder<Dummy>...\n";
105 buildVector<HolderD>();
106 growVector<HolderD>();
107 checkErrorHandling<HolderD>();
109 cout <<
"checking ScopedPtrHolder<Dummy>...\n";
110 buildVector<PtrHolderD>();
111 growVector<PtrHolderD>();
112 checkErrorHandling<PtrHolderD>();
115 void create_contained_object (
HolderD& holder) { holder.create(); }
116 void create_contained_object (
PtrHolderD& holder) { holder.reset(
new FixedDummy()); }
123 CHECK (0 == Dummy::checksum());
125 typedef typename Table<HO>::Type Vect;
128 CHECK (0 == Dummy::checksum());
130 for (uint i=0; i<10; ++i)
131 create_contained_object (table[i]);
133 CHECK (0 < Dummy::checksum());
137 Dummy *rawP = table[5].get();
140 CHECK (rawP == &(*table[5]));
141 CHECK (rawP->
calc(-555) == table[5]->calc(-555));
143 CHECK (0 == Dummy::checksum());
151 CHECK (0 == Dummy::checksum());
153 typedef typename Table<HO>::Type Vect;
157 CHECK (0 == Dummy::checksum());
159 cout <<
".\n..install one element at index[0]\n";
160 table.push_back(HO());
161 CHECK (0 == Dummy::checksum());
163 create_contained_object (table[0]);
164 CHECK (0 < Dummy::checksum());
165 int theSum = Dummy::checksum();
167 cout <<
".\n..*** resize table to 16 elements\n";
168 for (uint i=0; i<15; ++i)
169 table.push_back(HO());
171 CHECK (theSum == Dummy::checksum());
173 CHECK (0 == Dummy::checksum());
181 CHECK (0 == Dummy::checksum());
183 typedef typename Table<HO>::Type Vect;
187 CHECK (0 == Dummy::checksum());
189 create_contained_object (table[2]);
190 create_contained_object (table[4]);
191 CHECK (0 < Dummy::checksum());
192 int theSum = Dummy::checksum();
194 cout <<
".\n.throw some exceptions...\n";
195 Dummy::activateCtorFailure();
198 create_contained_object (table[3]);
199 NOTREACHED (
"ctor should throw");
203 CHECK (theSum < Dummy::checksum());
204 Dummy::checksum() -= val;
205 CHECK (theSum == Dummy::checksum());
211 Dummy::activateCtorFailure(
false);
212 throw_in_transfer=
true;
219 CHECK ( table.size() < 10);
221 CHECK (theSum == Dummy::checksum());
222 throw_in_transfer=
false;
224 CHECK (0 == Dummy::checksum());
Some wrappers for coping with ownership problems.
virtual long calc(int i)
a dummy API operation
Implementation namespace for support and library code.
A mechanism to take ownership without allowing copy.
Addendum to scoped-holder.hpp for transferring the lifecycle management to another instance...
Simplistic 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.
unittest helper code: test dummy objects to track instances.
A Dummy object for tests.
Extension to std::unique_ptr, allowing copy operations on empty pointers (i.e.