37 using LERR_(BOTTOM_VALUE);
38 using LERR_(WRONG_TYPE);
39 using LERR_(ASSERTION);
49 uint _create_count = 0;
56 Base(uint i=0) : id_(i) { _checksum +=id_; ++_create_count; }
57 Base(
Base const& o) : id_(o.id_) { _checksum +=id_; ++_create_count; }
59 uint getIt() {
return id_; }
67 ~
DD() { _checksum -= ii; }
97 typedef vector<Opaque> TestList;
120 TestList objs = createDummies ();
121 for_each (objs, reAccess);
122 checkHandling (objs);
123 checkSpecialSubclass ();
125 CHECK (0 == _checksum);
133 list.push_back (DD<1>());
134 list.push_back (DD<3>());
135 list.push_back (DD<5>());
136 list.push_back (DD<7>());
142 reAccess (Opaque& elm)
144 cout << elm->getIt() << endl;
164 D3 d3 (oo.
get<D3>() );
165 CHECK (3 == oo->getIt());
166 CHECK (!isSameObject (d3, *oo));
172 CHECK (5 == oo->getIt());
176 D5 &rd5 (oo.
get<D5>());
177 CHECK (isSameObject (rd5, *oo));
181 CHECK (7 == oo->getIt());
184 CHECK (7 == rd5.getIt());
185 CHECK (isSameObject (rd5, *oo));
187 uint cnt_before = _create_count;
193 CHECK (5 == oo->getIt());
194 CHECK (_create_count == 2 + cnt_before);
199 cnt_before = _create_count;
202 CHECK (_create_count == cnt_before);
204 CHECK (_create_count == cnt_before);
206 CHECK (_create_count == cnt_before);
214 VERIFY_ERROR (ASSERTION, oo->getIt() ); 216 // can't access empty holder... 222 CHECK (!isSameObject (d3, *o2));
223 CHECK (3 == o2->getIt());
225 CHECK (
sizeof(Opaque) <=
sizeof(Base) +
sizeof(
void*) +
_ALIGN_);
245 cout << showSizeof<Base>() << endl;
246 cout << showSizeof<Special>() << endl;
247 cout << showSizeof<Opaque>() << endl;
248 cout << showSizeof<SpecialOpaque>() << endl;
250 CHECK (
sizeof(Special) >
sizeof(Base));
251 CHECK (
sizeof(SpecialOpaque) >
sizeof(Opaque));
252 CHECK (
sizeof(SpecialOpaque) <=
sizeof(Special) +
sizeof(
void*) +
_ALIGN_);
258 CHECK (7 == s1.getIt());
259 CHECK (7 == s2.getIt());
262 SpecialOpaque ospe1 (s1);
263 SpecialOpaque ospe2 (s2);
268 CHECK ( isnil(ospe0));
269 CHECK (!isnil(ospe1));
270 CHECK (!isnil(ospe2));
272 CHECK (7 == ospe1->getIt());
273 CHECK (6 == ospe1.get<Special>().myVal_);
274 CHECK (3 == ospe2.get<Special>().myVal_);
278 CHECK (5 == ospe1->getIt());
281 Opaque normal = DD<5>();
283 CHECK (5 == normal->getIt());
285 // Assertion protects against SEGV void checkSpecialSubclass()
void checkHandling(TestList &objs)
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
const size_t _ALIGN_
maximum additional storage maybe wasted due to alignment of the contained object within OpaqueHolder'...
Implementation namespace for support and library code.
Inline buffer to hold and own an object while concealing the concrete type.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Helper allowing type erasure while holding the actual object inline.
void for_each(CON const &elements, FUN function, P1 &&bind1, ARGS &&...args)
Accept binding for arbitrary function arguments.
A collection of frequently used helper functions to support unit testing.
SUB & get() const
re-accessing the concrete contained object.
Perform operations "for each element" of a collection.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities. ...