Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
test-dummy-commands.hpp
Go to the documentation of this file.
1/*
2 TEST-DUMMY-COMMANDS.hpp - dummy functions used to build test commands
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
14
29#ifndef COMMAND_TEST_DUMMY_COMMANDS_H
30#define COMMAND_TEST_DUMMY_COMMANDS_H
31
32#include "lib/error.hpp"
35
36#include <functional>
37#include <sstream>
38#include <string>
39
40
41namespace steam {
42namespace control {
43namespace test {
44
45 using std::ostringstream;
46 using std::function;
47 using std::string;
48
49
50
51
52 namespace command1 {
53
54 extern int64_t check_;
55
56
57 inline void
59 {
60 check_ += someVal;
61 }
62
63 inline int64_t
64 capture (int)
65 {
66 return check_;
67 }
68
69 inline void
71 {
72 check_ = oldVal;
73 }
74
75 }
76
77
78
79
80
81 namespace command2 {
82
84
85
86 extern ostringstream check_;
87
88
89 typedef function<string()> FunS;
90
91 inline void
92 operate (FunS func, bool *fail)
93 {
94 if (fail and *fail) throw External("simulated exception");
95
96 check_ << func();
97 }
98
99 inline string
100 capture (FunS, bool*)
101 {
102 return check_.str();
103 }
104
105 inline void
106 undoIt (FunS, bool *fail, string previousProtocol)
107 {
108 if (fail and *fail) throw External("simulated exception in UNDO");
109
110 check_.str("");
111 check_ << previousProtocol << "|UNDO|";
112 }
113
114 }
115
116
117
118
119
120 namespace command3 {
121
122 extern ulong check_;
123
124
125 inline void
127 {
128 ++check_;
129 }
130
131 inline ulong
133 {
134 return check_;
135 }
136
137 inline void
139 {
140 check_ = oldVal;
141 }
142
143 }
144
145
146 /* ==== global static prototype definitions for these commands ==== */
147
149 extern CommandSetup test_Dummy_command1;
150
153 extern CommandSetup test_Dummy_command2;
154
156 extern CommandSetup test_Dummy_command3;
157
158
159}}} // namespace steam::control::test
160#endif
Marker and Helper for writing Steam-Layer Command definitions.
Provision for setup of concrete commands for use by the UI.
Lumiera error handling (C++ interface).
unsigned long int ulong
Definition integral.hpp:31
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
LumieraError< LERR_(EXTERNAL)> External
Definition error.hpp:213
void undoIt(int, int64_t oldVal)
int64_t check_
< test command just adding a given value
void undoIt(FunS, bool *fail, string previousProtocol)
void operate(FunS func, bool *fail)
ulong check_
< test command with zero arguments
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
A collection of frequently used helper functions to support unit testing.