Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit

Permalink
Update gtest to 1.7.0 to resolve problems with libc++
Browse files Browse the repository at this point in the history
  • Loading branch information
scpeters committed Nov 11, 2013
1 parent 66b9824 commit 8df675f
Show file tree
Hide file tree
Showing 34 changed files with 2,568 additions and 1,519 deletions.
13 changes: 12 additions & 1 deletion test/gtest/cmake/internal_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ macro(config_compiler_and_linker)
# Newlines inside flags variables break CMake's NMake generator.
# TODO([email protected]): Add -RTCs and -RTCu to debug builds.
set(cxx_base_flags "-GS -W4 -WX -wd4127 -wd4251 -wd4275 -nologo -J -Zi")
if (MSVC_VERSION LESS 1400)
# Suppress spurious warnings MSVC 7.1 sometimes issues.
# Forcing value to bool.
set(cxx_base_flags "${cxx_base_flags} -wd4800")
# Copy constructor and assignment operator could not be generated.
set(cxx_base_flags "${cxx_base_flags} -wd4511 -wd4512")
# Compatibility warnings not applicable to Google Test.
# Resolved overload was found by argument-dependent lookup.
set(cxx_base_flags "${cxx_base_flags} -wd4675")
endif()
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
Expand All @@ -69,7 +79,8 @@ macro(config_compiler_and_linker)
# whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
# explicitly.
set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0")
set(cxx_strict_flags "-Wextra")
set(cxx_strict_flags
"-Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
set(cxx_exception_flags "-features=except")
# Sun Pro doesn't provide macros to indicate whether exceptions and
Expand Down
10 changes: 0 additions & 10 deletions test/gtest/gtest-1.6.0.diff

This file was deleted.

44 changes: 44 additions & 0 deletions test/gtest/gtest-1.7.0.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff -r a5e72dd0ecf3 test/gtest/include/gtest/gtest-typed-test.h
--- a/test/gtest/include/gtest/gtest-typed-test.h Mon Nov 04 11:47:43 2013 -0800
+++ b/test/gtest/include/gtest/gtest-typed-test.h Mon Nov 04 11:49:12 2013 -0800
@@ -31,6 +31,7 @@

#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
+#pragma GCC system_header

// This header implements typed tests and type-parameterized tests.

diff -r a5e72dd0ecf3 test/gtest/src/gtest.cc
--- a/test/gtest/src/gtest.cc Mon Nov 04 11:47:43 2013 -0800
+++ b/test/gtest/src/gtest.cc Mon Nov 04 11:49:12 2013 -0800
@@ -33,6 +33,7 @@

#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
+#pragma GCC system_header

#include <ctype.h>
#include <math.h>
diff -r c33b44f8a9a1 test/gtest/include/gtest/internal/gtest-port.h
--- a/test/gtest/include/gtest/internal/gtest-port.h Wed Nov 06 11:23:38 2013 -0800
+++ b/test/gtest/include/gtest/internal/gtest-port.h Wed Nov 06 17:12:57 2013 -0800
@@ -39,6 +39,7 @@

#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
+#pragma GCC system_header

// The user can define the following macros in the build script to
// control Google Test's behavior. If the user doesn't define a macro
diff -r e980730656c1 test/gtest/include/gtest/gtest-printers.h
--- a/test/gtest/include/gtest/gtest-printers.h Wed Nov 06 17:13:57 2013 -0800
+++ b/test/gtest/include/gtest/gtest-printers.h Thu Nov 07 09:29:28 2013 -0800
@@ -94,6 +94,7 @@

#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
+#pragma GCC system_header

#include <ostream> // NOLINT
#include <sstream>
17 changes: 14 additions & 3 deletions test/gtest/include/gtest/gtest-death-test.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ GTEST_DECLARE_string_(death_test_style);

#if GTEST_HAS_DEATH_TEST

namespace internal {

// Returns a Boolean value indicating whether the caller is currently
// executing in the context of the death test child process. Tools such as
// Valgrind heap checkers may need this to modify their behavior in death
// tests. IMPORTANT: This is an internal utility. Using it may break the
// implementation of death tests. User code MUST NOT use it.
GTEST_API_ bool InDeathTestChild();

} // namespace internal

// The following macros are useful for writing death tests.

// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
Expand All @@ -75,7 +86,7 @@ GTEST_DECLARE_string_(death_test_style);
// for (int i = 0; i < 5; i++) {
// EXPECT_DEATH(server.ProcessRequest(i),
// "Invalid request .* in ProcessRequest()")
// << "Failed to die on request " << i);
// << "Failed to die on request " << i;
// }
//
// ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
Expand Down Expand Up @@ -245,10 +256,10 @@ class GTEST_API_ KilledBySignal {
# ifdef NDEBUG

# define EXPECT_DEBUG_DEATH(statement, regex) \
do { statement; } while (::testing::internal::AlwaysFalse())
GTEST_EXECUTE_STATEMENT_(statement, regex)

# define ASSERT_DEBUG_DEATH(statement, regex) \
do { statement; } while (::testing::internal::AlwaysFalse())
GTEST_EXECUTE_STATEMENT_(statement, regex)

# else

Expand Down
74 changes: 47 additions & 27 deletions test/gtest/include/gtest/gtest-message.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@

#include <limits>

#include "gtest/internal/gtest-string.h"
#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-port.h"

// Ensures that there is at least one operator<< in the global namespace.
// See Message& operator<<(...) below for why.
void operator<<(const testing::internal::Secret&, int);

namespace testing {

Expand Down Expand Up @@ -87,15 +90,7 @@ class GTEST_API_ Message {

public:
// Constructs an empty Message.
// We allocate the stringstream separately because otherwise each use of
// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
// stack frame leading to huge stack frames in some cases; gcc does not reuse
// the stack space.
Message() : ss_(new ::std::stringstream) {
// By default, we want there to be enough precision when printing
// a double to a Message.
*ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);
}
Message();

// Copy constructor.
Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT
Expand All @@ -118,7 +113,22 @@ class GTEST_API_ Message {
// Streams a non-pointer value to this object.
template <typename T>
inline Message& operator <<(const T& val) {
::GTestStreamToHelper(ss_.get(), val);
// Some libraries overload << for STL containers. These
// overloads are defined in the global namespace instead of ::std.
//
// C++'s symbol lookup rule (i.e. Koenig lookup) says that these
// overloads are visible in either the std namespace or the global
// namespace, but not other namespaces, including the testing
// namespace which Google Test's Message class is in.
//
// To allow STL containers (and other types that has a << operator
// defined in the global namespace) to be used in Google Test
// assertions, testing::Message must access the custom << operator
// from the global namespace. With this using declaration,
// overloads of << defined in the global namespace and those
// visible via Koenig lookup are both exposed in this function.
using ::operator <<;
*ss_ << val;
return *this;
}

Expand All @@ -140,7 +150,7 @@ class GTEST_API_ Message {
if (pointer == NULL) {
*ss_ << "(null)";
} else {
::GTestStreamToHelper(ss_.get(), pointer);
*ss_ << pointer;
}
return *this;
}
Expand All @@ -164,12 +174,8 @@ class GTEST_API_ Message {

// These two overloads allow streaming a wide C string to a Message
// using the UTF-8 encoding.
Message& operator <<(const wchar_t* wide_c_str) {
return *this << internal::String::ShowWideCString(wide_c_str);
}
Message& operator <<(wchar_t* wide_c_str) {
return *this << internal::String::ShowWideCString(wide_c_str);
}
Message& operator <<(const wchar_t* wide_c_str);
Message& operator <<(wchar_t* wide_c_str);

#if GTEST_HAS_STD_WSTRING
// Converts the given wide string to a narrow string using the UTF-8
Expand All @@ -183,13 +189,11 @@ class GTEST_API_ Message {
Message& operator <<(const ::wstring& wstr);
#endif // GTEST_HAS_GLOBAL_WSTRING

// Gets the text streamed to this object so far as a String.
// Gets the text streamed to this object so far as an std::string.
// Each '\0' character in the buffer is replaced with "\\0".
//
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
internal::String GetString() const {
return internal::StringStreamToString(ss_.get());
}
std::string GetString() const;

private:

Expand All @@ -199,16 +203,20 @@ class GTEST_API_ Message {
// decide between class template specializations for T and T*, so a
// tr1::type_traits-like is_pointer works, and we can overload on that.
template <typename T>
inline void StreamHelper(internal::true_type /*dummy*/, T* pointer) {
inline void StreamHelper(internal::true_type /*is_pointer*/, T* pointer) {
if (pointer == NULL) {
*ss_ << "(null)";
} else {
::GTestStreamToHelper(ss_.get(), pointer);
*ss_ << pointer;
}
}
template <typename T>
inline void StreamHelper(internal::false_type /*dummy*/, const T& value) {
::GTestStreamToHelper(ss_.get(), value);
inline void StreamHelper(internal::false_type /*is_pointer*/,
const T& value) {
// See the comments in Message& operator <<(const T&) above for why
// we need this using statement.
using ::operator <<;
*ss_ << value;
}
#endif // GTEST_OS_SYMBIAN

Expand All @@ -225,6 +233,18 @@ inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
return os << sb.GetString();
}

namespace internal {

// Converts a streamable value to an std::string. A NULL pointer is
// converted to "(null)". When the input value is a ::string,
// ::std::string, ::wstring, or ::std::wstring object, each NUL
// character in it is replaced with "\\0".
template <typename T>
std::string StreamableToString(const T& streamable) {
return (Message() << streamable).GetString();
}

} // namespace internal
} // namespace testing

#endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
2 changes: 1 addition & 1 deletion test/gtest/include/gtest/gtest-param-test.h
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ inline internal::ParamGenerator<bool> Bool() {
// Boolean flags:
//
// class FlagDependentTest
// : public testing::TestWithParam<tuple(bool, bool)> > {
// : public testing::TestWithParam<tuple<bool, bool> > {
// virtual void SetUp() {
// // Assigns external_flag_1 and external_flag_2 values from the tuple.
// tie(external_flag_1, external_flag_2) = GetParam();
Expand Down
2 changes: 1 addition & 1 deletion test/gtest/include/gtest/gtest-param-test.h.pump
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ inline internal::ParamGenerator<bool> Bool() {
// Boolean flags:
//
// class FlagDependentTest
// : public testing::TestWithParam<tuple(bool, bool)> > {
// : public testing::TestWithParam<tuple<bool, bool> > {
// virtual void SetUp() {
// // Assigns external_flag_1 and external_flag_2 values from the tuple.
// tie(external_flag_1, external_flag_2) = GetParam();
Expand Down
Loading

0 comments on commit 8df675f

Please sign in to comment.