From 2809901115a2546e3bff9b0f7d2b567693e189be Mon Sep 17 00:00:00 2001 From: Alexis Denis Date: Fri, 18 Nov 2016 16:23:24 -0600 Subject: [PATCH 1/4] Adding Borland C++ Builder 5 support. Included the project files as well as the automatically generated makefiles. The library compiles without issues. Borland requires the UnitTest namespace to be defined at the beginning of tests. Added an default to have no support for C++11. Added a Borland to the list of compilers that don't recognize "long long" but use __int64 instead. --- UnitTestcpp.bpg | 25 +++ UnitTestcppLib.bpf | 30 +++ UnitTestcppLib.bpr | 95 ++++++++++ UnitTestcppLib.mak | 197 ++++++++++++++++++++ UnitTestcppTest.bpf | 27 +++ UnitTestcppTest.bpr | 102 ++++++++++ UnitTestcppTest.mak | 196 +++++++++++++++++++ tests/Main.cpp | 3 + tests/TestCheckMacros.cpp | 1 + tests/TestCurrentTest.cpp | 2 + tests/TestExceptions.cpp | 1 + tests/TestLongMacros.cpp | 2 + tests/TestMemoryOutStream.cpp | 6 +- tests/TestRequireMacrosWithExceptionsOn.cpp | 1 + tests/TestTestMacros.cpp | 3 + tests/TestTestSuite.cpp | 2 + tests/TestTimeConstraintMacro.cpp | 2 + tests/TestUnitTestPP.cpp | 1 + 18 files changed, 693 insertions(+), 3 deletions(-) create mode 100644 UnitTestcpp.bpg create mode 100644 UnitTestcppLib.bpf create mode 100644 UnitTestcppLib.bpr create mode 100644 UnitTestcppLib.mak create mode 100644 UnitTestcppTest.bpf create mode 100644 UnitTestcppTest.bpr create mode 100644 UnitTestcppTest.mak diff --git a/UnitTestcpp.bpg b/UnitTestcpp.bpg new file mode 100644 index 0000000..a6d8edc --- /dev/null +++ b/UnitTestcpp.bpg @@ -0,0 +1,25 @@ +#------------------------------------------------------------------------------ +VERSION = BWS.01 +#------------------------------------------------------------------------------ +!ifndef ROOT +ROOT = $(MAKEDIR)\.. +!endif +#------------------------------------------------------------------------------ +MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** +DCC = $(ROOT)\bin\dcc32.exe $** +BRCC = $(ROOT)\bin\brcc32.exe $** +#------------------------------------------------------------------------------ +PROJECTS = UnitTestcppLib.lib UnitTestcppTest.exe +#------------------------------------------------------------------------------ +default: $(PROJECTS) +#------------------------------------------------------------------------------ + +UnitTestcppLib.lib: UnitTestcppLib.bpr + $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $** + $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak + +UnitTestcppTest.exe: UnitTestcppTest.bpr + $(ROOT)\bin\bpr2mak $** + $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak + + diff --git a/UnitTestcppLib.bpf b/UnitTestcppLib.bpf new file mode 100644 index 0000000..56fdd4b --- /dev/null +++ b/UnitTestcppLib.bpf @@ -0,0 +1,30 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USEUNIT("UnitTest++\AssertException.cpp"); +USEUNIT("UnitTest++\Checks.cpp"); +USEUNIT("UnitTest++\CompositeTestReporter.cpp"); +USEUNIT("UnitTest++\CurrentTest.cpp"); +USEUNIT("UnitTest++\DeferredTestReporter.cpp"); +USEUNIT("UnitTest++\DeferredTestResult.cpp"); +USEUNIT("UnitTest++\MemoryOutStream.cpp"); +USEUNIT("UnitTest++\ReportAssert.cpp"); +USEUNIT("UnitTest++\Test.cpp"); +USEUNIT("UnitTest++\TestDetails.cpp"); +USEUNIT("UnitTest++\TestList.cpp"); +USEUNIT("UnitTest++\TestReporter.cpp"); +USEUNIT("UnitTest++\TestReporterStdout.cpp"); +USEUNIT("UnitTest++\TestResults.cpp"); +USEUNIT("UnitTest++\TestRunner.cpp"); +USEUNIT("UnitTest++\TimeConstraint.cpp"); +USEUNIT("UnitTest++\XmlTestReporter.cpp"); +USEUNIT("UnitTest++\Win32\TimeHelpers.cpp"); +USEUNIT("UnitTest++\RequiredCheckException.cpp"); +USEUNIT("UnitTest++\RequiredCheckTestReporter.cpp"); +USEUNIT("UnitTest++\ThrowingTestReporter.cpp"); +//--------------------------------------------------------------------------- +#define Library + +// To add a file to the library use the Project menu 'Add to Project'. + diff --git a/UnitTestcppLib.bpr b/UnitTestcppLib.bpr new file mode 100644 index 0000000..89b0bd2 --- /dev/null +++ b/UnitTestcppLib.bpr @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/UnitTestcppLib.mak b/UnitTestcppLib.mak new file mode 100644 index 0000000..fd0739b --- /dev/null +++ b/UnitTestcppLib.mak @@ -0,0 +1,197 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.05.03 +# --------------------------------------------------------------------------- +PROJECT = UnitTestcppLib.lib +OBJFILES = UnitTest++\AssertException.obj UnitTest++\Checks.obj \ + UnitTest++\CompositeTestReporter.obj UnitTest++\CurrentTest.obj \ + UnitTest++\DeferredTestReporter.obj UnitTest++\DeferredTestResult.obj \ + UnitTest++\MemoryOutStream.obj UnitTest++\ReportAssert.obj \ + UnitTest++\Test.obj UnitTest++\TestDetails.obj UnitTest++\TestList.obj \ + UnitTest++\TestReporter.obj UnitTest++\TestReporterStdout.obj \ + UnitTest++\TestResults.obj UnitTest++\TestRunner.obj \ + UnitTest++\TimeConstraint.obj UnitTest++\XmlTestReporter.obj \ + UnitTest++\Win32\TimeHelpers.obj UnitTest++\RequiredCheckException.obj \ + UnitTest++\RequiredCheckTestReporter.obj UnitTest++\ThrowingTestReporter.obj +RESFILES = +MAINSOURCE = UnitTestcppLib.bpf +RESDEPEN = $(RESFILES) +LIBFILES = +IDLFILES = +IDLGENFILES = +LIBRARIES = +PACKAGES = +SPARELIBS = +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .;UnitTest++;UnitTest++\Win32 +PATHASM = .; +PATHPAS = .; +PATHRC = .; +LINKER = TLib +DEBUGLIBPATH = +RELEASELIBPATH = +USERDEFINES = _DEBUG +SYSDEFINES = _RTLDLL;NO_STRICT +INCLUDEPATH = UnitTest++\Win32;UnitTest++;$(BCB)\include;$(BCB)\include\vcl +LIBPATH = UnitTest++\Win32;UnitTest++;$(BCB)\lib\obj;$(BCB)\lib +WARNINGS = -w-par +LISTFILE = +# --------------------------------------------------------------------------- +CFLAG1 = -Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -c \ + -tW -tWM +IDLCFLAGS = +PFLAGS = -$YD -$W -$O- -v -JPHNE -M +RFLAGS = +AFLAGS = /mx /w2 /zd +LFLAGS = +# --------------------------------------------------------------------------- +ALLOBJ = $(OBJFILES) +ALLRES = +ALLLIB = +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +!endif + + + + + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if "$(USERDEFINES)" != "" +AUSERDEFINES = -d$(USERDEFINES:;= -d) +!else +AUSERDEFINES = +!endif + +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = TLib +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +!if "$(LISTFILE)" == "" +COMMA = +!else +COMMA = , +!endif + +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) /u $@ @&&! + $(LFLAGS) $? $(COMMA) $(LISTFILE) + +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< +# --------------------------------------------------------------------------- + + + + diff --git a/UnitTestcppTest.bpf b/UnitTestcppTest.bpf new file mode 100644 index 0000000..b5e8e06 --- /dev/null +++ b/UnitTestcppTest.bpf @@ -0,0 +1,27 @@ +USEUNIT("tests\Main.cpp"); +USELIB("UnitTestcppLib.lib"); +USEUNIT("tests\TestAssertHandler.cpp"); +USEUNIT("tests\TestCheckMacros.cpp"); +USEUNIT("tests\TestChecks.cpp"); +USEUNIT("tests\TestCompositeTestReporter.cpp"); +USEUNIT("tests\TestCurrentTest.cpp"); +USEUNIT("tests\TestDeferredTestReporter.cpp"); +USEUNIT("tests\TestExceptions.cpp"); +USEUNIT("tests\TestLongMacros.cpp"); +USEUNIT("tests\TestMemoryOutStream.cpp"); +USEUNIT("tests\TestRequireMacrosWithExceptionsOff.cpp"); +USEUNIT("tests\TestRequireMacrosWithExceptionsOn.cpp"); +USEUNIT("tests\TestTest.cpp"); +USEUNIT("tests\TestTestList.cpp"); +USEUNIT("tests\TestTestMacros.cpp"); +USEUNIT("tests\TestTestResults.cpp"); +USEUNIT("tests\TestTestRunner.cpp"); +USEUNIT("tests\TestTestSuite.cpp"); +USEUNIT("tests\TestTimeConstraint.cpp"); +USEUNIT("tests\TestTimeConstraintMacro.cpp"); +USEUNIT("tests\TestUnitTestPP.cpp"); +USEUNIT("tests\TestXmlTestReporter.cpp"); +//--------------------------------------------------------------------------- +This file is used by the project manager only and should be treated like the project file + + main \ No newline at end of file diff --git a/UnitTestcppTest.bpr b/UnitTestcppTest.bpr new file mode 100644 index 0000000..7d58bda --- /dev/null +++ b/UnitTestcppTest.bpr @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/UnitTestcppTest.mak b/UnitTestcppTest.mak new file mode 100644 index 0000000..fa613e7 --- /dev/null +++ b/UnitTestcppTest.mak @@ -0,0 +1,196 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.05.03 +# --------------------------------------------------------------------------- +PROJECT = UnitTestcppTest.exe +OBJFILES = tests\Main.obj tests\TestAssertHandler.obj tests\TestCheckMacros.obj \ + tests\TestChecks.obj tests\TestCompositeTestReporter.obj \ + tests\TestCurrentTest.obj tests\TestDeferredTestReporter.obj \ + tests\TestExceptions.obj tests\TestLongMacros.obj \ + tests\TestMemoryOutStream.obj tests\TestRequireMacrosWithExceptionsOff.obj \ + tests\TestRequireMacrosWithExceptionsOn.obj tests\TestTest.obj \ + tests\TestTestList.obj tests\TestTestMacros.obj tests\TestTestResults.obj \ + tests\TestTestRunner.obj tests\TestTestSuite.obj \ + tests\TestTimeConstraint.obj tests\TestTimeConstraintMacro.obj \ + tests\TestUnitTestPP.obj tests\TestXmlTestReporter.obj +RESFILES = +MAINSOURCE = UnitTestcppTest.bpf +RESDEPEN = $(RESFILES) +LIBFILES = UnitTestcppLib.lib +IDLFILES = +IDLGENFILES = +LIBRARIES = +PACKAGES = 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 +SPARELIBS = Vcl50.lib +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .;tests +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = _DEBUG +SYSDEFINES = NO_STRICT;_RTLDLL;USEPACKAGES +INCLUDEPATH = tests;$(BCB)\include;$(BCB)\include\vcl +LIBPATH = tests;$(BCB)\lib\obj;$(BCB)\lib +WARNINGS= -w-par +# --------------------------------------------------------------------------- +CFLAG1 = -tWC -tWM -Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v \ + -vi- -c +IDLCFLAGS = +PFLAGS = -$YD -$W -$O- -v -JPHNE -M +RFLAGS = +AFLAGS = /mx /w2 /zd +LFLAGS = -Tpe -ap -D"" -x -Gn -v +# --------------------------------------------------------------------------- +ALLOBJ = c0x32.obj $(PACKAGES) Memmgr.Lib sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +!endif + + + + + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if "$(USERDEFINES)" != "" +AUSERDEFINES = -d$(USERDEFINES:;= -d) +!else +AUSERDEFINES = +!endif + +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) -L$(LIBPATH) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< +# --------------------------------------------------------------------------- + + + + 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..ef8fc79 100644 --- a/tests/TestCheckMacros.cpp +++ b/tests/TestCheckMacros.cpp @@ -4,6 +4,7 @@ #include "ScopedCurrentTest.h" using namespace std; +using namespace UnitTest; namespace { diff --git a/tests/TestCurrentTest.cpp b/tests/TestCurrentTest.cpp index 6cfb99d..2a59f9e 100644 --- a/tests/TestCurrentTest.cpp +++ b/tests/TestCurrentTest.cpp @@ -2,6 +2,8 @@ #include "UnitTest++/CurrentTest.h" #include "ScopedCurrentTest.h" +using namespace UnitTest; + namespace { diff --git a/tests/TestExceptions.cpp b/tests/TestExceptions.cpp index 08f6547..4bfffde 100644 --- a/tests/TestExceptions.cpp +++ b/tests/TestExceptions.cpp @@ -9,6 +9,7 @@ #include using namespace std; +using namespace UnitTest; namespace { diff --git a/tests/TestLongMacros.cpp b/tests/TestLongMacros.cpp index 6720a97..507e284 100644 --- a/tests/TestLongMacros.cpp +++ b/tests/TestLongMacros.cpp @@ -2,6 +2,8 @@ #include "UnitTest++/UnitTestPP.h" +using namespace UnitTest; + // 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..8eda8a6 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; diff --git a/tests/TestRequireMacrosWithExceptionsOn.cpp b/tests/TestRequireMacrosWithExceptionsOn.cpp index f904708..0b49600 100644 --- a/tests/TestRequireMacrosWithExceptionsOn.cpp +++ b/tests/TestRequireMacrosWithExceptionsOn.cpp @@ -4,6 +4,7 @@ #include "ScopedCurrentTest.h" using namespace std; +using namespace UnitTest; #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..46f8fed 100644 --- a/tests/TestTestSuite.cpp +++ b/tests/TestTestSuite.cpp @@ -1,5 +1,7 @@ #include "UnitTest++/UnitTestPP.h" +using namespace UnitTest; + // 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..83d7124 100644 --- a/tests/TestTimeConstraintMacro.cpp +++ b/tests/TestTimeConstraintMacro.cpp @@ -4,6 +4,8 @@ #include "RecordingReporter.h" #include "ScopedCurrentTest.h" +using namespace UnitTest; + namespace { TEST(TimeConstraintMacroQualifiesNamespace) diff --git a/tests/TestUnitTestPP.cpp b/tests/TestUnitTestPP.cpp index 831b360..d06469d 100644 --- a/tests/TestUnitTestPP.cpp +++ b/tests/TestUnitTestPP.cpp @@ -2,6 +2,7 @@ #include "ScopedCurrentTest.h" // These are sample tests that show the different features of the framework +using namespace UnitTest; namespace { From 6c62f24bfdcaf411db415ede888004a7003c0968 Mon Sep 17 00:00:00 2001 From: Alexis Denis Date: Sun, 20 Nov 2016 09:58:41 -0600 Subject: [PATCH 2/4] Added conditional compiles around the "using namespace" per author recommendation. --- tests/TestCheckMacros.cpp | 2 ++ tests/TestCurrentTest.cpp | 2 ++ tests/TestExceptions.cpp | 2 ++ tests/TestLongMacros.cpp | 2 ++ tests/TestRequireMacrosWithExceptionsOn.cpp | 2 ++ tests/TestTestSuite.cpp | 2 ++ tests/TestTimeConstraintMacro.cpp | 2 ++ tests/TestUnitTestPP.cpp | 2 ++ 8 files changed, 16 insertions(+) diff --git a/tests/TestCheckMacros.cpp b/tests/TestCheckMacros.cpp index ef8fc79..6d948fb 100644 --- a/tests/TestCheckMacros.cpp +++ b/tests/TestCheckMacros.cpp @@ -4,7 +4,9 @@ #include "ScopedCurrentTest.h" using namespace std; +#ifdef __BORLANDC__ using namespace UnitTest; +#endif namespace { diff --git a/tests/TestCurrentTest.cpp b/tests/TestCurrentTest.cpp index 2a59f9e..ef0852a 100644 --- a/tests/TestCurrentTest.cpp +++ b/tests/TestCurrentTest.cpp @@ -2,7 +2,9 @@ #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 4bfffde..c7157c2 100644 --- a/tests/TestExceptions.cpp +++ b/tests/TestExceptions.cpp @@ -9,7 +9,9 @@ #include using namespace std; +#ifdef __BORLANDC__ using namespace UnitTest; +#endif namespace { diff --git a/tests/TestLongMacros.cpp b/tests/TestLongMacros.cpp index 507e284..89df636 100644 --- a/tests/TestLongMacros.cpp +++ b/tests/TestLongMacros.cpp @@ -2,7 +2,9 @@ #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. diff --git a/tests/TestRequireMacrosWithExceptionsOn.cpp b/tests/TestRequireMacrosWithExceptionsOn.cpp index 0b49600..5560956 100644 --- a/tests/TestRequireMacrosWithExceptionsOn.cpp +++ b/tests/TestRequireMacrosWithExceptionsOn.cpp @@ -4,7 +4,9 @@ #include "ScopedCurrentTest.h" using namespace std; +#ifdef __BORLANDC__ using namespace UnitTest; +#endif #ifndef UNITTEST_NO_EXCEPTIONS diff --git a/tests/TestTestSuite.cpp b/tests/TestTestSuite.cpp index 46f8fed..6fd83f1 100644 --- a/tests/TestTestSuite.cpp +++ b/tests/TestTestSuite.cpp @@ -1,6 +1,8 @@ #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) diff --git a/tests/TestTimeConstraintMacro.cpp b/tests/TestTimeConstraintMacro.cpp index 83d7124..a279b8c 100644 --- a/tests/TestTimeConstraintMacro.cpp +++ b/tests/TestTimeConstraintMacro.cpp @@ -4,7 +4,9 @@ #include "RecordingReporter.h" #include "ScopedCurrentTest.h" +#ifdef __BORLANDC__ using namespace UnitTest; +#endif namespace { diff --git a/tests/TestUnitTestPP.cpp b/tests/TestUnitTestPP.cpp index d06469d..0908d59 100644 --- a/tests/TestUnitTestPP.cpp +++ b/tests/TestUnitTestPP.cpp @@ -2,7 +2,9 @@ #include "ScopedCurrentTest.h" // These are sample tests that show the different features of the framework +#ifdef __BORLANDC__ using namespace UnitTest; +#endif namespace { From bcf039eccec5ce353c25dddd550aa95201410a5d Mon Sep 17 00:00:00 2001 From: Alexis Denis Date: Mon, 21 Nov 2016 16:24:54 -0600 Subject: [PATCH 3/4] Build clean and passes all the tests except three using CMake. cd builds cmake -G"Borland Makefiles" .. make Two of the tests fail because of unhandled floating point exceptions (throws when doing calculations using Nan). This was fixed by ignoring floating point exceptions. One test fails because std::string is not implemented properly in Borland C++ 5. This test is bypassed if using the Borland compiler. It does mean though that MemoryOutStream.Clear() doesn't work. A more permanent fix might be needed. I noticed a separate implementation of MemoryOutStream for VC6 that doesn't use std::string. Maybe we can use that one instead. --- CMakeLists.txt | 31 ++++-- UnitTestcpp.bpg | 25 ----- UnitTestcppLib.bpf | 30 ------ UnitTestcppLib.bpr | 95 ---------------- UnitTestcppLib.mak | 197 ---------------------------------- UnitTestcppTest.bpf | 27 ----- UnitTestcppTest.bpr | 102 ------------------ UnitTestcppTest.mak | 196 --------------------------------- tests/Main.cpp | 7 ++ tests/TestMemoryOutStream.cpp | 5 + 10 files changed, 34 insertions(+), 681 deletions(-) delete mode 100644 UnitTestcpp.bpg delete mode 100644 UnitTestcppLib.bpf delete mode 100644 UnitTestcppLib.bpr delete mode 100644 UnitTestcppLib.mak delete mode 100644 UnitTestcppTest.bpf delete mode 100644 UnitTestcppTest.bpr delete mode 100644 UnitTestcppTest.mak 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/UnitTestcpp.bpg b/UnitTestcpp.bpg deleted file mode 100644 index a6d8edc..0000000 --- a/UnitTestcpp.bpg +++ /dev/null @@ -1,25 +0,0 @@ -#------------------------------------------------------------------------------ -VERSION = BWS.01 -#------------------------------------------------------------------------------ -!ifndef ROOT -ROOT = $(MAKEDIR)\.. -!endif -#------------------------------------------------------------------------------ -MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** -DCC = $(ROOT)\bin\dcc32.exe $** -BRCC = $(ROOT)\bin\brcc32.exe $** -#------------------------------------------------------------------------------ -PROJECTS = UnitTestcppLib.lib UnitTestcppTest.exe -#------------------------------------------------------------------------------ -default: $(PROJECTS) -#------------------------------------------------------------------------------ - -UnitTestcppLib.lib: UnitTestcppLib.bpr - $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - -UnitTestcppTest.exe: UnitTestcppTest.bpr - $(ROOT)\bin\bpr2mak $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - - diff --git a/UnitTestcppLib.bpf b/UnitTestcppLib.bpf deleted file mode 100644 index 56fdd4b..0000000 --- a/UnitTestcppLib.bpf +++ /dev/null @@ -1,30 +0,0 @@ -//--------------------------------------------------------------------------- - -#include -#pragma hdrstop -USEUNIT("UnitTest++\AssertException.cpp"); -USEUNIT("UnitTest++\Checks.cpp"); -USEUNIT("UnitTest++\CompositeTestReporter.cpp"); -USEUNIT("UnitTest++\CurrentTest.cpp"); -USEUNIT("UnitTest++\DeferredTestReporter.cpp"); -USEUNIT("UnitTest++\DeferredTestResult.cpp"); -USEUNIT("UnitTest++\MemoryOutStream.cpp"); -USEUNIT("UnitTest++\ReportAssert.cpp"); -USEUNIT("UnitTest++\Test.cpp"); -USEUNIT("UnitTest++\TestDetails.cpp"); -USEUNIT("UnitTest++\TestList.cpp"); -USEUNIT("UnitTest++\TestReporter.cpp"); -USEUNIT("UnitTest++\TestReporterStdout.cpp"); -USEUNIT("UnitTest++\TestResults.cpp"); -USEUNIT("UnitTest++\TestRunner.cpp"); -USEUNIT("UnitTest++\TimeConstraint.cpp"); -USEUNIT("UnitTest++\XmlTestReporter.cpp"); -USEUNIT("UnitTest++\Win32\TimeHelpers.cpp"); -USEUNIT("UnitTest++\RequiredCheckException.cpp"); -USEUNIT("UnitTest++\RequiredCheckTestReporter.cpp"); -USEUNIT("UnitTest++\ThrowingTestReporter.cpp"); -//--------------------------------------------------------------------------- -#define Library - -// To add a file to the library use the Project menu 'Add to Project'. - diff --git a/UnitTestcppLib.bpr b/UnitTestcppLib.bpr deleted file mode 100644 index 89b0bd2..0000000 --- a/UnitTestcppLib.bpr +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1033 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - -[Language] -ActiveLang= -ProjectLang= -RootDir= - - \ No newline at end of file diff --git a/UnitTestcppLib.mak b/UnitTestcppLib.mak deleted file mode 100644 index fd0739b..0000000 --- a/UnitTestcppLib.mak +++ /dev/null @@ -1,197 +0,0 @@ -# --------------------------------------------------------------------------- -!if !$d(BCB) -BCB = $(MAKEDIR)\.. -!endif - -# --------------------------------------------------------------------------- -# IDE SECTION -# --------------------------------------------------------------------------- -# The following section of the project makefile is managed by the BCB IDE. -# It is recommended to use the IDE to change any of the values in this -# section. -# --------------------------------------------------------------------------- - -VERSION = BCB.05.03 -# --------------------------------------------------------------------------- -PROJECT = UnitTestcppLib.lib -OBJFILES = UnitTest++\AssertException.obj UnitTest++\Checks.obj \ - UnitTest++\CompositeTestReporter.obj UnitTest++\CurrentTest.obj \ - UnitTest++\DeferredTestReporter.obj UnitTest++\DeferredTestResult.obj \ - UnitTest++\MemoryOutStream.obj UnitTest++\ReportAssert.obj \ - UnitTest++\Test.obj UnitTest++\TestDetails.obj UnitTest++\TestList.obj \ - UnitTest++\TestReporter.obj UnitTest++\TestReporterStdout.obj \ - UnitTest++\TestResults.obj UnitTest++\TestRunner.obj \ - UnitTest++\TimeConstraint.obj UnitTest++\XmlTestReporter.obj \ - UnitTest++\Win32\TimeHelpers.obj UnitTest++\RequiredCheckException.obj \ - UnitTest++\RequiredCheckTestReporter.obj UnitTest++\ThrowingTestReporter.obj -RESFILES = -MAINSOURCE = UnitTestcppLib.bpf -RESDEPEN = $(RESFILES) -LIBFILES = -IDLFILES = -IDLGENFILES = -LIBRARIES = -PACKAGES = -SPARELIBS = -DEFFILE = -# --------------------------------------------------------------------------- -PATHCPP = .;UnitTest++;UnitTest++\Win32 -PATHASM = .; -PATHPAS = .; -PATHRC = .; -LINKER = TLib -DEBUGLIBPATH = -RELEASELIBPATH = -USERDEFINES = _DEBUG -SYSDEFINES = _RTLDLL;NO_STRICT -INCLUDEPATH = UnitTest++\Win32;UnitTest++;$(BCB)\include;$(BCB)\include\vcl -LIBPATH = UnitTest++\Win32;UnitTest++;$(BCB)\lib\obj;$(BCB)\lib -WARNINGS = -w-par -LISTFILE = -# --------------------------------------------------------------------------- -CFLAG1 = -Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -c \ - -tW -tWM -IDLCFLAGS = -PFLAGS = -$YD -$W -$O- -v -JPHNE -M -RFLAGS = -AFLAGS = /mx /w2 /zd -LFLAGS = -# --------------------------------------------------------------------------- -ALLOBJ = $(OBJFILES) -ALLRES = -ALLLIB = -# --------------------------------------------------------------------------- -!ifdef IDEOPTIONS - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -!endif - - - - - -# --------------------------------------------------------------------------- -# MAKE SECTION -# --------------------------------------------------------------------------- -# This section of the project file is not used by the BCB IDE. It is for -# the benefit of building from the command-line using the MAKE utility. -# --------------------------------------------------------------------------- - -.autodepend -# --------------------------------------------------------------------------- -!if "$(USERDEFINES)" != "" -AUSERDEFINES = -d$(USERDEFINES:;= -d) -!else -AUSERDEFINES = -!endif - -!if !$d(BCC32) -BCC32 = bcc32 -!endif - -!if !$d(CPP32) -CPP32 = cpp32 -!endif - -!if !$d(DCC32) -DCC32 = dcc32 -!endif - -!if !$d(TASM32) -TASM32 = tasm32 -!endif - -!if !$d(LINKER) -LINKER = TLib -!endif - -!if !$d(BRCC32) -BRCC32 = brcc32 -!endif - - -# --------------------------------------------------------------------------- -!if $d(PATHCPP) -.PATH.CPP = $(PATHCPP) -.PATH.C = $(PATHCPP) -!endif - -!if $d(PATHPAS) -.PATH.PAS = $(PATHPAS) -!endif - -!if $d(PATHASM) -.PATH.ASM = $(PATHASM) -!endif - -!if $d(PATHRC) -.PATH.RC = $(PATHRC) -!endif -# --------------------------------------------------------------------------- -!if "$(LISTFILE)" == "" -COMMA = -!else -COMMA = , -!endif - -$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) - $(BCB)\BIN\$(LINKER) /u $@ @&&! - $(LFLAGS) $? $(COMMA) $(LISTFILE) - -! -# --------------------------------------------------------------------------- -.pas.hpp: - $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } - -.pas.obj: - $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } - -.cpp.obj: - $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } - -.c.obj: - $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } - -.c.i: - $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } - -.cpp.i: - $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } - -.asm.obj: - $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ - -.rc.res: - $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< -# --------------------------------------------------------------------------- - - - - diff --git a/UnitTestcppTest.bpf b/UnitTestcppTest.bpf deleted file mode 100644 index b5e8e06..0000000 --- a/UnitTestcppTest.bpf +++ /dev/null @@ -1,27 +0,0 @@ -USEUNIT("tests\Main.cpp"); -USELIB("UnitTestcppLib.lib"); -USEUNIT("tests\TestAssertHandler.cpp"); -USEUNIT("tests\TestCheckMacros.cpp"); -USEUNIT("tests\TestChecks.cpp"); -USEUNIT("tests\TestCompositeTestReporter.cpp"); -USEUNIT("tests\TestCurrentTest.cpp"); -USEUNIT("tests\TestDeferredTestReporter.cpp"); -USEUNIT("tests\TestExceptions.cpp"); -USEUNIT("tests\TestLongMacros.cpp"); -USEUNIT("tests\TestMemoryOutStream.cpp"); -USEUNIT("tests\TestRequireMacrosWithExceptionsOff.cpp"); -USEUNIT("tests\TestRequireMacrosWithExceptionsOn.cpp"); -USEUNIT("tests\TestTest.cpp"); -USEUNIT("tests\TestTestList.cpp"); -USEUNIT("tests\TestTestMacros.cpp"); -USEUNIT("tests\TestTestResults.cpp"); -USEUNIT("tests\TestTestRunner.cpp"); -USEUNIT("tests\TestTestSuite.cpp"); -USEUNIT("tests\TestTimeConstraint.cpp"); -USEUNIT("tests\TestTimeConstraintMacro.cpp"); -USEUNIT("tests\TestUnitTestPP.cpp"); -USEUNIT("tests\TestXmlTestReporter.cpp"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - main \ No newline at end of file diff --git a/UnitTestcppTest.bpr b/UnitTestcppTest.bpr deleted file mode 100644 index 7d58bda..0000000 --- a/UnitTestcppTest.bpr +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1033 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - -[Language] -ActiveLang= -ProjectLang= -RootDir= - - \ No newline at end of file diff --git a/UnitTestcppTest.mak b/UnitTestcppTest.mak deleted file mode 100644 index fa613e7..0000000 --- a/UnitTestcppTest.mak +++ /dev/null @@ -1,196 +0,0 @@ -# --------------------------------------------------------------------------- -!if !$d(BCB) -BCB = $(MAKEDIR)\.. -!endif - -# --------------------------------------------------------------------------- -# IDE SECTION -# --------------------------------------------------------------------------- -# The following section of the project makefile is managed by the BCB IDE. -# It is recommended to use the IDE to change any of the values in this -# section. -# --------------------------------------------------------------------------- - -VERSION = BCB.05.03 -# --------------------------------------------------------------------------- -PROJECT = UnitTestcppTest.exe -OBJFILES = tests\Main.obj tests\TestAssertHandler.obj tests\TestCheckMacros.obj \ - tests\TestChecks.obj tests\TestCompositeTestReporter.obj \ - tests\TestCurrentTest.obj tests\TestDeferredTestReporter.obj \ - tests\TestExceptions.obj tests\TestLongMacros.obj \ - tests\TestMemoryOutStream.obj tests\TestRequireMacrosWithExceptionsOff.obj \ - tests\TestRequireMacrosWithExceptionsOn.obj tests\TestTest.obj \ - tests\TestTestList.obj tests\TestTestMacros.obj tests\TestTestResults.obj \ - tests\TestTestRunner.obj tests\TestTestSuite.obj \ - tests\TestTimeConstraint.obj tests\TestTimeConstraintMacro.obj \ - tests\TestUnitTestPP.obj tests\TestXmlTestReporter.obj -RESFILES = -MAINSOURCE = UnitTestcppTest.bpf -RESDEPEN = $(RESFILES) -LIBFILES = UnitTestcppLib.lib -IDLFILES = -IDLGENFILES = -LIBRARIES = -PACKAGES = 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 -SPARELIBS = Vcl50.lib -DEFFILE = -# --------------------------------------------------------------------------- -PATHCPP = .;tests -PATHASM = .; -PATHPAS = .; -PATHRC = .; -DEBUGLIBPATH = $(BCB)\lib\debug -RELEASELIBPATH = $(BCB)\lib\release -USERDEFINES = _DEBUG -SYSDEFINES = NO_STRICT;_RTLDLL;USEPACKAGES -INCLUDEPATH = tests;$(BCB)\include;$(BCB)\include\vcl -LIBPATH = tests;$(BCB)\lib\obj;$(BCB)\lib -WARNINGS= -w-par -# --------------------------------------------------------------------------- -CFLAG1 = -tWC -tWM -Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v \ - -vi- -c -IDLCFLAGS = -PFLAGS = -$YD -$W -$O- -v -JPHNE -M -RFLAGS = -AFLAGS = /mx /w2 /zd -LFLAGS = -Tpe -ap -D"" -x -Gn -v -# --------------------------------------------------------------------------- -ALLOBJ = c0x32.obj $(PACKAGES) Memmgr.Lib sysinit.obj $(OBJFILES) -ALLRES = $(RESFILES) -ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib -# --------------------------------------------------------------------------- -!ifdef IDEOPTIONS - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -!endif - - - - - -# --------------------------------------------------------------------------- -# MAKE SECTION -# --------------------------------------------------------------------------- -# This section of the project file is not used by the BCB IDE. It is for -# the benefit of building from the command-line using the MAKE utility. -# --------------------------------------------------------------------------- - -.autodepend -# --------------------------------------------------------------------------- -!if "$(USERDEFINES)" != "" -AUSERDEFINES = -d$(USERDEFINES:;= -d) -!else -AUSERDEFINES = -!endif - -!if !$d(BCC32) -BCC32 = bcc32 -!endif - -!if !$d(CPP32) -CPP32 = cpp32 -!endif - -!if !$d(DCC32) -DCC32 = dcc32 -!endif - -!if !$d(TASM32) -TASM32 = tasm32 -!endif - -!if !$d(LINKER) -LINKER = ilink32 -!endif - -!if !$d(BRCC32) -BRCC32 = brcc32 -!endif - - -# --------------------------------------------------------------------------- -!if $d(PATHCPP) -.PATH.CPP = $(PATHCPP) -.PATH.C = $(PATHCPP) -!endif - -!if $d(PATHPAS) -.PATH.PAS = $(PATHPAS) -!endif - -!if $d(PATHASM) -.PATH.ASM = $(PATHASM) -!endif - -!if $d(PATHRC) -.PATH.RC = $(PATHRC) -!endif -# --------------------------------------------------------------------------- -$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) - $(BCB)\BIN\$(LINKER) @&&! - $(LFLAGS) -L$(LIBPATH) + - $(ALLOBJ), + - $(PROJECT),, + - $(ALLLIB), + - $(DEFFILE), + - $(ALLRES) -! -# --------------------------------------------------------------------------- -.pas.hpp: - $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } - -.pas.obj: - $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } - -.cpp.obj: - $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } - -.c.obj: - $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } - -.c.i: - $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } - -.cpp.i: - $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } - -.asm.obj: - $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ - -.rc.res: - $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< -# --------------------------------------------------------------------------- - - - - diff --git a/tests/Main.cpp b/tests/Main.cpp index 0c369f0..ce9749a 100644 --- a/tests/Main.cpp +++ b/tests/Main.cpp @@ -1,9 +1,16 @@ #include "UnitTest++/UnitTestPP.h" #ifdef __BORLANDC__ #include + #include + #include #endif int main(int, char const *[]) { +#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 return UnitTest::RunAllTests(); } diff --git a/tests/TestMemoryOutStream.cpp b/tests/TestMemoryOutStream.cpp index 8eda8a6..a4bd958 100644 --- a/tests/TestMemoryOutStream.cpp +++ b/tests/TestMemoryOutStream.cpp @@ -257,6 +257,10 @@ namespace { CHECK_EQUAL("53124", stream.GetText()); } +#ifndef __BORLANDC__ + // 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; @@ -264,6 +268,7 @@ namespace { stream.Clear(); CHECK_EQUAL("", stream.GetText()); } +#endif #ifndef UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM From c5aa621e6447f7f37d00a1a085779b4f44877291 Mon Sep 17 00:00:00 2001 From: Alexis Denis Date: Tue, 22 Nov 2016 13:16:33 -0600 Subject: [PATCH 4/4] Catching and resolving the exception thrown when accessing an empty string from an ostrstream (MemoryOutStream GetString would throw if the stream was empty). Moving the exception disable to the test file instead of the main file so the workaround is located where it is needed. All tests pass!!! --- UnitTest++/MemoryOutStream.cpp | 9 +++++++-- tests/Main.cpp | 7 ------- tests/TestChecks.cpp | 10 ++++++++++ tests/TestMemoryOutStream.cpp | 2 -- 4 files changed, 17 insertions(+), 11 deletions(-) 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 ce9749a..0c369f0 100644 --- a/tests/Main.cpp +++ b/tests/Main.cpp @@ -1,16 +1,9 @@ #include "UnitTest++/UnitTestPP.h" #ifdef __BORLANDC__ #include - #include - #include #endif int main(int, char const *[]) { -#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 return UnitTest::RunAllTests(); } 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/TestMemoryOutStream.cpp b/tests/TestMemoryOutStream.cpp index a4bd958..4010c79 100644 --- a/tests/TestMemoryOutStream.cpp +++ b/tests/TestMemoryOutStream.cpp @@ -257,7 +257,6 @@ namespace { CHECK_EQUAL("53124", stream.GetText()); } -#ifndef __BORLANDC__ // 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&) @@ -268,7 +267,6 @@ namespace { stream.Clear(); CHECK_EQUAL("", stream.GetText()); } -#endif #ifndef UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM