42 using LERR_(LIFECYCLE);
43 using LERR_(INVALID_COMMAND);
44 using LERR_(DUPLICATE_COMMAND);
45 using LERR_(UNBOUND_ARGUMENTS);
51 const string INVOCATION_ID =
"CommandInstanceManager_test";
56 std::deque<Command> queue_;
70 queue_.emplace_front (move (
cmd));
77 return queue_.end()!= std::find_if (queue_.begin()
112 verify_simpleUsage();
113 verify_extendedUsage();
114 verify_instanceIdentity();
136 CHECK (not iManager.contains (COMMAND_PROTOTYPE));
139 command1::check_ = 0;
141 iManager.bindAndDispatch (COMMAND_PROTOTYPE, Rec{r1});
142 CHECK (not iManager.contains (COMMAND_PROTOTYPE));
144 Command com{COMMAND_PROTOTYPE};
146 CHECK (com.canExec());
148 iManager.dispatch (COMMAND_PROTOTYPE);
149 CHECK (not iManager.contains (COMMAND_PROTOTYPE));
155 CHECK (command1::check_ == 0);
157 CHECK (command1::check_ == r1 + r2);
170 Symbol instanceID = iManager.newInstance (COMMAND_PROTOTYPE, INVOCATION_ID);
171 CHECK (iManager.contains (instanceID));
173 Command cmd = iManager.getInstance (instanceID);
175 CHECK (not cmd.canExec());
178 CHECK (cmd.canExec());
180 iManager.dispatch (instanceID);
181 CHECK (fixture.contains (cmd));
182 CHECK (not iManager.contains (instanceID));
183 VERIFY_ERROR (LIFECYCLE, iManager.getInstance (instanceID));
185 command1::check_ = 0;
187 CHECK (command1::check_ == 42);
214 Symbol i1 = iManager.newInstance (COMMAND_PROTOTYPE,
"i1");
215 Symbol i2 = iManager.newInstance (COMMAND_PROTOTYPE,
"i2");
217 Command c11 = iManager.getInstance (i1);
218 Command c12 = iManager.getInstance (i1);
220 CHECK (c11.isValid());
221 CHECK (not c11.canExec());
224 command1::check_ = 0;
227 CHECK (c12.canExec());
228 CHECK (c11.canExec());
230 Command c2 = iManager.getInstance (i2);
235 CHECK (iManager.contains (i1));
236 CHECK (iManager.contains (i2));
237 CHECK (not fixture.contains (c11));
238 CHECK (not fixture.contains (c12));
239 CHECK (not fixture.contains (c2));
241 iManager.dispatch (i1);
242 CHECK (not iManager.contains (i1));
243 CHECK ( iManager.contains (i2));
244 CHECK ( fixture.contains (c11));
245 CHECK ( fixture.contains (c12));
246 CHECK (not fixture.contains (c2));
248 CHECK (command1::check_ == 0);
250 Symbol i11 = iManager.newInstance (COMMAND_PROTOTYPE,
"i1");
252 CHECK ((
const char*)i11 == (
const char*) i1);
255 Command c13 = iManager.getInstance (i1);
258 CHECK (c11.canExec());
259 CHECK (not c13.canExec());
262 CHECK (c13.canExec());
264 CHECK (command1::check_ == 0);
266 CHECK (command1::check_ == 0+r1);
270 CHECK (command1::check_ == 0+r1+r2);
272 CHECK ( iManager.contains (i1));
273 CHECK ( iManager.contains (i2));
274 CHECK ( fixture.contains (c11));
275 CHECK ( fixture.contains (c12));
276 CHECK (not fixture.contains (c2));
278 iManager.dispatch (i2);
279 iManager.dispatch (i11);
280 CHECK (not iManager.contains (i1));
281 CHECK (not iManager.contains (i2));
282 CHECK ( fixture.contains (c11));
283 CHECK ( fixture.contains (c12));
284 CHECK ( fixture.contains (c13));
285 CHECK ( fixture.contains (c2));
293 CHECK (command1::check_ == 0+r1+r2+47+r3+r3);
296 CHECK (command1::check_ == 0);
298 CHECK (command1::check_ == 0+r1+r2);
300 CHECK (command1::check_ == 0);
315 Symbol i1 = iManager.newInstance (COMMAND_PROTOTYPE,
"i1");
316 Symbol i2 = iManager.newInstance (COMMAND_PROTOTYPE,
"i2");
318 VERIFY_ERROR (DUPLICATE_COMMAND, iManager.newInstance (COMMAND_PROTOTYPE,
"i1"));
319 VERIFY_ERROR (DUPLICATE_COMMAND, iManager.newInstance (COMMAND_PROTOTYPE,
"i2"));
321 iManager.bindAndDispatch (i1, {-1});
323 iManager.newInstance (COMMAND_PROTOTYPE,
"i1");
324 VERIFY_ERROR (DUPLICATE_COMMAND, iManager.newInstance (COMMAND_PROTOTYPE,
"i2"));
326 CHECK (iManager.getInstance (i1));
327 CHECK (iManager.getInstance (i2));
345 Symbol instanceID{COMMAND_PROTOTYPE, INVOCATION_ID};
346 VERIFY_ERROR (INVALID_COMMAND, iManager.getInstance (instanceID));
347 VERIFY_ERROR (INVALID_COMMAND, iManager.dispatch (instanceID));
349 Symbol i2 = iManager.newInstance (COMMAND_PROTOTYPE, INVOCATION_ID);
350 CHECK (i2 == instanceID);
351 CHECK (iManager.getInstance (instanceID));
354 Command cmd = iManager.getInstance (instanceID);
356 CHECK (not cmd.canExec());
358 VERIFY_ERROR (UNBOUND_ARGUMENTS, iManager.dispatch (instanceID));
359 VERIFY_ERROR (DUPLICATE_COMMAND, iManager.newInstance (COMMAND_PROTOTYPE, INVOCATION_ID));
360 CHECK (iManager.contains (instanceID));
363 CHECK (cmd.canExec());
364 iManager.dispatch (instanceID);
366 CHECK (not iManager.contains (instanceID));
367 VERIFY_ERROR (LIFECYCLE, iManager.getInstance (instanceID));
368 VERIFY_ERROR (LIFECYCLE, iManager.dispatch (instanceID));
369 CHECK (instanceID == iManager.newInstance (COMMAND_PROTOTYPE, INVOCATION_ID));
381 CHECK (not iManager.contains (COMMAND_PROTOTYPE));
382 Command cmd = iManager.getInstance (COMMAND_PROTOTYPE);
384 CHECK (cmd.isValid());
385 CHECK (not cmd.isAnonymous());
387 CHECK (cmd ==
Command{COMMAND_PROTOTYPE});
390 CHECK (cmd.canExec());
391 CHECK (not fixture.contains(cmd));
393 iManager.dispatch (COMMAND_PROTOTYPE);
394 CHECK (fixture.contains(cmd));
396 command1::check_ = 0;
398 CHECK (command1::check_ == -12);
void verify_extendedUsage()
Conveniently iterable stack and queue containers.
inline string literal This is a marker type to indicate that
Maintain a current command instance for parametrisation.
void verify_simpleUsage()
Service to support forming and invocation of command instances for use by the UI. ...
CommandSetup test_Dummy_command1
test dummy command to add the argument to a global variable
int rani(uint bound=_iBOUND())
#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.
A front-end for using printf-style formatting.
Token or Atom with distinct identity.
Simplistic test class runner.
Interface of a service to perform Commands on the session.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
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)
void verify_instanceIdentity()