From a13270a6b83faee0ae8f0bb7d55c0069dc275e06 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 31 Mar 2017 22:35:11 +0200 Subject: [PATCH] Commands: static registration for the existing test dummy commands Up to now, these dummy functions where used by various unit tests directly, by creating command definitions within the test fixture. But since it is foreseeable that we'll need dummy commands for various further unit tests, it seems adequate to setup a global static registration with the newly created system of command registrations for these dummies. --- .../core/proc/control/test-dummy-commands.cpp | 34 +++++++++++++++++++ .../core/proc/control/test-dummy-commands.hpp | 14 ++++++++ 2 files changed, 48 insertions(+) diff --git a/tests/core/proc/control/test-dummy-commands.cpp b/tests/core/proc/control/test-dummy-commands.cpp index 64e4aaa67..138855f82 100644 --- a/tests/core/proc/control/test-dummy-commands.cpp +++ b/tests/core/proc/control/test-dummy-commands.cpp @@ -22,6 +22,7 @@ #include "proc/control/test-dummy-commands.hpp" +#include "proc/control/command-def.hpp" @@ -48,4 +49,37 @@ namespace test { } + /* ==== global static prototype definitions for these commands ==== */ + + /** + * @remark The following definition(s) will be evaluated automatically ON_GLOBAL_INIT + * They result in "prototype" definitions of these dummy commands to be + * registered under the names as used here in the macro invocation. + * Thus `test_Dummy_command1` will invoke command1::operate(int) etc. + * @see CommandSetup_test + */ + + COMMAND_DEFINITION (test_Dummy_command1) + { + def.operation(command1::operate) + .captureUndo(command1::capture) + .undoOperation(command1::undoIt); + }; + + COMMAND_DEFINITION (test_Dummy_command2) + { + def.operation(command2::operate) + .captureUndo(command2::capture) + .undoOperation(command2::undoIt); + }; + + COMMAND_DEFINITION (test_Dummy_command3) + { + def.operation(command3::operate) + .captureUndo(command3::capture) + .undoOperation(command3::undoIt); + }; + + + }}} // namespace proc::control::test diff --git a/tests/core/proc/control/test-dummy-commands.hpp b/tests/core/proc/control/test-dummy-commands.hpp index ef90c0873..6f02ff0cd 100644 --- a/tests/core/proc/control/test-dummy-commands.hpp +++ b/tests/core/proc/control/test-dummy-commands.hpp @@ -40,6 +40,7 @@ #include "lib/error.hpp" #include "lib/test/test-helper.hpp" +#include "proc/control/command-setup.hpp" #include #include @@ -151,5 +152,18 @@ namespace test { } + /* ==== global static prototype definitions for these commands ==== */ + + /** test dummy command to add the argument to a global variable */ + extern CommandSetup test_Dummy_command1; + + /** test dummy command to invoke the given functor and + * append the result onto a global log string buffer */ + extern CommandSetup test_Dummy_command2; + + /** test dummy command to increment a global variable; no arguments */ + extern CommandSetup test_Dummy_command3; + + }}} // namespace proc::control::test #endif