diff --git a/CMakeLists.txt b/CMakeLists.txt index a7411bc..c9ddc32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/UnitTest++/MemoryOutStream.cpp b/UnitTest++/MemoryOutStream.cpp index 98e52e6..41dd0f9 100644 --- a/UnitTest++/MemoryOutStream.cpp +++ b/UnitTest++/MemoryOutStream.cpp @@ -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 diff --git a/tests/Main.cpp b/tests/Main.cpp index 4a0f402..0c369f0 100644 --- a/tests/Main.cpp +++ b/tests/Main.cpp @@ -1,4 +1,7 @@ #include "UnitTest++/UnitTestPP.h" +#ifdef __BORLANDC__ + #include +#endif int main(int, char const *[]) { diff --git a/tests/TestCheckMacros.cpp b/tests/TestCheckMacros.cpp index f9c46c4..6d948fb 100644 --- a/tests/TestCheckMacros.cpp +++ b/tests/TestCheckMacros.cpp @@ -4,6 +4,9 @@ #include "ScopedCurrentTest.h" using namespace std; +#ifdef __BORLANDC__ +using namespace UnitTest; +#endif namespace { diff --git a/tests/TestChecks.cpp b/tests/TestChecks.cpp index 2c0ac04..04cd150 100644 --- a/tests/TestChecks.cpp +++ b/tests/TestChecks.cpp @@ -3,6 +3,11 @@ #include +#ifdef __BORLANDC__ + #include + #include +#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)); diff --git a/tests/TestCurrentTest.cpp b/tests/TestCurrentTest.cpp index 6cfb99d..ef0852a 100644 --- a/tests/TestCurrentTest.cpp +++ b/tests/TestCurrentTest.cpp @@ -2,6 +2,10 @@ #include "UnitTest++/CurrentTest.h" #include "ScopedCurrentTest.h" +#ifdef __BORLANDC__ +using namespace UnitTest; +#endif + namespace { diff --git a/tests/TestExceptions.cpp b/tests/TestExceptions.cpp index 08f6547..c7157c2 100644 --- a/tests/TestExceptions.cpp +++ b/tests/TestExceptions.cpp @@ -9,6 +9,9 @@ #include using namespace std; +#ifdef __BORLANDC__ +using namespace UnitTest; +#endif namespace { diff --git a/tests/TestLongMacros.cpp b/tests/TestLongMacros.cpp index 6720a97..89df636 100644 --- a/tests/TestLongMacros.cpp +++ b/tests/TestLongMacros.cpp @@ -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) diff --git a/tests/TestMemoryOutStream.cpp b/tests/TestMemoryOutStream.cpp index 854277e..4010c79 100644 --- a/tests/TestMemoryOutStream.cpp +++ b/tests/TestMemoryOutStream.cpp @@ -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; diff --git a/tests/TestRequireMacrosWithExceptionsOn.cpp b/tests/TestRequireMacrosWithExceptionsOn.cpp index f904708..5560956 100644 --- a/tests/TestRequireMacrosWithExceptionsOn.cpp +++ b/tests/TestRequireMacrosWithExceptionsOn.cpp @@ -4,6 +4,9 @@ #include "ScopedCurrentTest.h" using namespace std; +#ifdef __BORLANDC__ +using namespace UnitTest; +#endif #ifndef UNITTEST_NO_EXCEPTIONS diff --git a/tests/TestTestMacros.cpp b/tests/TestTestMacros.cpp index e66bfb6..54450df 100644 --- a/tests/TestTestMacros.cpp +++ b/tests/TestTestMacros.cpp @@ -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; diff --git a/tests/TestTestSuite.cpp b/tests/TestTestSuite.cpp index e0bbacf..6fd83f1 100644 --- a/tests/TestTestSuite.cpp +++ b/tests/TestTestSuite.cpp @@ -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 diff --git a/tests/TestTimeConstraintMacro.cpp b/tests/TestTimeConstraintMacro.cpp index a8d0c79..a279b8c 100644 --- a/tests/TestTimeConstraintMacro.cpp +++ b/tests/TestTimeConstraintMacro.cpp @@ -4,6 +4,10 @@ #include "RecordingReporter.h" #include "ScopedCurrentTest.h" +#ifdef __BORLANDC__ +using namespace UnitTest; +#endif + namespace { TEST(TimeConstraintMacroQualifiesNamespace) diff --git a/tests/TestUnitTestPP.cpp b/tests/TestUnitTestPP.cpp index 831b360..0908d59 100644 --- a/tests/TestUnitTestPP.cpp +++ b/tests/TestUnitTestPP.cpp @@ -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 { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy