diff options
Diffstat (limited to 'include/gtest')
-rw-r--r-- | include/gtest/gtest-printers.h | 28 | ||||
-rw-r--r-- | include/gtest/gtest.h | 4 | ||||
-rw-r--r-- | include/gtest/internal/gtest-internal.h | 5 | ||||
-rw-r--r-- | include/gtest/internal/gtest-string.h | 2 |
4 files changed, 31 insertions, 8 deletions
diff --git a/include/gtest/gtest-printers.h b/include/gtest/gtest-printers.h index 8ed6ec13..cbb809f9 100644 --- a/include/gtest/gtest-printers.h +++ b/include/gtest/gtest-printers.h @@ -308,7 +308,10 @@ void DefaultPrintTo(IsNotContainer /* dummy */, } else { // C++ doesn't allow casting from a function pointer to any object // pointer. - if (ImplicitlyConvertible<T*, const void*>::value) { + // + // IsTrue() silences warnings: "Condition is always true", + // "unreachable code". + if (IsTrue(ImplicitlyConvertible<T*, const void*>::value)) { // T is not a function type. We just call << to print p, // relying on ADL to pick up user-defined << for their pointer // types, if any. @@ -736,12 +739,25 @@ struct TuplePrefixPrinter<0> { template <typename Tuple> static void TersePrintPrefixToStrings(const Tuple&, Strings*) {} }; +// We have to specialize the entire TuplePrefixPrinter<> class +// template here, even though the definition of +// TersePrintPrefixToStrings() is the same as the generic version, as +// Borland C++ doesn't support specializing a method. template <> -template <typename Tuple> -void TuplePrefixPrinter<1>::PrintPrefixTo(const Tuple& t, ::std::ostream* os) { - UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>:: - Print(::std::tr1::get<0>(t), os); -} +struct TuplePrefixPrinter<1> { + template <typename Tuple> + static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) { + UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>:: + Print(::std::tr1::get<0>(t), os); + } + + template <typename Tuple> + static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) { + ::std::stringstream ss; + UniversalTersePrint(::std::tr1::get<0>(t), &ss); + strings->push_back(ss.str()); + } +}; // Helper function for printing a tuple. T must be instantiated with // a tuple type. diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h index 03ade855..cd01c7ba 100644 --- a/include/gtest/gtest.h +++ b/include/gtest/gtest.h @@ -1296,7 +1296,9 @@ namespace internal { template <typename T1, typename T2> String FormatForComparisonFailureMessage(const T1& value, const T2& /* other_operand */) { - return PrintToString(value); + // C++Builder compiles this incorrectly if the namespace isn't explicitly + // given. + return ::testing::PrintToString(value); } // The helper function for {ASSERT|EXPECT}_EQ. diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h index db098a49..947b1625 100644 --- a/include/gtest/internal/gtest-internal.h +++ b/include/gtest/internal/gtest-internal.h @@ -873,6 +873,11 @@ class ImplicitlyConvertible { static const bool value = sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1; # pragma warning(pop) // Restores the warning state. +#elif defined(__BORLANDC__) + // C++Builder cannot use member overload resolution during template + // instantiation. The simplest workaround is to use its C++0x type traits + // functions (C++Builder 2009 and above only). + static const bool value = __is_convertible(From, To); #else static const bool value = sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1; diff --git a/include/gtest/internal/gtest-string.h b/include/gtest/internal/gtest-string.h index efde52a9..dc3a07be 100644 --- a/include/gtest/internal/gtest-string.h +++ b/include/gtest/internal/gtest-string.h @@ -296,7 +296,7 @@ class GTEST_API_ String { private: // Constructs a non-NULL String from the given content. This - // function can only be called when data_ has not been allocated. + // function can only be called when c_str_ has not been allocated. // ConstructNonNull(NULL, 0) results in an empty string (""). // ConstructNonNull(NULL, non_zero) is undefined behavior. void ConstructNonNull(const char* buffer, size_t a_length) { |