29 #include <type_traits> 36 using LERR_(WRONG_TYPE);
61 virtual void copyInto (
void* )
const { };
62 virtual void moveInto (
void* ) { };
63 virtual void copyInto (
Interface&)
const { };
76 virtual operator string()
const =0;
77 virtual bool empty()
const =0;
87 static_assert (0 < i,
"invalid construction");
104 virtual operator string()
const override 106 return _Fmt(
"Sub|%s|%d|-%s")
107 % util::typeStr(
this)
123 _CheckSum_ -= access();
127 access() =
'A' +
rani(23);
128 _CheckSum_ += access();
132 access() = osub.access();
133 _CheckSum_ += access();
138 std::swap(access(),rsub.access());
141 operator= (
Sub const& osub)
143 if (!util::isSameObject (*
this, osub))
145 _CheckSum_ -= access();
146 access() = osub.access();
147 _CheckSum_ += access();
152 operator= (
Sub&& rsub)
154 _CheckSum_ -= access();
156 std::swap(access(),rsub.access());
205 :
public CopySupport<IMP>::template Policy<Interface, Opaque<IMP>, IMP>
214 throw error::Logic{
"virtual copy works only on instances " 215 "of the same concrete implementation class" 216 , LERR_(WRONG_TYPE)};
248 CHECK(0 == _CheckSum_);
250 verify_TestFixture();
252 CHECK(0 == _CheckSum_);
254 verify_fullVirtualCopySupport();
255 verify_noAssignementSupport();
256 verify_onlyMovableSupport();
257 verify_disabledCopySupport();
259 CHECK(0 == _CheckSum_);
289 CHECK (
string(a) ==
string(aa));
290 CHECK (
string(a) ==
string(a1));
296 CHECK (
string(a) ==
string(aa));
305 CHECK (
string(b) == prevID);
310 UnAssignable<'C'> cc(c);
312 CHECK (
string(c) ==
string(cc));
315 UnAssignable<'C'> ccc(std::move(cc));
320 CHECK (
string(ccc) == prevID);
321 CHECK (
string(cc) != prevID);
330 OnlyMovable<'D'> dd (std::move(d));
335 CHECK (
string(dd) !=
string(d));
358 verify_fullVirtualCopySupport()
360 RegularImpl a,aa,aaa;
365 char storage[
sizeof(RegularImpl)];
366 Interface& iiii (*reinterpret_cast<Interface*> (&storage));
371 i.moveInto(&storage);
372 CHECK (
string(iiii) == prevID);
373 CHECK (!isnil(iiii));
379 CHECK (
string(i) ==
string(ii));
385 CHECK (
string(ii) == prevID);
388 Opaque<Regular<'!'>> divergent;
389 Interface& evil(divergent);
394 cout <<
"==fullVirtualCopySupport=="<<endl
406 verify_noAssignementSupport()
408 ClonableImpl b,bb,bbb;
413 char storage[
sizeof(ClonableImpl)];
414 Interface& iiii (*reinterpret_cast<Interface*> (&storage));
419 i.moveInto(&storage);
420 CHECK (
string(iiii) == prevID);
421 CHECK (!isnil(iiii));
427 ii.copyInto(&storage);
429 CHECK (!isnil(iiii));
431 CHECK (
string(iiii) == prevID);
432 CHECK (
string(ii) == prevID);
437 CHECK (
string(iii) == prevID);
440 cout <<
"==noAssignementSupport=="<<endl
452 verify_onlyMovableSupport()
458 char storage[
sizeof(MovableImpl)];
459 Interface& iiii (*reinterpret_cast<Interface*> (&storage));
464 i.moveInto(&storage);
465 CHECK (
string(iiii) == prevID);
466 CHECK (!isnil(iiii));
473 CHECK (
string(ii) == prevID);
477 cout <<
"==onlyMovableSupport=="<<endl
488 verify_disabledCopySupport()
493 char storage[
sizeof(ImobileImpl)];
502 CHECK (
string(ii) == prevID);
506 cout <<
"==disabledCopySupport=="<<endl
int rani(uint bound=_iBOUND())
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
A front-end for using printf-style formatting.
Implementation namespace for support and library code.
Derived specific exceptions within Lumiera's exception hierarchy.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A collection of frequently used helper functions to support unit testing.
Helper for building »virtual copy« operations.