From: Rafał Długołęcki Date: Mon, 18 Apr 2016 23:56:57 +0000 (+0200) Subject: Add tests coverage report generation X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=e0fda02032d7d502e57e24eb218da9e24155541a;p=command.git Add tests coverage report generation --- diff --git a/test-all.sh b/test-all.sh new file mode 100644 index 0000000..4061274 --- /dev/null +++ b/test-all.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ ! -f configure ] ; then + ./autogen.sh +fi + +CXXFLAGS='--coverage -O0' ./configure + +make check +cd tests; make cov \ No newline at end of file diff --git a/tests/Makefile.am b/tests/Makefile.am index e17e256..fa1fbc4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -48,6 +48,23 @@ AM_CXXFLAGS = -I$(top_srcdir)/include -std=c++11 check-% : %.test all @srcdir=$(srcdir); export srcdir; +cov-reset: + rm -fr coverage + find . -name "*.gcda" -exec rm {} \; + find . -name "*.gcno" -exec rm {} \; + lcov --directory . --zerocounters + +cov-report: + mkdir -p coverage + lcov --compat-libtool --directory . --capture --output-file coverage/app.info + genhtml -o coverage/ coverage/app.info + +cov: + make cov-report + +clean-local: + make cov-reset + descriptive_holds_data_test_SOURCES = descriptive/holds_data.cpp callable_invokes_provided_function_test_SOURCES = callable/invokes_provided_function.cpp diff --git a/tests/callable/TestCallableFunctionPointer.h b/tests/callable/TestCallableFunctionPointer.h new file mode 100644 index 0000000..7fea870 --- /dev/null +++ b/tests/callable/TestCallableFunctionPointer.h @@ -0,0 +1,27 @@ +#include "callable.h" + +using namespace command; + +template +class TestCallable : public Callable { +public: + TestCallable(void (*function)(ArgumentType)) + : Callable(function) { + } + + void callFunction(ArgumentType test) { + this->call(test); + } +}; + +template<> +class TestCallable : public Callable { +public: + TestCallable(void (*function)(void)) + : Callable(function) { + } + + void callFunction() { + this->call(); + } +};