49 undo (
short param,
int memento)
51 testVal += param-memento;
67 using LERR_(MISSING_MEMENTO);
88 checkStateCapturingMechanism();
98 checkStateCapturingMechanism ()
100 function<void(short,int)> undo_func =
undo;
101 function< int(short)> cap_func =
capture;
103 MemHolder mementoHolder (undo_func,cap_func);
105 CHECK (
sizeof(MemHolder) <=
sizeof(
int)
106 + 2 *
sizeof(
function<
void()>)
109 function<OpSIG> bound_undo_func = mementoHolder.tieUndoFunc();
110 function<OpSIG> bound_cap_func = mementoHolder.tieCaptureFunc();
113 VERIFY_ERROR (MISSING_MEMENTO, mementoHolder.getState() );
115 short rr (rand() %100);
119 CHECK (rr == mementoHolder.getState());
123 CHECK (testVal == 10-rr);
129 CHECK (5+rr == mementoHolder.getState());
132 bound_undo_func(3*rr);
133 CHECK (testVal == -20 + 3*rr - (5+rr));
void OpSIG(short)
assumed signature of the Command "Operation"
void undo(short param, int memento)
#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.
Simple 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.