38 #include <type_traits> 45 using LERR_(WRONG_TYPE);
70 virtual void copyInto (
void* )
const { };
71 virtual void moveInto (
void* ) { };
72 virtual void copyInto (
Interface&)
const { };
85 virtual operator string()
const =0;
86 virtual bool empty()
const =0;
96 static_assert (0 < i,
"invalid construction");
103 return storage_[i-1];
108 return storage_[i-1];
113 virtual operator string()
const override 115 return _Fmt(
"Sub|%s|%d|-%s")
116 % util::typeStr(
this)
132 _CheckSum_ -= access();
136 access() =
'A' + rand() % 23;
137 _CheckSum_ += access();
141 access() = osub.access();
142 _CheckSum_ += access();
147 std::swap(access(),rsub.access());
150 operator= (
Sub const& osub)
152 if (!util::isSameObject (*
this, osub))
154 _CheckSum_ -= access();
155 access() = osub.access();
156 _CheckSum_ += access();
161 operator= (
Sub&& rsub)
163 _CheckSum_ -= access();
165 std::swap(access(),rsub.access());
214 :
public CopySupport<IMP>::template Policy<Interface, Opaque<IMP>, IMP>
223 throw error::Logic{
"virtual copy works only on instances " 224 "of the same concrete implementation class" 225 , LERR_(WRONG_TYPE)};
256 CHECK(0 == _CheckSum_);
258 verify_TestFixture();
260 CHECK(0 == _CheckSum_);
262 verify_fullVirtualCopySupport();
263 verify_noAssignementSupport();
264 verify_onlyMovableSupport();
265 verify_disabledCopySupport();
267 CHECK(0 == _CheckSum_);
297 CHECK (
string(a) ==
string(aa));
298 CHECK (
string(a) ==
string(a1));
304 CHECK (
string(a) ==
string(aa));
313 CHECK (
string(b) == prevID);
318 UnAssignable<'C'> cc(c);
320 CHECK (
string(c) ==
string(cc));
323 UnAssignable<'C'> ccc(std::move(cc));
328 CHECK (
string(ccc) == prevID);
329 CHECK (
string(cc) != prevID);
338 OnlyMovable<'D'> dd (std::move(d));
343 CHECK (
string(dd) !=
string(d));
366 verify_fullVirtualCopySupport()
368 RegularImpl a,aa,aaa;
373 char storage[
sizeof(RegularImpl)];
374 Interface& iiii (*reinterpret_cast<Interface*> (&storage));
379 i.moveInto(&storage);
380 CHECK (
string(iiii) == prevID);
381 CHECK (!isnil(iiii));
387 CHECK (
string(i) ==
string(ii));
393 CHECK (
string(ii) == prevID);
396 Opaque<Regular<'!'>> divergent;
397 Interface& evil(divergent);
402 cout <<
"==fullVirtualCopySupport=="<<endl
414 verify_noAssignementSupport()
416 ClonableImpl b,bb,bbb;
421 char storage[
sizeof(ClonableImpl)];
422 Interface& iiii (*reinterpret_cast<Interface*> (&storage));
427 i.moveInto(&storage);
428 CHECK (
string(iiii) == prevID);
429 CHECK (!isnil(iiii));
435 ii.copyInto(&storage);
437 CHECK (!isnil(iiii));
439 CHECK (
string(iiii) == prevID);
440 CHECK (
string(ii) == prevID);
445 CHECK (
string(iii) == prevID);
448 cout <<
"==noAssignementSupport=="<<endl
460 verify_onlyMovableSupport()
466 char storage[
sizeof(MovableImpl)];
467 Interface& iiii (*reinterpret_cast<Interface*> (&storage));
472 i.moveInto(&storage);
473 CHECK (
string(iiii) == prevID);
474 CHECK (!isnil(iiii));
481 CHECK (
string(ii) == prevID);
485 cout <<
"==onlyMovableSupport=="<<endl
496 verify_disabledCopySupport()
501 char storage[
sizeof(ImobileImpl)];
510 CHECK (
string(ii) == prevID);
514 cout <<
"==disabledCopySupport=="<<endl
#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.
Simple 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.