46 using std::regex_replace;
63 testString =
"Ichthyostega wuz here";
68 operate (
string search,
string replace)
70 testString = regex_replace (testString, regex(search), replace);
74 capture (
string,
string)
80 undoIt (
string,
string,
string oldVal)
90 def.operation(operate)
92 .undoOperation(undoIt);
126 Literal empty_text = def_empty;
127 CHECK (empty_text ==
"to be or not to be");
128 CHECK (
sizeof(def_empty) ==
sizeof(
Literal));
129 CHECK (
sizeof(def_empty) ==
sizeof(
char*));
131 const char* actualContent =
reinterpret_cast<char*&
>(def_empty);
132 CHECK (actualContent == empty_text);
135 CHECK (
string(def_empty) ==
string(empty_text));
138 CHECK (def_empty ==
CommandSetup(
"to be or not to be"));
139 CHECK (def_empty !=
CommandSetup(
"to pee or not to pee"));
149 def_0 = do_something_pointless;
156 def.operation (operate)
157 .captureUndo (capture)
158 .undoOperation (undoIt);
164 def.operation ([&](uint cnt)
168 .captureUndo ([](uint) ->
string 172 .undoOperation ([](uint,
string oldVal)
178 _Fmt pattern{
" %d times."};
190 CHECK (
testString ==
"Ichthyostega wuz here");
194 CHECK (not Command::defined(
"test.CommandSetup.def_0"));
197 CHECK (Command::defined(
"test.CommandSetup.def_1"));
198 CHECK (Command::defined(
"test.CommandSetup.def_2"));
201 Command com1{
"test.CommandSetup.def_1"};
202 Command com2{
"test.CommandSetup.def_2"};
204 com1.
bind (
string{
"^(\\w+)"},
string{
"No $1"});
205 com2.
bind (uint(42));
207 CHECK (
testString ==
"Ichthyostega wuz here");
209 CHECK (
testString ==
"No Ichthyostega wuz here");
212 CHECK (
testString ==
"No Ichthyostega wuz here 42 times.");
215 CHECK (
testString ==
"Ichthyostega wuz here");
238 Command{test_CommandSetup_test}
243 CHECK (not c1.canExec());
244 CHECK (not c2.canExec());
246 c1.
bind (
string{
"wuz.*"},
string{
"the Devonian"});
247 c2.
bind (
string{
"\\s*\\w+$"},
string{
""});
248 CHECK (c1.canExec());
249 CHECK (c2.canExec());
250 CHECK (not Command::canExec(test_CommandSetup_test));
252 CHECK (
testString ==
"Ichthyostega wuz here");
255 CHECK (
testString ==
"Ichthyostega the Devonian");
267 CHECK (
testString ==
"Ichthyostega wuz here");
269 Command::remove(
"c1");
270 Command::remove(
"c2");
272 CHECK (not Command::defined(
"c1"));
273 CHECK (not Command::defined(
"c2"));
274 CHECK (Command::defined(test_CommandSetup_test));
Helper class used solely for defining a Command-Object.
void verify_DefinitionSetup()
void verify_DefinitionRegistration()
inline string literal This is a marker type to indicate that
#define COMMAND_DEFINITION(_NAME_)
Macro to write command definitions in a compact form.
Common ID definitions for Steam-Layer commands.
Command storeDef(Symbol newCmdID) const
create a clone definition
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
Marker and Helper for writing Steam-Layer Command definitions.
static size_t pendingCnt()
diagnostics / test
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
static void invokeDefinitionClosures()
void verify_standardUsage()
Handle object representing a single Command instance to be used by client code.
RET bind()
Accept dummy binding (0 Arg)
string testString
will be manipulated by the commands we define
Actually defining a command and binding it to execution parameters.