37 using std::regex_replace;
54 testString =
"Ichthyostega wuz here";
59 operate (
string search,
string replace)
61 testString = regex_replace (testString, regex(search), replace);
65 capture (
string,
string)
71 undoIt (
string,
string,
string oldVal)
81 def.operation(operate)
83 .undoOperation(undoIt);
117 Literal empty_text = def_empty;
118 CHECK (empty_text ==
"to be or not to be");
119 CHECK (
sizeof(def_empty) ==
sizeof(
Literal));
120 CHECK (
sizeof(def_empty) ==
sizeof(
char*));
122 const char* actualContent =
reinterpret_cast<char*&
>(def_empty);
123 CHECK (actualContent == empty_text);
126 CHECK (
string(def_empty) ==
string(empty_text));
129 CHECK (def_empty ==
CommandSetup(
"to be or not to be"));
130 CHECK (def_empty !=
CommandSetup(
"to pee or not to pee"));
140 def_0 = do_something_pointless;
147 def.operation (operate)
148 .captureUndo (capture)
149 .undoOperation (undoIt);
155 def.operation ([&](uint cnt)
159 .captureUndo ([](uint) ->
string 163 .undoOperation ([](uint,
string oldVal)
169 _Fmt pattern{
" %d times."};
181 CHECK (
testString ==
"Ichthyostega wuz here");
185 CHECK (not Command::defined(
"test.CommandSetup.def_0"));
188 CHECK (Command::defined(
"test.CommandSetup.def_1"));
189 CHECK (Command::defined(
"test.CommandSetup.def_2"));
192 Command com1{
"test.CommandSetup.def_1"};
193 Command com2{
"test.CommandSetup.def_2"};
195 com1.
bind (
string{
"^(\\w+)"},
string{
"No $1"});
196 com2.
bind (uint(42));
198 CHECK (
testString ==
"Ichthyostega wuz here");
200 CHECK (
testString ==
"No Ichthyostega wuz here");
203 CHECK (
testString ==
"No Ichthyostega wuz here 42 times.");
206 CHECK (
testString ==
"Ichthyostega wuz here");
229 Command{test_CommandSetup_test}
234 CHECK (not c1.canExec());
235 CHECK (not c2.canExec());
237 c1.
bind (
string{
"wuz.*"},
string{
"the Devonian"});
238 c2.
bind (
string{
"\\s*\\w+$"},
string{
""});
239 CHECK (c1.canExec());
240 CHECK (c2.canExec());
241 CHECK (not Command::canExec(test_CommandSetup_test));
243 CHECK (
testString ==
"Ichthyostega wuz here");
246 CHECK (
testString ==
"Ichthyostega the Devonian");
258 CHECK (
testString ==
"Ichthyostega wuz here");
260 Command::remove(
"c1");
261 Command::remove(
"c2");
263 CHECK (not Command::defined(
"c1"));
264 CHECK (not Command::defined(
"c2"));
265 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
Simplistic 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.