Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
command-clone-builder-test.cpp
Go to the documentation of this file.
1/*
2 CommandCloneBuilder(Test) - verify building an implementation clone
3
4 Copyright (C)
5 2009, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
19#include "lib/test/run.hpp"
25#include "lib/symbol.hpp"
26#include "lib/util.hpp"
27#include "lib/p.hpp"
28
30
31
32namespace steam {
33namespace control {
34namespace test {
35
36 using namespace lib::meta;
37
39
40
41 namespace { // test config...
43 }
44
45
46
47
48
49
50 /****************************************************************************/
64 class CommandCloneBuilder_test : public Test
65 {
66
67
68 virtual void
69 run (Arg)
70 {
71 seedRand();
73 CHECK (&registry);
74 uint cnt_inst = registry.instance_count();
75
76 {
77 PCmdImpl source = buildTestImplFrame (registry);
78 PCmdImpl clone = registry.createCloneImpl (*source);
79
80 verifySeparation (source, clone);
81 }
82
83 CHECK (cnt_inst == registry.instance_count());
84 }
85
86
87
90 {
91 // simulate what normally happens within a CommandDef
92 typedef void Sig_oper(int);
93 typedef long Sig_capt(int);
94 typedef void Sig_undo(int,long);
95
99
102
103 // make ready for execution
105 CHECK (cmd->canExec());
106 return cmd;
107 }
108
109
111 void
113 {
114 TypedArguments<std::tuple<int>> arg {std::make_tuple (rani (10000))};
115 cmd.setArguments (arg);
116 CHECK (cmd.canExec());
117 }
118
119
125 void
127 {
128 CHECK (orig and copy);
129 CHECK (orig->canExec());
130 CHECK (copy->canExec());
131
132
133 // prepare for command invocation on implementation level....
134 HandlingPattern const& testExec = HandlingPattern::get(TEST_HANDLING_PATTERN);
136
138 CHECK ( orig->canExec());
139 CHECK (!orig->canUndo());
140 testExec.exec (*orig, "Execute original"); // EXEC 1
143 CHECK (orig->canUndo());
144
145 CHECK (!copy->canUndo());
146 testExec.exec (*copy, "Execute clone"); // EXEC 2
148 CHECK (copy->canUndo());
149
150 // invoke UNDO on the clone
151 testExec.undo (*copy, "Undo clone"); // UNDO 2
153
154 // invoke UNDO on original
155 testExec.undo (*orig, "Undo original"); // UNDO 1
157 }
158
159 };
160
161
163 LAUNCHER (CommandCloneBuilder_test, "function controller");
164
165
166}}} // namespace steam::control::test
Implementation helper to bind Steam-Layer commands with arbitrary argument tuples.
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition p.hpp:77
Steam-Layer Command implementation.
Registry managing command implementation objects (Singleton).
shared_ptr< CommandImpl > newCommandImpl(function< SIG_OPER > &operFunctor, function< SIG_CAPT > &captFunctor, function< SIG_UNDO > &undoFunctor)
set up a new command implementation frame
static lib::Depend< CommandRegistry > instance
storage for the singleton factory used to access CommandRegistry
shared_ptr< CommandImpl > createCloneImpl(CommandImpl const &refObject)
create an allocation for holding a clone of the given CommandImpl data.
Definition command.cpp:219
Interface: Operation Skeleton how to invoke or undo a command.
static HandlingPattern const & get(ID id)
retrieve the pre-configured pattern
void bindRandArgument(CommandImpl &cmd)
Helper: create random command parameter binding.
Top level of the command implementation.
Managing command definitions and the storage of individual command objects.
Pre-defined command execution skeletons.
unsigned int uint
Definition integral.hpp:29
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
void undoIt(int, int64_t oldVal)
int64_t check_
< test command just adding a given value
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
Customised refcounting smart pointer.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Marker types to indicate a literal string and a Symbol.
Some dummy command functions used for building unit test cases.
Metaprogramming with tuples-of-types and the std::tuple record.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...