diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7c5acea..cebf214 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,24 +1,15 @@ -cmake_minimum_required (VERSION 2.6) -project (CPP_UTILS_TEST) +add_definitions(-Wall -Werror -pedantic -Weffc++ -Wshadow -ggdb -fprofile-arcs -ftest-coverage) -message(STATUS "Test dir:") - -set (CXX_FLAGS "-Wall -Wextra -pedantic") -add_definitions( ${CXX_FLAGS} ) -message(STATUS "g++ flags: ${CXX_FLAGS}") - -include_directories (../include) -message(STATUS "include dir: ${CPP_UTILS_LIB}/include") - -add_executable (testThreadPool main_threadpool.cpp) -target_link_libraries (testThreadPool CppUtils) +include_directories(../include) +#add_library (CppUtils src/*) find_package(CxxTest) if(CXXTEST_FOUND) - set(CXXTEST_USE_PERL TRUE) - include_directories(${CXXTEST_INCLUDE_DIR}) - enable_testing() -# CXXTEST_ADD_TEST(unittest_sos check_sos.cpp ${SOS_TEST_PATH}/check_sos.h) -# target_link_libraries(unittest_sos CppUtils) -endif() \ No newline at end of file +set(CXXTEST_USE_PERL TRUE) +include_directories(${CXXTEST_INCLUDE_DIR} ../include) +enable_testing() +CXXTEST_ADD_TEST(unittest_multiple generated_main.cpp unittest_multiple.hpp ) +target_link_libraries(unittest_multiple CppUtils gcov) +endif() + diff --git a/test/run_test.sh b/test/run_test.sh new file mode 100755 index 0000000..5322faf --- /dev/null +++ b/test/run_test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Usage: ./run_test.sh + +pre="\E[00;32m" +post="\E[00;00m" + +echo -e "${pre}Reset coverage files${post}" +lcov --directory . -z +rm -f ./lcov.info + +echo -e "${pre}Run tests${post}" +$1 + +echo -e "${pre}Capture coverage info${post}" +lcov --directory . --capture -o lcov.info + +echo -e "${pre}Filtering coverage tracefile${post}" +lcov -r lcov.info "g++-v*" -o lcov.info +lcov -r lcov.info "/usr/include/cxxtest*" -o lcov.info +lcov -r lcov.info "$(PWD)/test/*" -o lcov.info + +echo -e "${pre}Generating HTML${post}" +rm -rf ./cov +mkdir cov +genhtml -o ./cov lcov.info diff --git a/test/unittest_multiple.hpp b/test/unittest_multiple.hpp new file mode 100644 index 0000000..fa42b9b --- /dev/null +++ b/test/unittest_multiple.hpp @@ -0,0 +1,16 @@ +#include + + + +class MyTestSuite : public CxxTest::TestSuite +{ + +public: + + void testAddition() + { + TS_ASSERT_EQUALS( 1 + 1, 2 ); + + } + +};