mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-27 00:28:49 +03:00
Merge c5aa621e64 into c331bb0dea
This commit is contained in:
commit
ac97493c8d
14 changed files with 79 additions and 14 deletions
|
|
@ -10,7 +10,12 @@ option(UTPP_INCLUDE_TESTS_IN_BUILD
|
|||
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(BORLAND)
|
||||
set(UTPP_USE_PLUS_SIGN OFF)
|
||||
string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " cp32mti.lib Vcl50.bpi Vclx50.bpi bcbsmp50.bpi Qrpt50.bpi Vcldb50.bpi Vclbde50.bpi ibsmp50.bpi vcldbx50.bpi TeeUI50.bpi TeeDB50.bpi Tee50.bpi TeeQR50.bpi VCLIB50.bpi bcbie50.bpi vclie50.bpi Inetdb50.bpi Inet50.bpi NMFast50.bpi dclocx50.bpi bcb2kaxserver50.bpi Memmgr.Lib ")
|
||||
endif()
|
||||
|
||||
if(MSVC14 OR MSVC12)
|
||||
# has the support we need
|
||||
else()
|
||||
|
|
@ -32,6 +37,8 @@ if (${UTPP_AMPLIFY_WARNINGS})
|
|||
# we are dealing with an MSVC or MSVC-like compiler (e.g. Intel on Windows)
|
||||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
|
||||
elseif(BORLAND)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w-par")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
|
||||
endif()
|
||||
|
|
@ -59,28 +66,34 @@ add_library(UnitTest++ STATIC ${headers_} ${sources_} ${platformHeaders_} ${plat
|
|||
|
||||
if(${UTPP_USE_PLUS_SIGN})
|
||||
set_target_properties(UnitTest++ PROPERTIES OUTPUT_NAME UnitTest++)
|
||||
else()
|
||||
set_target_properties(UnitTest++ PROPERTIES OUTPUT_NAME UnitTestpp)
|
||||
endif()
|
||||
|
||||
|
||||
if(${UTPP_USE_PLUS_SIGN})
|
||||
set(UTPP_TEST_NAME TestUnitTest++)
|
||||
else()
|
||||
set(UTPP_TEST_NAME TestUnitTestPP)
|
||||
endif()
|
||||
|
||||
# build the test runner
|
||||
file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h)
|
||||
source_group( "" FILES ${TEST_SRCS})
|
||||
add_executable(TestUnitTest++ ${TEST_SRCS})
|
||||
add_executable(${UTPP_TEST_NAME} ${TEST_SRCS})
|
||||
include_directories(.)
|
||||
|
||||
if(${UTPP_USE_PLUS_SIGN})
|
||||
set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++)
|
||||
endif()
|
||||
set_target_properties(${UTPP_TEST_NAME} PROPERTIES OUTPUT_NAME ${UTPP_TEST_NAME})
|
||||
|
||||
target_link_libraries(TestUnitTest++ UnitTest++)
|
||||
target_link_libraries(${UTPP_TEST_NAME} UnitTest++)
|
||||
|
||||
# run unit tests as post build step
|
||||
add_custom_command(TARGET TestUnitTest++
|
||||
POST_BUILD COMMAND TestUnitTest++
|
||||
add_custom_command(TARGET ${UTPP_TEST_NAME}
|
||||
POST_BUILD COMMAND ${UTPP_TEST_NAME}
|
||||
COMMENT "Running unit tests")
|
||||
|
||||
if(NOT ${UTPP_INCLUDE_TESTS_IN_BUILD})
|
||||
set_target_properties(TestUnitTest++ PROPERTIES EXCLUDE_FROM_ALL 1)
|
||||
set_target_properties(${UTPP_TEST_NAME} PROPERTIES EXCLUDE_FROM_ALL 1)
|
||||
endif()
|
||||
|
||||
# add install targets
|
||||
|
|
|
|||
|
|
@ -6,14 +6,19 @@ namespace UnitTest {
|
|||
|
||||
char const* MemoryOutStream::GetText() const
|
||||
{
|
||||
m_text = this->str();
|
||||
try
|
||||
{
|
||||
m_text = this->str();
|
||||
}
|
||||
catch (...) { m_text = ""; }
|
||||
|
||||
return m_text.c_str();
|
||||
}
|
||||
|
||||
void MemoryOutStream::Clear()
|
||||
{
|
||||
this->str(std::string());
|
||||
m_text = this->str();
|
||||
m_text = std::string();
|
||||
}
|
||||
|
||||
#ifdef UNITTEST_COMPILER_IS_MSVC6
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
#include "UnitTest++/UnitTestPP.h"
|
||||
#ifdef __BORLANDC__
|
||||
#include <vcl.h>
|
||||
#endif
|
||||
|
||||
int main(int, char const *[])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include "ScopedCurrentTest.h"
|
||||
|
||||
using namespace std;
|
||||
#ifdef __BORLANDC__
|
||||
using namespace UnitTest;
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@
|
|||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#endif
|
||||
|
||||
using namespace UnitTest;
|
||||
|
||||
|
||||
|
|
@ -148,6 +153,11 @@ namespace {
|
|||
|
||||
TEST(CheckCloseWithNaNFails)
|
||||
{
|
||||
#ifdef __BORLANDC__
|
||||
// This is to allow the check test to pass when using Nan (invalid float numbers), otherwise, they throw an exception
|
||||
// and the test fails (CheckCloseWithNaNFails and CheckCloseWithNaNAgainstItselfFails)
|
||||
_control87(MCW_EM, MCW_EM);
|
||||
#endif
|
||||
const unsigned int bitpattern = 0xFFFFFFFF;
|
||||
float nan;
|
||||
UNIITEST_NS_QUAL_STD(memcpy)(&nan, &bitpattern, sizeof(bitpattern));
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
#include "UnitTest++/CurrentTest.h"
|
||||
#include "ScopedCurrentTest.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
using namespace UnitTest;
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@
|
|||
#include <stdexcept>
|
||||
|
||||
using namespace std;
|
||||
#ifdef __BORLANDC__
|
||||
using namespace UnitTest;
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
#include "UnitTest++/UnitTestPP.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
using namespace UnitTest;
|
||||
#endif
|
||||
|
||||
// This file is not intended to test every little thing, just a few basics to hopefully ensure
|
||||
// the macros are working and the short macros are not defined.
|
||||
UNITTEST_SUITE(LongMacros)
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ namespace {
|
|||
TEST(StreamingLongLongWritesCorrectCharacters)
|
||||
{
|
||||
MemoryOutStream stream;
|
||||
#ifdef UNITTEST_COMPILER_IS_MSVC6
|
||||
#if defined(UNITTEST_COMPILER_IS_MSVC6) || defined(__BORLANDC__)
|
||||
stream << (__int64)-12345i64;
|
||||
#else
|
||||
stream << (long long)-12345ll;
|
||||
|
|
@ -199,7 +199,7 @@ namespace {
|
|||
TEST(StreamingUnsignedLongLongWritesCorrectCharacters)
|
||||
{
|
||||
MemoryOutStream stream;
|
||||
#ifdef UNITTEST_COMPILER_IS_MSVC6
|
||||
#if defined(UNITTEST_COMPILER_IS_MSVC6) || defined(__BORLANDC__)
|
||||
stream << (unsigned __int64)85899ui64;
|
||||
#else
|
||||
stream << (unsigned long long)85899ull;
|
||||
|
|
@ -219,7 +219,7 @@ namespace {
|
|||
TEST(StreamingMinUnsignedLongLongWritesCorrectCharacters)
|
||||
{
|
||||
MemoryOutStream stream;
|
||||
#ifdef UNITTEST_COMPILER_IS_MSVC6
|
||||
#if defined(UNITTEST_COMPILER_IS_MSVC6) || defined(__BORLANDC__)
|
||||
stream << (unsigned __int64)0ui64;
|
||||
#else
|
||||
stream << (unsigned long long)0ull;
|
||||
|
|
@ -257,6 +257,9 @@ namespace {
|
|||
CHECK_EQUAL("53124", stream.GetText());
|
||||
}
|
||||
|
||||
// Not sure why but this test fails with the Borland C++ 5.5 compiler.
|
||||
// It throws an unhandled exception:
|
||||
// unexpected NULL pointer in function: basic_string( const charT*,size_type,const Allocator&)
|
||||
TEST(ClearEmptiesMemoryOutStreamContents)
|
||||
{
|
||||
MemoryOutStream stream;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include "ScopedCurrentTest.h"
|
||||
|
||||
using namespace std;
|
||||
#ifdef __BORLANDC__
|
||||
using namespace UnitTest;
|
||||
#endif
|
||||
|
||||
#ifndef UNITTEST_NO_EXCEPTIONS
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ using namespace std;
|
|||
#else
|
||||
#define _NOEXCEPT_OP(x)
|
||||
#endif
|
||||
#else
|
||||
#define _NOEXCEPT_OP(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -43,6 +45,7 @@ using namespace std;
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
TestList list1;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
#include "UnitTest++/UnitTestPP.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
using namespace UnitTest;
|
||||
#endif
|
||||
|
||||
// We're really testing if it's possible to use the same suite in two files
|
||||
// to compile and link successfuly (TestTestSuite.cpp has suite with the same name)
|
||||
// Note: we are outside of the anonymous namespace
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
#include "RecordingReporter.h"
|
||||
#include "ScopedCurrentTest.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
using namespace UnitTest;
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(TimeConstraintMacroQualifiesNamespace)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
#include "ScopedCurrentTest.h"
|
||||
|
||||
// These are sample tests that show the different features of the framework
|
||||
#ifdef __BORLANDC__
|
||||
using namespace UnitTest;
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue