35 using LERR_(INVALID_COMMAND);
36 using LERR_(DUPLICATE_COMMAND);
37 using LERR_(UNBOUND_ARGUMENTS);
38 using LERR_(INVALID_ARGUMENTS);
54 int random() {
return randVal = 10 +
rani(40); }
72 stringRepresentation();
75 CHECK (0 == command1::check_);
86 .operation (command1::operate)
87 .captureUndo (command1::capture)
88 .undoOperation (command1::undoIt)
93 CHECK (randVal == command1::check_);
96 CHECK ( 0 == command1::check_);
105 .operation (command1::operate)
106 .captureUndo (command1::capture)
107 .undoOperation (command1::undoIt)
112 Command com (
"test.command1.2");
115 CHECK (contains (
string(com),
"test.command1.2"));
116 CHECK (contains (
string(com),
"{def}"));
117 CHECK (!com.canExec());
119 CHECK ( 0 == command1::check_);
123 CHECK ( com.canExec());
124 CHECK (!com.canUndo());
126 CHECK (randVal == command1::check_);
128 CHECK ( 0 == command1::check_);
131 invoke (
"test.command1.2") (1234);
132 CHECK ( 1234 == command1::check_);
135 CHECK ( 0 == command1::check_);
142 Command::remove(
"test.command1.2");
148 def.operation (command1::operate)
149 .captureUndo (command1::capture);
153 def.operation (command1::operate)
154 .captureUndo (command1::capture)
155 .undoOperation (command1::undoIt);
160 CHECK ( Command::defined(
"test.command1.2"));
161 CHECK (!Command::canExec(
"test.command1.2"));
162 CHECK (!Command::canUndo(
"test.command1.2"));
166 CHECK (!com.canExec());
167 CHECK (!com.canUndo());
170 CHECK ( Command::defined(
"test.command1.2"));
171 CHECK ( Command::canExec(
"test.command1.2"));
172 CHECK (!Command::canUndo(
"test.command1.2"));
175 CHECK ( Command::defined(
"test.command1.2"));
176 CHECK ( Command::canExec(
"test.command1.2"));
177 CHECK ( Command::canUndo(
"test.command1.2"));
180 CHECK ( Command::defined(
"test.command1.2"));
181 CHECK ( Command::canExec(
"test.command1.2"));
182 CHECK ( Command::canUndo(
"test.command1.2"));
185 CHECK ( Command::defined(
"test.command1.2"));
186 CHECK (!Command::canExec(
"test.command1.2"));
187 CHECK (!Command::canUndo(
"test.command1.2"));
195 .operation (command1::operate)
196 .captureUndo (command1::capture)
197 .undoOperation (command1::undoIt)
210 CHECK (c1.canExec());
211 CHECK (!c1.canUndo());
215 CHECK (c2.canExec());
216 CHECK (!c2.canUndo());
217 CHECK (c2.isAnonymous());
220 CHECK (!isSameObject(c1, c2));
222 CHECK (0 == command1::check_);
226 CHECK (randVal == command1::check_);
227 CHECK ( c1.canUndo());
228 CHECK (!c2.canUndo());
231 CHECK (randVal + randVal == command1::check_);
232 CHECK (c2.canUndo());
236 CHECK (0 == command1::check_);
238 CHECK (randVal == command1::check_);
242 CHECK (randVal + 23 == command1::check_);
246 CHECK (randVal + 23 + randVal == command1::check_);
248 CHECK (randVal + 23 == command1::check_);
253 CHECK (randVal == command1::check_);
255 CHECK (randVal + 23 == command1::check_);
258 c2.storeDef (
"test.command1.4");
261 CHECK (c4.canExec());
262 CHECK (c4.canUndo());
264 CHECK ( c2.isAnonymous());
269 CHECK (randVal + 2*23 == command1::check_);
271 c4.
bind(
int(-command1::check_));
273 CHECK (0 == command1::check_);
275 CHECK (23 == command1::check_);
277 CHECK (0 == command1::check_);
281 CHECK (c2.canExec());
282 CHECK (c2.canUndo());
283 CHECK (not c4.canExec());
284 CHECK (not c4.canUndo());
291 #define BUILD_NEW_COMMAND_DEF(_ID_) \ 293 .operation (command1::operate) \ 294 .captureUndo (command1::capture) \ 295 .undoOperation (command1::undoIt) 298 VERIFY_ERROR (DUPLICATE_COMMAND, BUILD_NEW_COMMAND_DEF (
"test.command1.1") );
300 VERIFY_ERROR (DUPLICATE_COMMAND, BUILD_NEW_COMMAND_DEF (
"test.command1.2") );
302 VERIFY_ERROR (DUPLICATE_COMMAND, BUILD_NEW_COMMAND_DEF (
"test.command1.3") );
304 VERIFY_ERROR (DUPLICATE_COMMAND, BUILD_NEW_COMMAND_DEF (
"test.command1.4") );
309 stringRepresentation()
319 .operation (command1::operate)
320 .captureUndo (command1::capture)
321 .undoOperation (command1::undoIt);
347 VERIFY_ERROR (INVALID_COMMAND, invoke (
"miracle") (1,2,3));
350 CHECK (!unbelievable);
358 CHECK (!miracle.canExec());
359 CHECK (!miracle.canUndo());
364 CHECK (Command::remove(
"test.command1.1"));
365 CHECK (Command::remove(
"test.command1.2"));
366 CHECK (Command::remove(
"test.command1.3"));
367 CHECK (Command::remove(
"test.command1.4"));
368 CHECK (Command::remove(
"test.command1.5"));
370 CHECK (!Command::remove(
"miracle"));
383 CHECK (c5.isValid());
384 CHECK (c5.canExec());
Some additional helpers and convenience shortcuts to ease command invocation.
Helper class used solely for defining a Command-Object.
static size_t definition_count()
int rani(uint bound=_iBOUND())
Command newInstance() const
create independent (anonymous) clone copy of this command
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
static Command get(Symbol cmdID)
Access existing command for use.
Steam-Layer implementation namespace root.
static size_t instance_count()
Command & unbind()
discard any argument data previously bound.
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.
ExecResult execSync()
invoke using a default "synchronous" execution pattern
Some dummy command functions used for building unit test cases.
Handle object representing a single Command instance to be used by client code.
RET bind()
Accept dummy binding (0 Arg)
Actually defining a command and binding it to execution parameters.
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities. ...