Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
command-message-binding-test.cpp
Go to the documentation of this file.
1/*
2 CommandMessageBinding(Test) - verify argument binding via GenNode-Message, with immutable types
3
4 Copyright (C)
5 2016, 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"
23#include "lib/diff/gen-node.hpp"
24
25
26namespace steam {
27namespace control {
28namespace test {
29
30 using lib::time::Time;
36 using lib::diff::Rec;
37
38
39
40
41
42 namespace { // functions to be invoked through the command system
43
45
46 void
47 operate (Duration dur)
48 {
49 implicitTestState += dur;
50 }
51
52 Time
53 capture (Duration)
54 {
55 return implicitTestState;
56 }
57
58 void
60 {
62 }
63 }
64
65
66
67
68 /***********************************************************************/
85 class CommandMessageBinding_test : public Test
86 {
87
88 virtual void
89 run (Arg)
90 {
92 implicitTestState = five;
93
94 CommandDef ("test.command2")
95 .operation (operate)
96 .captureUndo (capture)
97 .undoOperation (undoIt)
98 ;
99
100
101
102 TimeSpan testSpan (randTime(), randTime());
103 Rec argMsg {testSpan};
104
105 // bind the command argument from a GenNode message
106 Command ourCmd = Command::get("test.command2");
107 CHECK (not ourCmd.canExec());
108
109 ourCmd.bindArg (argMsg);
110 CHECK (ourCmd.canExec());
111
112 // invoke the command
113 ourCmd();
114 CHECK (implicitTestState == five + Duration(testSpan));
115
116 // undo the effect of the command
117 ourCmd.undo();
118 CHECK (implicitTestState == five);
119 }
120 };
121
122
125
126
127}}} // namespace steam::control::test
object-like record of data.
Definition record.hpp:142
Duration is the internal Lumiera time metric.
A time interval anchored at a specific point 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.
Generic building block for tree shaped (meta)data structures.
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
lib::time::Time randTime()
create a random but not insane Time value between 1s ... 10min + 500ms
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
A collection of frequently used helper functions to support unit testing.
a family of time value like entities and their relationships.