38 undo (
short param,
int memento)
40 testVal += param-memento;
56 using LERR_(MISSING_MEMENTO);
78 checkStateCapturingMechanism();
88 checkStateCapturingMechanism ()
90 function<void(short,int)> undo_func =
undo;
91 function< int(short)> cap_func =
capture;
93 MemHolder mementoHolder (undo_func,cap_func);
95 CHECK (
sizeof(MemHolder) <=
sizeof(
int)
96 + 2 *
sizeof(
function<
void()>)
99 function<OpSIG> bound_undo_func = mementoHolder.tieUndoFunc();
100 function<OpSIG> bound_cap_func = mementoHolder.tieCaptureFunc();
103 VERIFY_ERROR (MISSING_MEMENTO, mementoHolder.getState() );
105 short rr (
rani (100));
109 CHECK (rr == mementoHolder.getState());
113 CHECK (testVal == 10-rr);
119 CHECK (5+rr == mementoHolder.getState());
122 bound_undo_func(3*rr);
123 CHECK (testVal == -20 + 3*rr - (5+rr));
void OpSIG(short)
assumed signature of the Command "Operation"
void undo(short param, int memento)
int rani(uint bound=_iBOUND())
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Steam-Layer implementation namespace root.
A special binding used by Steam-Layer commands for capturing UNDO state information.
Simplistic test class runner.
const size_t ALIGNMENT
maximum additional storage maybe wasted due to alignment of the memento value within MementoTie ...
A collection of frequently used helper functions to support unit testing.
int testVal
used to verify the effect of testFunc
Binding together state capturing and execution of the undo operation.