From c1062c97b5d408ab7c02b517f13374abdf077f57 Mon Sep 17 00:00:00 2001 From: Fraser Hutchison Date: Fri, 27 Sep 2013 00:31:59 +0100 Subject: [PATCH 1/3] Temporarily disabled VC warning C4702. --- include/internal/clara.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/internal/clara.h b/include/internal/clara.h index fa58da79..114bd843 100644 --- a/include/internal/clara.h +++ b/include/internal/clara.h @@ -155,6 +155,10 @@ namespace Clara { void (*function)( C& ); }; +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4702) +#endif template struct BoundBinaryFunction : IArgFunction{ BoundBinaryFunction( void (*_function)( C&, T ) ) : function( _function ) {} @@ -172,6 +176,9 @@ namespace Clara { virtual IArgFunction* clone() const { return new BoundBinaryFunction( *this ); } void (*function)( C&, T ); }; +#ifdef _MSC_VER +# pragma warning(pop) +#endif template BoundArgFunction makeBoundField( M C::* _member ) { From 2267c950a30a3deb3859a1d3354d3082fa4da2f8 Mon Sep 17 00:00:00 2001 From: Fraser Hutchison Date: Thu, 24 Oct 2013 02:01:17 +0100 Subject: [PATCH 2/3] Fixes overflow issue when listing tests. --- include/internal/catch_list.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp index 550107f8..45807edd 100644 --- a/include/internal/catch_list.hpp +++ b/include/internal/catch_list.hpp @@ -86,12 +86,13 @@ namespace Catch { std::cout << nameCol; } if( i < tagsWrapper.size() && !tagsWrapper[i].empty() ) { + size_t padLen( maxNameLen > nameCol.size() ? maxNameLen - nameCol.size() : 0 ); if( i == 0 ) { Colour colourGuard( Colour::SecondaryText ); - std::cout << " " << std::string( maxNameLen - nameCol.size(), '.' ) << " "; + std::cout << " " << std::string( padLen, '.' ) << " "; } else { - std::cout << std::string( maxNameLen - nameCol.size(), ' ' ) << " "; + std::cout << std::string( padLen, ' ' ) << " "; } std::cout << tagsWrapper[i]; } From 162ff2cb438065852b56e02880469d0f42d39fce Mon Sep 17 00:00:00 2001 From: Fraser Hutchison Date: Thu, 24 Oct 2013 02:33:01 +0100 Subject: [PATCH 3/3] Added CTest targets to perform basic test of --list-tests and --list-tags options. --- projects/CMake/CMakeLists.txt | 49 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index cff62616..5e4d8517 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -1,37 +1,40 @@ cmake_minimum_required(VERSION 2.8) -project(Catch C CXX) -message("configure: Catch/SelfTest") +project(Catch) # define some folders -set(CATCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..") +get_filename_component(CATCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PATH) +get_filename_component(CATCH_DIR "${CATCH_DIR}" PATH) set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest) -set(SCRIPTS_DIR ${CATCH_DIR}/scripts) # define the sources of the self test -set( - SOURCES - ${SELF_TEST_DIR}/ApproxTests.cpp - ${SELF_TEST_DIR}/BDDTests.cpp - ${SELF_TEST_DIR}/catch_self_test.cpp - ${SELF_TEST_DIR}/ClassTests.cpp - ${SELF_TEST_DIR}/CmdLineTests.cpp - ${SELF_TEST_DIR}/ConditionTests.cpp - ${SELF_TEST_DIR}/ExceptionTests.cpp - ${SELF_TEST_DIR}/GeneratorTests.cpp - ${SELF_TEST_DIR}/MessageTests.cpp - ${SELF_TEST_DIR}/MiscTests.cpp - ${SELF_TEST_DIR}/SectionTrackerTests.cpp - ${SELF_TEST_DIR}/TestMain.cpp - ${SELF_TEST_DIR}/TrickyTests.cpp - ${SELF_TEST_DIR}/VariadicMacrosTests.cpp +set(SOURCES + ${SELF_TEST_DIR}/ApproxTests.cpp + ${SELF_TEST_DIR}/BDDTests.cpp + ${SELF_TEST_DIR}/catch_self_test.cpp + ${SELF_TEST_DIR}/ClassTests.cpp + ${SELF_TEST_DIR}/CmdLineTests.cpp + ${SELF_TEST_DIR}/ConditionTests.cpp + ${SELF_TEST_DIR}/ExceptionTests.cpp + ${SELF_TEST_DIR}/GeneratorTests.cpp + ${SELF_TEST_DIR}/MessageTests.cpp + ${SELF_TEST_DIR}/MiscTests.cpp + ${SELF_TEST_DIR}/SectionTrackerTests.cpp + ${SELF_TEST_DIR}/TestMain.cpp + ${SELF_TEST_DIR}/TrickyTests.cpp + ${SELF_TEST_DIR}/VariadicMacrosTests.cpp ) # configure the executable include_directories(${CATCH_DIR}/include) add_executable(SelfTest ${SOURCES}) -# configure unit tests via ctest +# configure unit tests via CTest enable_testing() -add_test(NAME SelfTest_run COMMAND SelfTest) -#add_test(NAME SelfTest_run COMMAND python ${SCRIPTS_DIR}/approvalTests.py "${CMAKE_CURRENT_BINARY_DIR}/SelfTest") +add_test(NAME RunTests COMMAND SelfTest) + +add_test(NAME ListTests COMMAND SelfTest --list-tests) +set_tests_properties(ListTests PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ test cases") + +add_test(NAME ListTags COMMAND SelfTest --list-tags) +set_tests_properties(ListTags PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ tags")