Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
command-basic-test.cpp
Go to the documentation of this file.
1/*
2 CommandBasic(Test) - checking simple SteamDispatcher command definition and execution
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"
22#include "lib/p.hpp"
23
24
25namespace steam {
26namespace control {
27namespace test {
28
29 using lib::P;
30 using lib::makeP;
31 using lib::time::Time;
35
36
37
38
39
40 namespace { // functions to be invoked through the command system
41
42 void
44 {
45 *dummyObj += TimeValue(randVal);
46 }
47
48 Offset
50 {
51 return Offset{*dummyObj};
52 }
53
54 void
56 {
58 }
59
60 }
61
62
63
64 /***********************************************************************/
80 class CommandBasic_test : public Test
81 {
82
83 virtual void
84 run (Arg)
85 {
86 seedRand();
87 int randVal{rani(10) - 5};
89 TimeValue randomTime(randVal);
90 auto obj = makeP<TimeVar>(five);
91
92 CommandDef ("test.command1")
93 .operation (operate)
94 .captureUndo (capture)
95 .undoOperation (undoIt)
96 .bind (obj, randVal)
97 ;
98
99
100 Command ourCmd = Command::get("test.command1");
101
102 // invoke the command
103 CHECK (*obj == five);
104 ourCmd();
105 CHECK (*obj == five + randomTime);
106
107 // undo the effect of the command
108 ourCmd.undo();
109 CHECK (*obj == five);
110 }
111 };
112
113
115 LAUNCHER (CommandBasic_test, "unit controller");
116
117
118}}} // namespace steam::control::test
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition p.hpp:77
Offset measures a distance in time.
basic constant internal time value.
a mutable time value, behaving like a plain number, allowing copy and re-accessing
Lumiera's internal time value datatype.
Helper class used solely for defining a Command-Object.
auto operation(FUN operation_to_define)
Handle object representing a single Command instance to be used by client code.
Definition command.hpp:120
static Command get(Symbol cmdID)
Access existing command for use.
Definition command.cpp:120
Actually defining a command and binding it to execution parameters.
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
P< X > makeP(ARGS &&... ctorArgs)
Helper to create and manage by lib::P.
Definition p.hpp:142
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
a family of time value like entities and their relationships.