diff --git a/Makefile.am b/Makefile.am
index c83fb70b..b030cd83 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -51,6 +51,15 @@ EXTRA_DIST += \
xcode/Samples/FrameworkSample/widget.h \
xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj
+# C++Builder project files
+EXTRA_DIST += \
+ codegear/gtest_all.cc \
+ codegear/gtest_link.cc \
+ codegear/gtest.cbproj \
+ codegear/gtest_main.cbproj \
+ codegear/gtest_unittest.cbproj \
+ codegear/gtest.groupproj
+
# TODO(wan@google.com): integrate scripts/gen_gtest_pred_impl.py into
# the build system such that a user can specify the maximum predicate
# arity here and have the script automatically generate the
diff --git a/codegear/gtest.cbproj b/codegear/gtest.cbproj
new file mode 100644
index 00000000..95c3054b
--- /dev/null
+++ b/codegear/gtest.cbproj
@@ -0,0 +1,138 @@
+
+
+
+ {bca37a72-5b07-46cf-b44e-89f8e06451a2}
+ Release
+
+
+ true
+
+
+ true
+ true
+ Base
+
+
+ true
+ true
+ Base
+
+
+ true
+ lib
+ JPHNE
+ NO_STRICT
+ true
+ true
+ CppStaticLibrary
+ true
+ rtl.bpi;vcl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;bdertl.bpi;vcldbx.bpi;dsnap.bpi;dsnapcon.bpi;vclib.bpi;ibxpress.bpi;adortl.bpi;dbxcds.bpi;dbexpress.bpi;DbxCommonDriver.bpi;websnap.bpi;vclie.bpi;webdsnap.bpi;inet.bpi;inetdbbde.bpi;inetdbxpress.bpi;soaprtl.bpi;Rave75VCL.bpi;teeUI.bpi;tee.bpi;teedb.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;IntrawebDB_90_100.bpi;Intraweb_90_100.bpi;dclZipForged11.bpi;vclZipForged11.bpi;GR32_BDS2006.bpi;GR32_DSGN_BDS2006.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD11R.bpi;JvSystemD11R.bpi;JvStdCtrlsD11R.bpi;JvAppFrmD11R.bpi;JvBandsD11R.bpi;JvDBD11R.bpi;JvDlgsD11R.bpi;JvBDED11R.bpi;JvCmpD11R.bpi;JvCryptD11R.bpi;JvCtrlsD11R.bpi;JvCustomD11R.bpi;JvDockingD11R.bpi;JvDotNetCtrlsD11R.bpi;JvEDID11R.bpi;JvGlobusD11R.bpi;JvHMID11R.bpi;JvInterpreterD11R.bpi;JvJansD11R.bpi;JvManagedThreadsD11R.bpi;JvMMD11R.bpi;JvNetD11R.bpi;JvPageCompsD11R.bpi;JvPluginD11R.bpi;JvPrintPreviewD11R.bpi;JvRuntimeDesignD11R.bpi;JvTimeFrameworkD11R.bpi;JvValidatorsD11R.bpi;JvWizardD11R.bpi;JvXPCtrlsD11R.bpi;VclSmp.bpi;CExceptionExpert11.bpi
+ false
+ $(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\src;..\include;..
+ rtl.lib;vcl.lib
+ 32
+ $(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk
+
+
+ false
+ false
+ true
+ _DEBUG;$(Defines)
+ true
+ false
+ true
+ None
+ DEBUG
+ true
+ Debug
+ true
+ true
+ true
+ $(BDS)\lib\debug;$(ILINK_LibraryPath)
+ Full
+ true
+
+
+ NDEBUG;$(Defines)
+ Release
+ $(BDS)\lib\release;$(ILINK_LibraryPath)
+ None
+
+
+ CPlusPlusBuilder.Personality
+ CppStaticLibrary
+
+FalseFalse1000FalseFalseFalseFalseFalse103312521.0.0.01.0.0.0FalseFalseFalseTrueFalse
+
+
+ CodeGear C++Builder Office 2000 Servers Package
+ CodeGear C++Builder Office XP Servers Package
+ FalseTrueTrue3$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\src;..\include;..$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\src;..\include;..$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\src;..\src;..\include1$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk1NO_STRICT13216
+
+
+
+
+ 3
+
+
+ 4
+
+
+ 5
+
+
+ 6
+
+
+ 7
+
+
+ 8
+
+
+ 0
+
+
+ 1
+
+
+ 2
+
+
+ 9
+
+
+ 10
+
+
+ 11
+
+
+ 12
+
+
+ 14
+
+
+ 13
+
+
+ 15
+
+
+ 16
+
+
+ 17
+
+
+ 18
+
+
+ Cfg_1
+
+
+ Cfg_2
+
+
+
\ No newline at end of file
diff --git a/codegear/gtest.groupproj b/codegear/gtest.groupproj
new file mode 100644
index 00000000..8b650f85
--- /dev/null
+++ b/codegear/gtest.groupproj
@@ -0,0 +1,54 @@
+
+
+ {c1d923e0-6cba-4332-9b6f-3420acbf5091}
+
+
+
+
+
+
+
+
+ Default.Personality
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/codegear/gtest_all.cc b/codegear/gtest_all.cc
new file mode 100644
index 00000000..121b2d80
--- /dev/null
+++ b/codegear/gtest_all.cc
@@ -0,0 +1,38 @@
+// Copyright 2009, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Josh Kelley (joshkel@gmail.com)
+//
+// Google C++ Testing Framework (Google Test)
+//
+// C++Builder's IDE cannot build a static library from files with hyphens
+// in their name. See http://qc.codegear.com/wc/qcmain.aspx?d=70977 .
+// This file serves as a workaround.
+
+#include "src/gtest-all.cc"
diff --git a/codegear/gtest_link.cc b/codegear/gtest_link.cc
new file mode 100644
index 00000000..918eccd1
--- /dev/null
+++ b/codegear/gtest_link.cc
@@ -0,0 +1,40 @@
+// Copyright 2009, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Josh Kelley (joshkel@gmail.com)
+//
+// Google C++ Testing Framework (Google Test)
+//
+// Links gtest.lib and gtest_main.lib into the current project in C++Builder.
+// This means that these libraries can't be renamed, but it's the only way to
+// ensure that Debug versus Release test builds are linked against the
+// appropriate Debug or Release build of the libraries.
+
+#pragma link "gtest.lib"
+#pragma link "gtest_main.lib"
diff --git a/codegear/gtest_main.cbproj b/codegear/gtest_main.cbproj
new file mode 100644
index 00000000..d76ce139
--- /dev/null
+++ b/codegear/gtest_main.cbproj
@@ -0,0 +1,82 @@
+
+
+
+ {bca37a72-5b07-46cf-b44e-89f8e06451a2}
+ Release
+
+
+ true
+
+
+ true
+ true
+ Base
+
+
+ true
+ true
+ Base
+
+
+ true
+ lib
+ JPHNE
+ NO_STRICT
+ true
+ true
+ CppStaticLibrary
+ true
+ rtl.bpi;vcl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;bdertl.bpi;vcldbx.bpi;dsnap.bpi;dsnapcon.bpi;vclib.bpi;ibxpress.bpi;adortl.bpi;dbxcds.bpi;dbexpress.bpi;DbxCommonDriver.bpi;websnap.bpi;vclie.bpi;webdsnap.bpi;inet.bpi;inetdbbde.bpi;inetdbxpress.bpi;soaprtl.bpi;Rave75VCL.bpi;teeUI.bpi;tee.bpi;teedb.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;IntrawebDB_90_100.bpi;Intraweb_90_100.bpi;dclZipForged11.bpi;vclZipForged11.bpi;GR32_BDS2006.bpi;GR32_DSGN_BDS2006.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD11R.bpi;JvSystemD11R.bpi;JvStdCtrlsD11R.bpi;JvAppFrmD11R.bpi;JvBandsD11R.bpi;JvDBD11R.bpi;JvDlgsD11R.bpi;JvBDED11R.bpi;JvCmpD11R.bpi;JvCryptD11R.bpi;JvCtrlsD11R.bpi;JvCustomD11R.bpi;JvDockingD11R.bpi;JvDotNetCtrlsD11R.bpi;JvEDID11R.bpi;JvGlobusD11R.bpi;JvHMID11R.bpi;JvInterpreterD11R.bpi;JvJansD11R.bpi;JvManagedThreadsD11R.bpi;JvMMD11R.bpi;JvNetD11R.bpi;JvPageCompsD11R.bpi;JvPluginD11R.bpi;JvPrintPreviewD11R.bpi;JvRuntimeDesignD11R.bpi;JvTimeFrameworkD11R.bpi;JvValidatorsD11R.bpi;JvWizardD11R.bpi;JvXPCtrlsD11R.bpi;VclSmp.bpi;CExceptionExpert11.bpi
+ false
+ $(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\src;..\include;..
+ rtl.lib;vcl.lib
+ 32
+ $(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk
+
+
+ false
+ false
+ true
+ _DEBUG;$(Defines)
+ true
+ false
+ true
+ None
+ DEBUG
+ true
+ Debug
+ true
+ true
+ true
+ $(BDS)\lib\debug;$(ILINK_LibraryPath)
+ Full
+ true
+
+
+ NDEBUG;$(Defines)
+ Release
+ $(BDS)\lib\release;$(ILINK_LibraryPath)
+ None
+
+
+ CPlusPlusBuilder.Personality
+ CppStaticLibrary
+
+FalseFalse1000FalseFalseFalseFalseFalse103312521.0.0.01.0.0.0FalseFalseFalseTrueFalse
+ CodeGear C++Builder Office 2000 Servers Package
+ CodeGear C++Builder Office XP Servers Package
+ FalseTrueTrue3$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\src;..\include;..$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\src;..\include;..$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\src;..\src;..\include1$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk1NO_STRICT13216
+
+
+
+
+ 0
+
+
+ Cfg_1
+
+
+ Cfg_2
+
+
+
diff --git a/codegear/gtest_unittest.cbproj b/codegear/gtest_unittest.cbproj
new file mode 100644
index 00000000..d3823c90
--- /dev/null
+++ b/codegear/gtest_unittest.cbproj
@@ -0,0 +1,88 @@
+
+
+
+ {eea63393-5ac5-4b9c-8909-d75fef2daa41}
+ Release
+
+
+ true
+
+
+ true
+ true
+ Base
+
+
+ true
+ true
+ Base
+
+
+ true
+ exe
+ JPHNE
+ NO_STRICT
+ true
+ true
+ ..\test
+ true
+ CppConsoleApplication
+ true
+ rtl.bpi;vcl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;bdertl.bpi;vcldbx.bpi;dsnap.bpi;dsnapcon.bpi;vclib.bpi;ibxpress.bpi;adortl.bpi;dbxcds.bpi;dbexpress.bpi;DbxCommonDriver.bpi;websnap.bpi;vclie.bpi;webdsnap.bpi;inet.bpi;inetdbbde.bpi;inetdbxpress.bpi;soaprtl.bpi;Rave75VCL.bpi;teeUI.bpi;tee.bpi;teedb.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;IntrawebDB_90_100.bpi;Intraweb_90_100.bpi;dclZipForged11.bpi;vclZipForged11.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD11R.bpi;JvSystemD11R.bpi;JvStdCtrlsD11R.bpi;JvAppFrmD11R.bpi;JvBandsD11R.bpi;JvDBD11R.bpi;JvDlgsD11R.bpi;JvBDED11R.bpi;JvCmpD11R.bpi;JvCryptD11R.bpi;JvCtrlsD11R.bpi;JvCustomD11R.bpi;JvDockingD11R.bpi;JvDotNetCtrlsD11R.bpi;JvEDID11R.bpi;JvGlobusD11R.bpi;JvHMID11R.bpi;JvInterpreterD11R.bpi;JvJansD11R.bpi;JvManagedThreadsD11R.bpi;JvMMD11R.bpi;JvNetD11R.bpi;JvPageCompsD11R.bpi;JvPluginD11R.bpi;JvPrintPreviewD11R.bpi;JvRuntimeDesignD11R.bpi;JvTimeFrameworkD11R.bpi;JvValidatorsD11R.bpi;JvWizardD11R.bpi;JvXPCtrlsD11R.bpi;VclSmp.bpi
+ false
+ $(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\include;..\test;..
+ $(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;..\test
+ true
+
+
+ false
+ false
+ _DEBUG;$(Defines)
+ true
+ true
+ false
+ true
+ None
+ DEBUG
+ true
+ Debug
+ true
+ true
+ $(BDS)\lib\debug;$(ILINK_LibraryPath)
+ true
+ Full
+ true
+
+
+ NDEBUG;$(Defines)
+ Release
+ $(BDS)\lib\release;$(ILINK_LibraryPath)
+ None
+
+
+ CPlusPlusBuilder.Personality
+ CppConsoleApplication
+
+FalseFalse1000FalseFalseFalseFalseFalse103312521.0.0.01.0.0.0FalseFalseFalseTrueFalse
+
+
+ CodeGear C++Builder Office 2000 Servers Package
+ CodeGear C++Builder Office XP Servers Package
+ FalseTrueTrue3$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\include;..\test;..$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\include;..\test$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;..\include1$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;..\test$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;..\test$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(OUTPUTDIR);..\test2NO_STRICTSTRICT
+
+
+
+
+ 0
+
+
+ 1
+
+
+ Cfg_1
+
+
+ Cfg_2
+
+
+
\ No newline at end of file
diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h
index f61d502f..d596b3a6 100644
--- a/include/gtest/internal/gtest-internal.h
+++ b/include/gtest/internal/gtest-internal.h
@@ -383,7 +383,7 @@ class FloatingPoint {
// around may change its bits, although the new value is guaranteed
// to be also a NAN. Therefore, don't expect this constructor to
// preserve the bits in x when x is a NAN.
- explicit FloatingPoint(const RawType& x) : value_(x) {}
+ explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
// Static methods
@@ -392,8 +392,8 @@ class FloatingPoint {
// This function is needed to test the AlmostEquals() method.
static RawType ReinterpretBits(const Bits bits) {
FloatingPoint fp(0);
- fp.bits_ = bits;
- return fp.value_;
+ fp.u_.bits_ = bits;
+ return fp.u_.value_;
}
// Returns the floating-point number that represent positive infinity.
@@ -404,16 +404,16 @@ class FloatingPoint {
// Non-static methods
// Returns the bits that represents this number.
- const Bits &bits() const { return bits_; }
+ const Bits &bits() const { return u_.bits_; }
// Returns the exponent bits of this number.
- Bits exponent_bits() const { return kExponentBitMask & bits_; }
+ Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
// Returns the fraction bits of this number.
- Bits fraction_bits() const { return kFractionBitMask & bits_; }
+ Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
// Returns the sign bit of this number.
- Bits sign_bit() const { return kSignBitMask & bits_; }
+ Bits sign_bit() const { return kSignBitMask & u_.bits_; }
// Returns true iff this is NAN (not a number).
bool is_nan() const {
@@ -433,10 +433,17 @@ class FloatingPoint {
// a NAN must return false.
if (is_nan() || rhs.is_nan()) return false;
- return DistanceBetweenSignAndMagnitudeNumbers(bits_, rhs.bits_) <= kMaxUlps;
+ return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
+ <= kMaxUlps;
}
private:
+ // The data type used to store the actual floating-point number.
+ union FloatingPointUnion {
+ RawType value_; // The raw floating-point number.
+ Bits bits_; // The bits that represent the number.
+ };
+
// Converts an integer from the sign-and-magnitude representation to
// the biased representation. More precisely, let N be 2 to the
// power of (kBitCount - 1), an integer x is represented by the
@@ -471,10 +478,7 @@ class FloatingPoint {
return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
}
- union {
- RawType value_; // The raw floating-point number.
- Bits bits_; // The bits that represent the number.
- };
+ FloatingPointUnion u_;
};
// Typedefs the instances of the FloatingPoint template class that we
diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h
index 3e178fac..a82eec82 100644
--- a/include/gtest/internal/gtest-port.h
+++ b/include/gtest/internal/gtest-port.h
@@ -220,13 +220,15 @@
// Defines GTEST_HAS_EXCEPTIONS to 1 if exceptions are enabled, or 0
// otherwise.
-#ifdef _MSC_VER // Compiled by MSVC?
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS
+// macro to enable exceptions, so we'll do the same.
// Assumes that exceptions are enabled by default.
-#ifndef _HAS_EXCEPTIONS // MSVC uses this macro to enable exceptions.
+#ifndef _HAS_EXCEPTIONS
#define _HAS_EXCEPTIONS 1
#endif // _HAS_EXCEPTIONS
#define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
-#else // The compiler is not MSVC.
+#else // The compiler is not MSVC or C++Builder.
// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled. For
// other compilers, we assume exceptions are disabled to be
// conservative.
@@ -235,7 +237,7 @@
#else
#define GTEST_HAS_EXCEPTIONS 0
#endif // defined(__GNUC__) && __EXCEPTIONS
-#endif // _MSC_VER
+#endif // defined(_MSC_VER) || defined(__BORLANDC__)
// Determines whether ::std::string and ::string are available.
@@ -756,13 +758,22 @@ namespace posix {
typedef struct _stat StatStruct;
-inline int FileNo(FILE* file) { return _fileno(file); }
+#ifdef __BORLANDC__
+inline int IsATTY(int fd) { return isatty(fd); }
+inline int StrCaseCmp(const char* s1, const char* s2) {
+ return stricmp(s1, s2);
+}
+inline char* StrDup(const char* src) { return strdup(src); }
+#else
inline int IsATTY(int fd) { return _isatty(fd); }
-inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
inline int StrCaseCmp(const char* s1, const char* s2) {
return _stricmp(s1, s2);
}
inline char* StrDup(const char* src) { return _strdup(src); }
+#endif // __BORLANDC__
+
+inline int FileNo(FILE* file) { return _fileno(file); }
+inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
inline int RmDir(const char* dir) { return _rmdir(dir); }
inline bool IsDir(const StatStruct& st) {
return (_S_IFDIR & st.st_mode) != 0;
@@ -778,7 +789,7 @@ inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
inline int StrCaseCmp(const char* s1, const char* s2) {
return strcasecmp(s1, s2);
}
-inline char* StrDup(const char* src) { return ::strdup(src); }
+inline char* StrDup(const char* src) { return strdup(src); }
inline int RmDir(const char* dir) { return rmdir(dir); }
inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
@@ -815,6 +826,11 @@ inline const char* StrError(int errnum) { return strerror(errnum); }
inline const char* GetEnv(const char* name) {
#ifdef _WIN32_WCE // We are on Windows CE, which has no environment variables.
return NULL;
+#elif defined(__BORLANDC__)
+ // Environment variables which we programmatically clear will be set to the
+ // empty string rather than unset (NULL). Handle that case.
+ const char* const env = getenv(name);
+ return (env != NULL && env[0] != '\0') ? env : NULL;
#else
return getenv(name);
#endif
diff --git a/src/gtest-filepath.cc b/src/gtest-filepath.cc
index 3180d0d5..f966352b 100644
--- a/src/gtest-filepath.cc
+++ b/src/gtest-filepath.cc
@@ -88,10 +88,10 @@ FilePath FilePath::GetCurrentDir() {
// something reasonable.
return FilePath(kCurrentDirectoryString);
#elif GTEST_OS_WINDOWS
- char cwd[GTEST_PATH_MAX_ + 1] = {};
+ char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
#else
- char cwd[GTEST_PATH_MAX_ + 1] = {};
+ char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
#endif
}
@@ -127,8 +127,13 @@ FilePath FilePath::RemoveDirectoryName() const {
// On Windows platform, '\' is the path separator, otherwise it is '/'.
FilePath FilePath::RemoveFileName() const {
const char* const last_sep = strrchr(c_str(), kPathSeparator);
- return FilePath(last_sep ? String(c_str(), last_sep + 1 - c_str())
- : String(kCurrentDirectoryString));
+ String dir;
+ if (last_sep) {
+ dir = String(c_str(), last_sep + 1 - c_str());
+ } else {
+ dir = kCurrentDirectoryString;
+ }
+ return FilePath(dir);
}
// Helper functions for naming files in a directory for xml output.
@@ -141,11 +146,13 @@ FilePath FilePath::MakeFileName(const FilePath& directory,
const FilePath& base_name,
int number,
const char* extension) {
- const FilePath file_name(
- (number == 0) ?
- String::Format("%s.%s", base_name.c_str(), extension) :
- String::Format("%s_%d.%s", base_name.c_str(), number, extension));
- return ConcatPaths(directory, file_name);
+ String file;
+ if (number == 0) {
+ file = String::Format("%s.%s", base_name.c_str(), extension);
+ } else {
+ file = String::Format("%s_%d.%s", base_name.c_str(), number, extension);
+ }
+ return ConcatPaths(directory, FilePath(file));
}
// Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml".
diff --git a/src/gtest-port.cc b/src/gtest-port.cc
index e5c793f8..7f6db79f 100644
--- a/src/gtest-port.cc
+++ b/src/gtest-port.cc
@@ -68,8 +68,8 @@
namespace testing {
namespace internal {
-#ifdef _MSC_VER
-// MSVC does not provide a definition of STDERR_FILENO.
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+// MSVC and C++Builder do not provide a definition of STDERR_FILENO.
const int kStdErrFileno = 2;
#else
const int kStdErrFileno = STDERR_FILENO;
diff --git a/src/gtest.cc b/src/gtest.cc
index a7118055..48807671 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -735,10 +735,11 @@ String UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
}
static TimeInMillis GetTimeInMillis() {
-#ifdef _WIN32_WCE // We are on Windows CE
+#if defined(_WIN32_WCE) || defined(__BORLANDC__)
// Difference between 1970-01-01 and 1601-01-01 in miliseconds.
// http://analogous.blogspot.com/2005/04/epoch.html
- const TimeInMillis kJavaEpochToWinFileTimeDelta = 11644473600000UL;
+ const TimeInMillis kJavaEpochToWinFileTimeDelta =
+ static_cast(116444736UL) * 100000UL;
const DWORD kTenthMicrosInMilliSecond = 10000;
SYSTEMTIME now_systime;
@@ -3221,13 +3222,18 @@ UnitTest * UnitTest::GetInstance() {
// different implementation in this case to bypass the compiler bug.
// This implementation makes the compiler happy, at the cost of
// leaking the UnitTest object.
-#if _MSC_VER == 1310 && !defined(_DEBUG) // MSVC 7.1 and optimized build.
+
+ // CodeGear C++Builder insists on a public destructor for the
+ // default implementation. Use this implementation to keep good OO
+ // design with private destructor.
+
+#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
static UnitTest* const instance = new UnitTest;
return instance;
#else
static UnitTest instance;
return &instance;
-#endif // _MSC_VER==1310 && !defined(_DEBUG)
+#endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
}
// Registers and returns a global test environment. When a test
@@ -3259,7 +3265,7 @@ Environment* UnitTest::AddEnvironment(Environment* env) {
class GoogleTestFailureException : public ::std::runtime_error {
public:
explicit GoogleTestFailureException(const TestPartResult& failure)
- : runtime_error(PrintTestPartResultToString(failure).c_str()) {}
+ : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}
};
#endif
@@ -3350,17 +3356,20 @@ int UnitTest::Run() {
SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
#endif // _WIN32_WCE
+#if defined(_MSC_VER) || defined(__MINGW32__)
// Death test children can be terminated with _abort(). On Windows,
// _abort() can show a dialog with a warning message. This forces the
// abort message to go to stderr instead.
_set_error_mode(_OUT_TO_STDERR);
+#endif
+#if _MSC_VER >= 1400
// In the debug version, Visual Studio pops up a separate dialog
// offering a choice to debug the aborted program. We need to suppress
// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
// executed. Google Test will notify the user of any unexpected
// failure via stderr.
-#if _MSC_VER >= 1400
+ //
// VC++ doesn't define _set_abort_behavior() prior to the version 8.0.
// Users of prior VC versions shall suffer the agony and pain of
// clicking through the countless debug dialogs.
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index 0786725b..8becca15 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -65,6 +65,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#undef GTEST_IMPLEMENTATION_
#include
+#include
#if GTEST_HAS_PTHREAD
#include
@@ -79,6 +80,10 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include
#endif // GTEST_OS_LINUX
+#ifdef __BORLANDC__
+#include