Command system basic unit test pass

This commit is contained in:
Fischlurch 2009-10-06 05:11:30 +02:00
parent 5861597d7f
commit c8e049cdea
8 changed files with 30 additions and 55 deletions

View file

@ -265,7 +265,8 @@ namespace lib {
Slot<XX>
allocateSlot ()
{
TODO ("redirect to the corresponding pool allocator");
////////////////////////////////////////////////TICKET #231 :redirect to the corresponding pool allocator
TRACE (memory, "allocate %s", util::tyStr<XX>().c_str());
void* space = new char[sizeof(XX)];
allocCnt_.inc<XX>();
return Slot<XX> (this, space);
@ -275,7 +276,8 @@ namespace lib {
void
releaseSlot (void* entry)
{
TODO ("redirect to the corresponding pool allocator");
////////////////////////////////////////////////TICKET #231 :redirect to the corresponding pool allocator
TRACE (memory, "release %s", util::tyStr<XX>().c_str());
typedef char Storage[sizeof(XX)];
delete[] reinterpret_cast<Storage*> (entry);
allocCnt_.dec<XX>();

View file

@ -123,15 +123,25 @@ namespace control {
typedef unordered_map<Symbol, Command, hash<Symbol> > CmdIndex;
typedef map< const Command*, Symbol, order_by_impl> ReverseIndex;
TypedAllocationManager allocator_;
CmdIndex index_;
ReverseIndex ridx_;
TypedAllocationManager allocator_;
public:
static lib::Singleton<CommandRegistry> instance;
~CommandRegistry()
{
INFO (command, "Shutting down Command system...");
//////////////////////TICKET #295 : possibly remotely trigger Command mass suicide here....
ridx_.clear();
index_.clear();
}
/** register a command (Frontend) under the given ID
* @return either the new command, or an already existing
* command registered under the given ID */

View file

@ -3,7 +3,7 @@ TESTING "Component Test Suite: Proc-Layer controller" ./test-components --group=
PLANNED "CommandBasic_test" CommandBasic_test <<END
TEST "CommandBasic_test" CommandBasic_test <<END
END
@ -55,7 +55,7 @@ return: 0
END
PLANNED "Equality comparisons" CommandEquality_test <<END
TEST "Equality comparisons" CommandEquality_test <<END
return: 0
END

View file

@ -22,16 +22,13 @@
#include "lib/test/run.hpp"
#include "lib/test/test-helper.hpp"
#include "proc/control/command-def.hpp"
#include "lib/lumitime.hpp"
#include "lib/p.hpp"
//#include "lib/util.hpp"
#include <cstdlib>
using lumiera::Time;
//using util::contains;
using std::rand;
@ -45,7 +42,7 @@ namespace test {
namespace { // functions to be invoked through the command system
void
operate (P<Time> dummyObj, int randVal)
{
@ -73,6 +70,12 @@ namespace test {
* Shows how to define a simple command inline and how to
* trigger execution and UNDO. Verifies the command action
* takes place and is reverted again by the UNDO function.
*
* This is a simplified demonstration. Usually, commands would be defined
* in bulk and without specifying parameters. Later, typically client code
* accesses a handle by ID, binds to the concrete argument and dispatches
* the invocation. Note in this example that by using a smart-ptr as
* argument allows accessing an object by reference and late binding.
*
* @see control::Command
* @see control::CommandDef
@ -111,6 +114,6 @@ namespace test {
/** Register this test class... */
LAUNCHER (CommandBasic_test, "unit controller");
}} // namespace control::test

View file

@ -119,8 +119,9 @@ namespace test {
// now create a clone, registered under a different ID
Command cmd2 = cmd1.storeDef(TEST_CMD2);
ASSERT (cmd2 != cmd1);
ASSERT (cmd2 == cmd1);
cmd2.bind(54321);
ASSERT (cmd2 != cmd1);
// this created exactly one additional instance allocation:
ASSERT (1+cnt_inst == registry.instance_count());

View file

@ -23,15 +23,6 @@
#include "lib/test/run.hpp"
#include "lib/test/test-helper.hpp"
//#include "proc/asset/media.hpp"
//#include "proc/mobject/session.hpp"
//#include "proc/mobject/session/edl.hpp"
//#include "proc/mobject/session/testclip.hpp"
//#include "proc/mobject/test-dummy-mobject.hpp"
//#include "lib/p.hpp"
//#include "proc/mobject/placement.hpp"
//#include "proc/mobject/placement-index.hpp"
//#include "proc/mobject/explicitplacement.hpp"
#include "proc/control/command-invocation.hpp"
#include "proc/control/command-def.hpp"
//#include "lib/lumitime.hpp"
@ -61,13 +52,8 @@ namespace test {
using util::isSameObject;
using util::contains;
using util::str;
// using session::test::TestClip;
// using lumiera::P;
//using lumiera::typelist::BuildTupleAccessor;
@ -161,8 +147,8 @@ namespace test {
ASSERT ( 1234 == command1::check_);
// another shortcut, with static type check:
invoke (command1::operate) (5678);
ASSERT ( 1234+5678 == command1::check_);
// invoke (command1::operate) (5678); //////////////////TICKET #291 : unimplemented for now (9/09)
// ASSERT ( 1234+5678 == command1::check_);
com.undo();
ASSERT ( 0 == command1::check_);

View file

@ -23,15 +23,6 @@
#include "lib/test/run.hpp"
#include "lib/test/test-helper.hpp"
//#include "proc/asset/media.hpp"
//#include "proc/mobject/session.hpp"
//#include "proc/mobject/session/edl.hpp"
//#include "proc/mobject/session/testclip.hpp"
//#include "proc/mobject/test-dummy-mobject.hpp"
//#include "lib/p.hpp"
//#include "proc/mobject/placement.hpp"
//#include "proc/mobject/placement-index.hpp"
//#include "proc/mobject/explicitplacement.hpp"
#include "proc/control/command.hpp"
#include "proc/control/command-def.hpp"
#include "proc/control/handling-pattern.hpp"
@ -68,12 +59,8 @@ namespace test {
using boost::lexical_cast;
using util::contains;
using boost::ref;
// using session::test::TestClip;
// using lumiera::P;
//using lumiera::typelist::BuildTupleAccessor;
using lumiera::error::LUMIERA_ERROR_EXTERNAL;

View file

@ -23,15 +23,6 @@
#include "lib/test/run.hpp"
#include "lib/test/test-helper.hpp"
//#include "proc/asset/media.hpp"
//#include "proc/mobject/session.hpp"
//#include "proc/mobject/session/edl.hpp"
//#include "proc/mobject/session/testclip.hpp"
//#include "proc/mobject/test-dummy-mobject.hpp"
//#include "lib/p.hpp"
//#include "proc/mobject/placement.hpp"
//#include "proc/mobject/placement-index.hpp"
//#include "proc/mobject/explicitplacement.hpp"
#include "proc/control/command-def.hpp"
//#include "lib/lumitime.hpp"
#include "lib/util.hpp"
@ -63,13 +54,8 @@ namespace test {
// using lib::test::showSizeof;
// using util::isSameObject;
// using util::contains;
// using session::test::TestClip;
// using lumiera::P;
//using lumiera::typelist::BuildTupleAccessor;
// using lumiera::error::LUMIERA_ERROR_EXTERNAL;