CommandQueue: prepare for an unit test
This commit is contained in:
parent
b6d5cd1c76
commit
b5590fb22c
6 changed files with 51 additions and 10 deletions
|
|
@ -41,7 +41,7 @@
|
|||
#ifndef PROC_CONTROL_COMMAND_QUEUE_H
|
||||
#define PROC_CONTROL_COMMAND_QUEUE_H
|
||||
|
||||
#include "lib/error.hpp" ////////TODO needed?
|
||||
#include "proc/control/command.hpp"
|
||||
//#include "common/subsys.hpp"
|
||||
//#include "lib/depend.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@
|
|||
|
||||
#include "lib/test/run.hpp"
|
||||
#include "proc/control/command-queue.hpp"
|
||||
//#include "proc/control/command.hpp"
|
||||
#include "proc/control/command-def.hpp"
|
||||
//#include "proc/control/command-registry.hpp"
|
||||
//#include "lib/test/event-log.hpp"
|
||||
#include "lib/symbol.hpp"
|
||||
|
||||
//#include "proc/control/test-dummy-commands.hpp"
|
||||
#include "proc/control/test-dummy-commands.hpp"
|
||||
|
||||
//#include <cstdlib>
|
||||
|
||||
|
|
@ -39,10 +40,13 @@ namespace test {
|
|||
|
||||
// using std::function;
|
||||
// using std::rand;
|
||||
using lib::Symbol;
|
||||
|
||||
|
||||
namespace { // test fixture...
|
||||
|
||||
const Symbol COMMAND_1{"test.queue.command1"};
|
||||
const Symbol COMMAND_3{"test.queue.command3"};
|
||||
|
||||
}//(End) test fixture
|
||||
|
||||
|
|
@ -67,7 +71,29 @@ namespace test {
|
|||
class CommandQueue_test : public Test
|
||||
{
|
||||
|
||||
//------------------FIXTURE
|
||||
public:
|
||||
CommandQueue_test()
|
||||
{
|
||||
CommandDef (COMMAND_1)
|
||||
.operation (command1::operate)
|
||||
.captureUndo (command1::capture)
|
||||
.undoOperation (command1::undoIt)
|
||||
;
|
||||
CommandDef (COMMAND_3)
|
||||
.operation (command3::operate)
|
||||
.captureUndo (command3::capture)
|
||||
.undoOperation (command3::undoIt)
|
||||
;
|
||||
}
|
||||
~CommandQueue_test()
|
||||
{
|
||||
Command::remove (COMMAND_1);
|
||||
Command::remove (COMMAND_3);
|
||||
}
|
||||
//-------------(End)FIXTURE
|
||||
|
||||
|
||||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ namespace test {
|
|||
|
||||
check_defaultHandlingPattern();
|
||||
// check_ThrowOnError(); //////////////////////////////////////////////////////////////////////TICKET #211
|
||||
// check_DispatcherInvocation() // yet to be written as of 1/2016
|
||||
check_DispatcherInvocation();
|
||||
|
||||
|
||||
Command::remove ("test.command2");
|
||||
|
|
@ -198,6 +198,14 @@ namespace test {
|
|||
com2.undo();
|
||||
CHECK (!protocolled(randVal_));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
check_DispatcherInvocation()
|
||||
{
|
||||
UNIMPLEMENTED("start the dispatcher and enqueue a rigged special command"); /////////////////////////////TICKET #209
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ namespace test {
|
|||
* asynchronous or repeated invocation and command sequence bundles.
|
||||
*
|
||||
* @todo planned but not implemented as of 7/09
|
||||
* @todo as of 12/2016 I doubt we'll get asynchronous invocation
|
||||
* but command sequence bundles still seem a reasonable future idea
|
||||
*
|
||||
* @see HandlingPattern
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
/** @test verify the Handling pattern API: execute a command */
|
||||
void
|
||||
checkExec (PCommandImpl com)
|
||||
{
|
||||
|
|
@ -177,8 +178,8 @@ namespace test {
|
|||
CHECK (!com->canExec());
|
||||
|
||||
typedef Types<int> ArgType;
|
||||
const int ARGU (1 + rand() % 1000);
|
||||
Tuple<ArgType> tuple(ARGU);
|
||||
const int ARGR (1 + rand() % 1000);
|
||||
Tuple<ArgType> tuple(ARGR);
|
||||
TypedArguments<Tuple<ArgType>> arg(tuple);
|
||||
com->setArguments(arg);
|
||||
|
||||
|
|
@ -190,11 +191,12 @@ namespace test {
|
|||
ExecResult res = patt.exec (*com, TEST_CMD);
|
||||
|
||||
CHECK (res);
|
||||
CHECK (ARGU == command1::check_);
|
||||
CHECK (ARGR == command1::check_);
|
||||
CHECK (com->canUndo());
|
||||
}
|
||||
|
||||
|
||||
/** @test verify the Handling pattern API: undo a command */
|
||||
void
|
||||
checkUndo (PCommandImpl com)
|
||||
{
|
||||
|
|
@ -212,6 +214,9 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
/** @test use custom implementation of the HandlingPattern interface,
|
||||
* rigged to verify the functions are actually invoked.
|
||||
*/
|
||||
void
|
||||
useCustomHandler (PCommandImpl com)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
** Some dummy command functions used for building unit test cases.
|
||||
** Any of these functions comes in triples of operation function, undo state
|
||||
** capturing function and UNDO function. They are placed into a nested test
|
||||
** namespace, together with some global variables used as a backdoor to
|
||||
** namespace, together with some global variables, usable as backdoor to
|
||||
** verify the effect of calling these functions.
|
||||
**
|
||||
** @see command-use1-test.cpp
|
||||
|
|
@ -86,7 +86,7 @@ namespace test {
|
|||
|
||||
|
||||
|
||||
namespace command2 { ///< test command writing to protocol and possibly throwing
|
||||
namespace command2 { ///< test command writing capturing log and possibly throwing
|
||||
|
||||
using lumiera::error::External;
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ namespace test {
|
|||
|
||||
|
||||
|
||||
namespace command3 { ///< test command taking zero arguments
|
||||
namespace command3 { ///< test command with zero arguments
|
||||
|
||||
extern ulong check_;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue