Test for callable void function arguments.
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Sun, 3 May 2015 10:18:15 +0000 (12:18 +0200)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Sun, 3 May 2015 10:18:15 +0000 (12:18 +0200)
tests/Makefile.am
tests/callable/TestCallable.h
tests/callable/invokes_void_function.cpp [new file with mode: 0644]

index ecc69f9e54216217bda5987078bfb7fec3143c1f..c08c2cc69259ed537edc5f7bc0d40b4deca5466c 100644 (file)
@@ -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
 
index 097e115b9acbee7be45c051ab92c432e2d91b998..7fea87045200dacf0823ed10989ed91158235ceb 100644 (file)
@@ -13,3 +13,15 @@ public:
         this->call(test);
     }
 };
+
+template<>
+class TestCallable<void> : public Callable<void> {
+public:
+    TestCallable(void (*function)(void))
+        : Callable<void>(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 (file)
index 0000000..f0e4671
--- /dev/null
@@ -0,0 +1,29 @@
+#include <cstring>
+#include <iostream>
+
+#include "TestCallable.h"
+#include "callable.h"
+
+using namespace std;
+using namespace command;
+
+bool test = false;
+
+void function(void) {
+    test = true;
+};
+
+int main() {
+    TestCallable<void> 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;
+}
+