mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-29 04:35:29 +03:00
Compare commits
30 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10e50ad70c | ||
|
|
854cae2518 | ||
|
|
37df68be21 | ||
|
|
0ea55a251b | ||
|
|
f871471d90 | ||
|
|
c269666681 | ||
|
|
d355e127be | ||
|
|
2423fcac76 | ||
|
|
bdef2bdd62 | ||
|
|
a7d506d7eb | ||
|
|
bc5d87f484 | ||
|
|
a6fdaeef12 | ||
|
|
85b3666173 | ||
|
|
8c460c48e6 | ||
|
|
65af507437 | ||
|
|
ee996164f2 | ||
|
|
af28992c5d | ||
|
|
33e6314753 | ||
|
|
07d4872076 | ||
|
|
0b15459ee4 | ||
|
|
0a6857e388 | ||
|
|
d7bd757862 | ||
|
|
0757ba8f90 | ||
|
|
c331bb0dea | ||
|
|
85bade33f5 | ||
|
|
a2fe23887a | ||
|
|
bb49539107 | ||
|
|
c4ab9d31ed | ||
|
|
8f7a263446 | ||
|
|
9eba823269 |
8 changed files with 72 additions and 23 deletions
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 2.8.1)
|
||||
project(UnitTest++)
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(UnitTest++ VERSION 2.1.0)
|
||||
|
||||
option(UTPP_USE_PLUS_SIGN
|
||||
"Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths"
|
||||
|
|
@ -11,8 +11,16 @@ option(UTPP_AMPLIFY_WARNINGS
|
|||
"Set this to OFF if you wish to use CMake default warning levels; should generally only use to work around support issues for your specific compiler"
|
||||
ON)
|
||||
|
||||
if(MSVC14 OR MSVC12)
|
||||
# has the support we need
|
||||
set(LIB_SUFFIX "" CACHE STRING "Identifier to add to end of lib directory name e.g. 64 for lib64")
|
||||
|
||||
if (MSVC)
|
||||
# CHECK_CXX_COMPILER_FLAG could be used
|
||||
# but MSVC version is preferred for feature requirements
|
||||
if (MSVC14 OR MSVC12)
|
||||
# has the support we need
|
||||
else()
|
||||
message(STATUS "The MSVC compiler version does not support UnitTest++ C++11 features.")
|
||||
endif()
|
||||
else()
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
|
||||
|
|
@ -22,7 +30,7 @@ else()
|
|||
elseif(COMPILER_SUPPORTS_CXX11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
else()
|
||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
@ -56,6 +64,8 @@ source_group(${platformDir_} FILES ${platformHeaders_} ${platformSources_})
|
|||
|
||||
# create the lib
|
||||
add_library(UnitTest++ STATIC ${headers_} ${sources_} ${platformHeaders_} ${platformSources_})
|
||||
add_library(UnitTest++::UnitTest++ ALIAS UnitTest++)
|
||||
|
||||
|
||||
if(${UTPP_USE_PLUS_SIGN})
|
||||
set_target_properties(UnitTest++ PROPERTIES OUTPUT_NAME UnitTest++)
|
||||
|
|
@ -66,13 +76,16 @@ endif()
|
|||
file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h)
|
||||
source_group( "" FILES ${TEST_SRCS})
|
||||
add_executable(TestUnitTest++ ${TEST_SRCS})
|
||||
include_directories(.)
|
||||
|
||||
|
||||
if(${UTPP_USE_PLUS_SIGN})
|
||||
set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++)
|
||||
endif()
|
||||
|
||||
target_link_libraries(TestUnitTest++ UnitTest++)
|
||||
target_link_libraries(TestUnitTest++
|
||||
PUBLIC
|
||||
UnitTest++::UnitTest++
|
||||
)
|
||||
|
||||
# run unit tests as post build step
|
||||
add_custom_command(TARGET TestUnitTest++
|
||||
|
|
@ -92,19 +105,41 @@ else()
|
|||
set (UTPP_INSTALL_DESTINATION "include/UnitTestPP")
|
||||
endif()
|
||||
|
||||
set(config_install_dir_ lib/cmake/${PROJECT_NAME})
|
||||
set(targets_export_name_ "${PROJECT_NAME}Targets")
|
||||
target_include_directories( UnitTest++
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/UnitTest++>
|
||||
)
|
||||
set_target_properties(UnitTest++ PROPERTIES DEBUG_POSTFIX "-d")
|
||||
set_target_properties(TestUnitTest++ PROPERTIES DEBUG_POSTFIX "-d")
|
||||
|
||||
install(TARGETS UnitTest++ EXPORT "${targets_export_name_}" DESTINATION lib)
|
||||
set(config_install_dir_ lib${LIB_SUFFIX}/cmake/${PROJECT_NAME})
|
||||
set(targets_export_name_ "${PROJECT_NAME}Targets")
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
cmake/UnitTest++ConfigVersion.cmake
|
||||
VERSION ${UnitTest++_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
install(TARGETS UnitTest++ EXPORT "${targets_export_name_}" DESTINATION lib${LIB_SUFFIX})
|
||||
install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION})
|
||||
install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_})
|
||||
install(FILES cmake/UnitTest++Config.cmake DESTINATION "${config_install_dir_}")
|
||||
install(EXPORT "${targets_export_name_}" DESTINATION "${config_install_dir_}")
|
||||
install(FILES
|
||||
cmake/UnitTest++Config.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmake/UnitTest++ConfigVersion.cmake
|
||||
DESTINATION "${config_install_dir_}")
|
||||
install(EXPORT "${targets_export_name_}" NAMESPACE "UnitTest++::" DESTINATION "${config_install_dir_}")
|
||||
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
|
||||
set(includedir ${CMAKE_INSTALL_PREFIX}/include/UnitTest++)
|
||||
configure_file("UnitTest++.pc.in" "UnitTest++.pc" @ONLY)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig)
|
||||
else()
|
||||
set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig)
|
||||
endif()
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/UnitTest++.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
|
||||
DESTINATION "${pkgconfdir}")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
> ### Maintenance of UnitTest++, recently sporadic, is officially on hiatus until 26 November 2020. Subscribe to https://github.com/unittest-cpp/unittest-cpp/issues/180 for updates.
|
||||
|
||||
|
||||
[](https://travis-ci.org/unittest-cpp/unittest-cpp)
|
||||
[](https://ci.appveyor.com/project/pjohnmeyer/unittest-cpp/branch/master)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix) || defined(linux) || \
|
||||
defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) \
|
||||
|| defined (__HAIKU__)
|
||||
|| defined (__HAIKU__) || defined(_AIX)
|
||||
#define UNITTEST_POSIX
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -25,16 +25,16 @@
|
|||
} \
|
||||
namespace Suite ## Name
|
||||
|
||||
#define UNITTEST_IMPL_TEST(Name, List) \
|
||||
#define UNITTEST_IMPL_TEST(Name, List) \
|
||||
class Test ## Name : public UnitTest::Test \
|
||||
{ \
|
||||
public: \
|
||||
Test ## Name() : Test(#Name, UnitTestSuite::GetSuiteName(), __FILE__, __LINE__) {} \
|
||||
private: \
|
||||
virtual void RunImpl() const; \
|
||||
} test ## Name ## Instance; \
|
||||
} static test ## Name ## Instance; \
|
||||
\
|
||||
UnitTest::ListAdder adder ## Name (List, &test ## Name ## Instance); \
|
||||
static UnitTest::ListAdder adder ## Name (List, &test ## Name ## Instance); \
|
||||
\
|
||||
void Test ## Name::RunImpl() const
|
||||
|
||||
|
|
@ -49,10 +49,12 @@
|
|||
explicit Fixture ## Name ## Helper(UnitTest::TestDetails const& details) : m_details(details) {} \
|
||||
void RunImpl(); \
|
||||
UnitTest::TestDetails const& m_details; \
|
||||
virtual ~Fixture ## Name ## Helper(); \
|
||||
private: \
|
||||
Fixture ## Name ## Helper(Fixture ## Name ## Helper const&); \
|
||||
Fixture ## Name ## Helper& operator =(Fixture ## Name ## Helper const&); \
|
||||
}; \
|
||||
Fixture ## Name ## Helper::~Fixture ## Name ## Helper(){} \
|
||||
\
|
||||
class Test ## Fixture ## Name : public UnitTest::Test \
|
||||
{ \
|
||||
|
|
@ -60,9 +62,9 @@
|
|||
Test ## Fixture ## Name() : Test(#Name, UnitTestSuite::GetSuiteName(), __FILE__, __LINE__) {} \
|
||||
private: \
|
||||
virtual void RunImpl() const; \
|
||||
} test ## Fixture ## Name ## Instance; \
|
||||
} static test ## Fixture ## Name ## Instance; \
|
||||
\
|
||||
UnitTest::ListAdder adder ## Fixture ## Name (List, &test ## Fixture ## Name ## Instance); \
|
||||
static UnitTest::ListAdder adder ## Fixture ## Name (List, &test ## Fixture ## Name ## Instance); \
|
||||
\
|
||||
void Test ## Fixture ## Name::RunImpl() const \
|
||||
{ \
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
version: 2.0.0.{build}
|
||||
version: 2.1.0.{build}
|
||||
|
||||
os:
|
||||
- Windows Server 2012 R2
|
||||
|
|
|
|||
9
autogen.sh
Executable file
9
autogen.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
test -e ./.autotools_aux || mkdir .autotools_aux
|
||||
|
||||
libtoolize -cq
|
||||
aclocal -I m4 --install # Generate aclocal
|
||||
autoconf # Generate configure script
|
||||
autoheader # Generate config.h
|
||||
automake --add-missing --copy # Generate Makefile.in and other scripts
|
||||
|
|
@ -23,7 +23,7 @@ AM_CONDITIONAL([WINDOWS],
|
|||
|
||||
LT_INIT()
|
||||
|
||||
AC_SUBST([LIBUNITTEST_SO_VERSION], [2:0:0])
|
||||
AC_SUBST([LIBUNITTEST_SO_VERSION], [2:1:0])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CXX
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ namespace {
|
|||
CHECK_EQUAL(1, results.GetFailureCount());
|
||||
}
|
||||
|
||||
#if !defined(UNITTEST_MINGW) && !defined(UNITTEST_WIN32)
|
||||
#if !defined(UNITTEST_MINGW) && !defined(UNITTEST_WIN32) && !defined(__clang__)
|
||||
// Skip this test in debug because some debuggers don't like it.
|
||||
#if defined(NDEBUG)
|
||||
TEST(CrashingTestsAreReportedAsFailures)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue