CommandRegistry: function test pass
This commit is contained in:
parent
07de2a767b
commit
4f1c034b58
4 changed files with 34 additions and 13 deletions
|
|
@ -187,7 +187,10 @@ namespace control {
|
|||
: arguments_()
|
||||
, memento_()
|
||||
{
|
||||
arguments_.template create<ArgHolder> (*oAh.arguments_);
|
||||
if (oAh.arguments_->isValid()) // don't clone garbage from invalid arguments
|
||||
arguments_.template create<ArgHolder> (*oAh.arguments_);
|
||||
|
||||
// memento can be cloned as-is, irrespective of activation state
|
||||
memento_.template create<MemHolder> (*oAh.memento_);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ namespace control {
|
|||
canExec() const ///< state check: sufficiently defined to be invoked
|
||||
{
|
||||
return isValid()
|
||||
&& *pClo_;
|
||||
&& pClo_->isValid();
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -188,18 +188,24 @@ namespace control {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
friend bool
|
||||
operator== (CommandImpl const& ci1, CommandImpl const& ci2)
|
||||
{
|
||||
return (ci1.do_ == ci2.do_)
|
||||
&& (ci1.undo_ == ci2.undo_)
|
||||
// && (ci1.undo_ == ci2.undo_) // causes failure regularly, due to the missing equality on boost::function. See Ticket #294
|
||||
&& (ci1.defaultPatt_ == ci2.defaultPatt_)
|
||||
&& (ci1.canExec() == ci2.canExec())
|
||||
&& (ci1.canUndo() == ci2.canUndo())
|
||||
&& (ci1.pClo_->equals(*ci2.pClo_))
|
||||
;
|
||||
}
|
||||
|
||||
friend bool
|
||||
operator!= (CommandImpl const& ci1, CommandImpl const& ci2)
|
||||
{
|
||||
return !(ci1==ci2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ return: 0
|
|||
END
|
||||
|
||||
|
||||
PLANNED "Command index and allocation" CommandRegistry_test <<END
|
||||
TEST "Command index and allocation" CommandRegistry_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
||||
|
|
|
|||
|
|
@ -64,10 +64,10 @@ namespace test {
|
|||
*/
|
||||
class CommandRegistry_test : public Test
|
||||
{
|
||||
|
||||
|
||||
uint cnt_defs;
|
||||
uint cnt_inst;
|
||||
|
||||
|
||||
|
||||
virtual void
|
||||
run (Arg)
|
||||
|
|
@ -101,6 +101,10 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/** @test verify the index operation.
|
||||
* Add, search, remove, store copy.
|
||||
*/
|
||||
void
|
||||
checkRegistration (CommandRegistry& registry)
|
||||
{
|
||||
|
|
@ -161,6 +165,12 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/** @test verify the allocation/de-allocation handling as
|
||||
* embedded into the CommandRegistry operation.
|
||||
* Simulates on low level what normally happens
|
||||
* during command lifecycle.
|
||||
*/
|
||||
void
|
||||
checkAllocation (CommandRegistry& registry)
|
||||
{
|
||||
|
|
@ -186,16 +196,18 @@ namespace test {
|
|||
|
||||
ASSERT (pImpl);
|
||||
ASSERT (pImpl->isValid());
|
||||
ASSERT (!pImpl->canExec());
|
||||
ASSERT (1 == pImpl.use_count()); // no magic involved, we hold the only instance
|
||||
|
||||
PImpl clone = registry.createCloneImpl(*pImpl);
|
||||
ASSERT (clone->isValid());
|
||||
ASSERT (!clone->canExec());
|
||||
ASSERT (1 == clone.use_count());
|
||||
ASSERT (1 == pImpl.use_count());
|
||||
ASSERT (2+cnt_inst == registry.instance_count());
|
||||
|
||||
ASSERT (!isSameObject (*pImpl, *clone));
|
||||
// ASSERT (*pImpl == *clone); ///////////////////////////////////////TODO: comparison on CommandImpl ??
|
||||
ASSERT (*pImpl == *clone);
|
||||
|
||||
ASSERT (!pImpl->canExec());
|
||||
typedef Types<int> ArgType;
|
||||
|
|
@ -203,13 +215,13 @@ namespace test {
|
|||
pImpl->setArguments(arg);
|
||||
ASSERT (pImpl->canExec());
|
||||
|
||||
// ASSERT (*pImpl != *clone); // this proves the clone has indeed a separate identity
|
||||
ASSERT (!clone->canExec());
|
||||
ASSERT (!clone->canExec()); // this proves the clone has indeed a separate identity
|
||||
ASSERT (*pImpl != *clone);
|
||||
|
||||
// discard the first clone and overwrite with a new one
|
||||
clone = registry.createCloneImpl(*pImpl);
|
||||
ASSERT (2+cnt_inst == registry.instance_count());
|
||||
// ASSERT (*pImpl == *clone);
|
||||
ASSERT (*pImpl == *clone);
|
||||
ASSERT (clone->canExec());
|
||||
|
||||
clone.reset();
|
||||
|
|
@ -223,6 +235,6 @@ namespace test {
|
|||
|
||||
/** Register this test class... */
|
||||
LAUNCHER (CommandRegistry_test, "function controller");
|
||||
|
||||
|
||||
|
||||
|
||||
}} // namespace control::test
|
||||
|
|
|
|||
Loading…
Reference in a new issue