From: Rafał Długołęcki Date: Sun, 3 May 2015 10:18:15 +0000 (+0200) Subject: Test for callable void function arguments. X-Git-Tag: v0.2~24 X-Git-Url: https://git.dlugolecki.net.pl/?p=command.git;a=commitdiff_plain;h=f11e60384326f936aa57e55700e440e9e10f9466 Test for callable void function arguments. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index ecc69f9..c08c2cc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,6 +3,7 @@ AUTOMAKE_OPTIONS = subdir-objects TESTS = \ descriptive_holds_data.test \ callable_invokes_provided_function.test \ + callable_invokes_void_function.test \ parameter_is_descriptive.test \ argument_handles_string_value.test \ argument_handles_int_value.test \ @@ -18,6 +19,7 @@ AM_CXXFLAGS = -O3 -I$(top_srcdir)/include -std=c++11 descriptive_holds_data_test_SOURCES = descriptive/holds_data.cpp callable_invokes_provided_function_test_SOURCES = callable/invokes_provided_function.cpp +callable_invokes_void_function_test_SOURCES = callable/invokes_void_function.cpp parameter_is_descriptive_test_SOURCES = parameter/is_descriptive.cpp diff --git a/tests/callable/TestCallable.h b/tests/callable/TestCallable.h index 097e115..7fea870 100644 --- a/tests/callable/TestCallable.h +++ b/tests/callable/TestCallable.h @@ -13,3 +13,15 @@ public: this->call(test); } }; + +template<> +class TestCallable : public Callable { +public: + TestCallable(void (*function)(void)) + : Callable(function) { + } + + void callFunction() { + this->call(); + } +}; diff --git a/tests/callable/invokes_void_function.cpp b/tests/callable/invokes_void_function.cpp new file mode 100644 index 0000000..f0e4671 --- /dev/null +++ b/tests/callable/invokes_void_function.cpp @@ -0,0 +1,29 @@ +#include +#include + +#include "TestCallable.h" +#include "callable.h" + +using namespace std; +using namespace command; + +bool test = false; + +void function(void) { + test = true; +}; + +int main() { + TestCallable callable(function); + callable.callFunction(); + + if (test == true) { + cout << "Callable class calls provided function\n"; + return 0; + } + + cout << "Callable class does not call provided function\n"; + + return 1; +} +