Commit 5d96565c authored by Gaspard Petit's avatar Gaspard Petit
Browse files

Merge branch 'master' into support_xboxone

parents 8b491162 23015249
...@@ -29,10 +29,12 @@ ...@@ -29,10 +29,12 @@
// //
// Author: wan@google.com (Zhanyong Wan) // Author: wan@google.com (Zhanyong Wan)
#include "gtest/gtest.h"
#include "sample4.h" #include "sample4.h"
#include "gtest/gtest.h"
namespace { namespace {
// Tests the Increment() method. // Tests the Increment() method.
TEST(Counter, Increment) { TEST(Counter, Increment) {
Counter c; Counter c;
...@@ -43,4 +45,5 @@ TEST(Counter, Increment) { ...@@ -43,4 +45,5 @@ TEST(Counter, Increment) {
EXPECT_EQ(1, c.Increment()); EXPECT_EQ(1, c.Increment());
EXPECT_EQ(2, c.Increment()); EXPECT_EQ(2, c.Increment());
} }
} // namespace } // namespace
...@@ -46,9 +46,9 @@ ...@@ -46,9 +46,9 @@
#include <limits.h> #include <limits.h>
#include <time.h> #include <time.h>
#include "sample3-inl.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "sample1.h" #include "sample1.h"
#include "sample3-inl.h"
namespace { namespace {
// In this sample, we want to ensure that every test finishes within // In this sample, we want to ensure that every test finishes within
// ~5 seconds. If a test takes longer to run, we consider it a // ~5 seconds. If a test takes longer to run, we consider it a
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace { namespace {
#if GTEST_HAS_PARAM_TEST
using ::testing::TestWithParam; using ::testing::TestWithParam;
using ::testing::Values; using ::testing::Values;
...@@ -116,15 +115,4 @@ INSTANTIATE_TEST_CASE_P(OnTheFlyAndPreCalculated, PrimeTableTestSmpl7, ...@@ -116,15 +115,4 @@ INSTANTIATE_TEST_CASE_P(OnTheFlyAndPreCalculated, PrimeTableTestSmpl7,
Values(&CreateOnTheFlyPrimeTable, Values(&CreateOnTheFlyPrimeTable,
&CreatePreCalculatedPrimeTable<1000>)); &CreatePreCalculatedPrimeTable<1000>));
#else
// Google Test may not support value-parameterized tests with some
// compilers. If we use conditional compilation to compile out all
// code referring to the gtest_main library, MSVC linker will not link
// that library at all and consequently complain about missing entry
// point defined in that library (fatal error LNK1561: entry point
// must be defined). This dummy test keeps gtest_main linked in.
TEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {}
#endif // GTEST_HAS_PARAM_TEST
} // namespace } // namespace
...@@ -66,15 +66,7 @@ ...@@ -66,15 +66,7 @@
#include "gtest/gtest-message.h" #include "gtest/gtest-message.h"
#include "gtest/internal/gtest-string.h" #include "gtest/internal/gtest-string.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick exists to
// prevent the accidental inclusion of gtest-internal-inl.h in the
// user's code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
...@@ -259,7 +251,7 @@ enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW }; ...@@ -259,7 +251,7 @@ enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };
// message is propagated back to the parent process. Otherwise, the // message is propagated back to the parent process. Otherwise, the
// message is simply printed to stderr. In either case, the program // message is simply printed to stderr. In either case, the program
// then exits with status 1. // then exits with status 1.
void DeathTestAbort(const std::string& message) { static void DeathTestAbort(const std::string& message) {
// On a POSIX system, this function may be called from a threadsafe-style // On a POSIX system, this function may be called from a threadsafe-style
// death test child process, which operates on a very small stack. Use // death test child process, which operates on a very small stack. Use
// the heap for any additional non-minuscule memory requirements. // the heap for any additional non-minuscule memory requirements.
...@@ -985,6 +977,7 @@ static int ExecDeathTestChildMain(void* child_arg) { ...@@ -985,6 +977,7 @@ static int ExecDeathTestChildMain(void* child_arg) {
} }
# endif // !GTEST_OS_QNX # endif // !GTEST_OS_QNX
# if GTEST_HAS_CLONE
// Two utility routines that together determine the direction the stack // Two utility routines that together determine the direction the stack
// grows. // grows.
// This could be accomplished more elegantly by a single recursive // This could be accomplished more elegantly by a single recursive
...@@ -994,20 +987,22 @@ static int ExecDeathTestChildMain(void* child_arg) { ...@@ -994,20 +987,22 @@ static int ExecDeathTestChildMain(void* child_arg) {
// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining // GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining
// StackLowerThanAddress into StackGrowsDown, which then doesn't give // StackLowerThanAddress into StackGrowsDown, which then doesn't give
// correct answer. // correct answer.
void StackLowerThanAddress(const void* ptr, bool* result) GTEST_NO_INLINE_; static void StackLowerThanAddress(const void* ptr,
void StackLowerThanAddress(const void* ptr, bool* result) { bool* result) GTEST_NO_INLINE_;
static void StackLowerThanAddress(const void* ptr, bool* result) {
int dummy; int dummy;
*result = (&dummy < ptr); *result = (&dummy < ptr);
} }
// Make sure AddressSanitizer does not tamper with the stack here. // Make sure AddressSanitizer does not tamper with the stack here.
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
bool StackGrowsDown() { static bool StackGrowsDown() {
int dummy; int dummy;
bool result; bool result;
StackLowerThanAddress(&dummy, &result); StackLowerThanAddress(&dummy, &result);
return result; return result;
} }
# endif // GTEST_HAS_CLONE
// Spawns a child process with the same executable as the current process in // Spawns a child process with the same executable as the current process in
// a thread-safe manner and instructs it to run the death test. The // a thread-safe manner and instructs it to run the death test. The
...@@ -1223,7 +1218,7 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex, ...@@ -1223,7 +1218,7 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
// Recreates the pipe and event handles from the provided parameters, // Recreates the pipe and event handles from the provided parameters,
// signals the event, and returns a file descriptor wrapped around the pipe // signals the event, and returns a file descriptor wrapped around the pipe
// handle. This function is called in the child process only. // handle. This function is called in the child process only.
int GetStatusFileDescriptor(unsigned int parent_process_id, static int GetStatusFileDescriptor(unsigned int parent_process_id,
size_t write_handle_as_size_t, size_t write_handle_as_size_t,
size_t event_handle_as_size_t) { size_t event_handle_as_size_t) {
AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE, AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,
......
...@@ -37,14 +37,6 @@ ...@@ -37,14 +37,6 @@
#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_ #ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_
#define GTEST_SRC_GTEST_INTERNAL_INL_H_ #define GTEST_SRC_GTEST_INTERNAL_INL_H_
// GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is
// part of Google Test's implementation; otherwise it's undefined.
#if !GTEST_IMPLEMENTATION_
// If this file is included from the user's code, just say no.
# error "gtest-internal-inl.h is part of Google Test's internal implementation."
# error "It must not be included except by Google Test itself."
#endif // GTEST_IMPLEMENTATION_
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
# include <errno.h> # include <errno.h>
#endif // !_WIN32_WCE #endif // !_WIN32_WCE
...@@ -664,13 +656,11 @@ class GTEST_API_ UnitTestImpl { ...@@ -664,13 +656,11 @@ class GTEST_API_ UnitTestImpl {
tear_down_tc)->AddTestInfo(test_info); tear_down_tc)->AddTestInfo(test_info);
} }
#if GTEST_HAS_PARAM_TEST
// Returns ParameterizedTestCaseRegistry object used to keep track of // Returns ParameterizedTestCaseRegistry object used to keep track of
// value-parameterized tests and instantiate and register them. // value-parameterized tests and instantiate and register them.
internal::ParameterizedTestCaseRegistry& parameterized_test_registry() { internal::ParameterizedTestCaseRegistry& parameterized_test_registry() {
return parameterized_test_registry_; return parameterized_test_registry_;
} }
#endif // GTEST_HAS_PARAM_TEST
// Sets the TestCase object for the test that's currently running. // Sets the TestCase object for the test that's currently running.
void set_current_test_case(TestCase* a_current_test_case) { void set_current_test_case(TestCase* a_current_test_case) {
...@@ -845,14 +835,12 @@ class GTEST_API_ UnitTestImpl { ...@@ -845,14 +835,12 @@ class GTEST_API_ UnitTestImpl {
// shuffled order. // shuffled order.
std::vector<int> test_case_indices_; std::vector<int> test_case_indices_;
#if GTEST_HAS_PARAM_TEST
// ParameterizedTestRegistry object used to register value-parameterized // ParameterizedTestRegistry object used to register value-parameterized
// tests. // tests.
internal::ParameterizedTestCaseRegistry parameterized_test_registry_; internal::ParameterizedTestCaseRegistry parameterized_test_registry_;
// Indicates whether RegisterParameterizedTests() has been called already. // Indicates whether RegisterParameterizedTests() has been called already.
bool parameterized_tests_registered_; bool parameterized_tests_registered_;
#endif // GTEST_HAS_PARAM_TEST
// Index of the last death test case registered. Initially -1. // Index of the last death test case registered. Initially -1.
int last_death_test_case_; int last_death_test_case_;
......
...@@ -67,15 +67,7 @@ ...@@ -67,15 +67,7 @@
#include "gtest/gtest-message.h" #include "gtest/gtest-message.h"
#include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-string.h" #include "gtest/internal/gtest-string.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick exists to
// prevent the accidental inclusion of gtest-internal-inl.h in the
// user's code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
namespace internal { namespace internal {
...@@ -671,7 +663,7 @@ bool AtomMatchesChar(bool escaped, char pattern_char, char ch) { ...@@ -671,7 +663,7 @@ bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
} }
// Helper function used by ValidateRegex() to format error messages. // Helper function used by ValidateRegex() to format error messages.
std::string FormatRegexSyntaxError(const char* regex, int index) { static std::string FormatRegexSyntaxError(const char* regex, int index) {
return (Message() << "Syntax error at index " << index return (Message() << "Syntax error at index " << index
<< " in simple regular expression \"" << regex << "\": ").GetString(); << " in simple regular expression \"" << regex << "\": ").GetString();
} }
...@@ -1015,7 +1007,9 @@ static CapturedStream* g_captured_stderr = NULL; ...@@ -1015,7 +1007,9 @@ static CapturedStream* g_captured_stderr = NULL;
static CapturedStream* g_captured_stdout = NULL; static CapturedStream* g_captured_stdout = NULL;
// Starts capturing an output stream (stdout/stderr). // Starts capturing an output stream (stdout/stderr).
void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) { static void CaptureStream(int fd,
const char* stream_name,
CapturedStream** stream) {
if (*stream != NULL) { if (*stream != NULL) {
GTEST_LOG_(FATAL) << "Only one " << stream_name GTEST_LOG_(FATAL) << "Only one " << stream_name
<< " capturer can exist at a time."; << " capturer can exist at a time.";
...@@ -1024,7 +1018,7 @@ void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) { ...@@ -1024,7 +1018,7 @@ void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {
} }
// Stops capturing the output stream and returns the captured string. // Stops capturing the output stream and returns the captured string.
std::string GetCapturedStream(CapturedStream** captured_stream) { static std::string GetCapturedStream(CapturedStream** captured_stream) {
const std::string content = (*captured_stream)->GetCapturedString(); const std::string content = (*captured_stream)->GetCapturedString();
delete *captured_stream; delete *captured_stream;
......
...@@ -180,7 +180,10 @@ static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) { ...@@ -180,7 +180,10 @@ static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) {
*os << static_cast<char>(c); *os << static_cast<char>(c);
return kAsIs; return kAsIs;
} else { } else {
*os << "\\x" + String::FormatHexInt(static_cast<UnsignedChar>(c)); ostream::fmtflags flags = os->flags();
*os << "\\x" << std::hex << std::uppercase
<< static_cast<int>(static_cast<UnsignedChar>(c));
os->flags(flags);
return kHexEscape; return kHexEscape;
} }
} }
......
...@@ -32,15 +32,7 @@ ...@@ -32,15 +32,7 @@
// The Google C++ Testing Framework (Google Test) // The Google C++ Testing Framework (Google Test)
#include "gtest/gtest-test-part.h" #include "gtest/gtest-test-part.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick exists to
// prevent the accidental inclusion of gtest-internal-inl.h in the
// user's code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
......
...@@ -133,14 +133,7 @@ ...@@ -133,14 +133,7 @@
# include <sys/types.h> // NOLINT # include <sys/types.h> // NOLINT
#endif #endif
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
# define vsnprintf _vsnprintf # define vsnprintf _vsnprintf
...@@ -629,7 +622,7 @@ extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId(); ...@@ -629,7 +622,7 @@ extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();
// This predicate-formatter checks that 'results' contains a test part // This predicate-formatter checks that 'results' contains a test part
// failure of the given type and that the failure message contains the // failure of the given type and that the failure message contains the
// given substring. // given substring.
AssertionResult HasOneFailure(const char* /* results_expr */, static AssertionResult HasOneFailure(const char* /* results_expr */,
const char* /* type_expr */, const char* /* type_expr */,
const char* /* substr_expr */, const char* /* substr_expr */,
const TestPartResultArray& results, const TestPartResultArray& results,
...@@ -1313,11 +1306,12 @@ AssertionResult EqFailure(const char* lhs_expression, ...@@ -1313,11 +1306,12 @@ AssertionResult EqFailure(const char* lhs_expression,
const std::string& rhs_value, const std::string& rhs_value,
bool ignoring_case) { bool ignoring_case) {
Message msg; Message msg;
msg << " Expected: " << lhs_expression; msg << "Expected equality of these values:";
msg << "\n " << lhs_expression;
if (lhs_value != lhs_expression) { if (lhs_value != lhs_expression) {
msg << "\n Which is: " << lhs_value; msg << "\n Which is: " << lhs_value;
} }
msg << "\nTo be equal to: " << rhs_expression; msg << "\n " << rhs_expression;
if (rhs_value != rhs_expression) { if (rhs_value != rhs_expression) {
msg << "\n Which is: " << rhs_value; msg << "\n Which is: " << rhs_value;
} }
...@@ -2136,7 +2130,8 @@ static std::string FormatWordList(const std::vector<std::string>& words) { ...@@ -2136,7 +2130,8 @@ static std::string FormatWordList(const std::vector<std::string>& words) {
return word_list.GetString(); return word_list.GetString();
} }
bool ValidateTestPropertyName(const std::string& property_name, static bool ValidateTestPropertyName(
const std::string& property_name,
const std::vector<std::string>& reserved_names) { const std::vector<std::string>& reserved_names) {
if (std::find(reserved_names.begin(), reserved_names.end(), property_name) != if (std::find(reserved_names.begin(), reserved_names.end(), property_name) !=
reserved_names.end()) { reserved_names.end()) {
...@@ -2555,7 +2550,6 @@ TestInfo* MakeAndRegisterTestInfo( ...@@ -2555,7 +2550,6 @@ TestInfo* MakeAndRegisterTestInfo(
return test_info; return test_info;
} }
#if GTEST_HAS_PARAM_TEST
void ReportInvalidTestCaseType(const char* test_case_name, void ReportInvalidTestCaseType(const char* test_case_name,
CodeLocation code_location) { CodeLocation code_location) {
Message errors; Message errors;
...@@ -2569,12 +2563,11 @@ void ReportInvalidTestCaseType(const char* test_case_name, ...@@ -2569,12 +2563,11 @@ void ReportInvalidTestCaseType(const char* test_case_name,
<< "probably rename one of the classes to put the tests into different\n" << "probably rename one of the classes to put the tests into different\n"
<< "test cases."; << "test cases.";
fprintf(stderr, "%s %s", GTEST_LOG_(ERROR)
FormatFileLocation(code_location.file.c_str(), << FormatFileLocation(code_location.file.c_str(),
code_location.line).c_str(), code_location.line)
errors.GetString().c_str()); << " " << errors.GetString();
} }
#endif // GTEST_HAS_PARAM_TEST
} // namespace internal } // namespace internal
...@@ -2613,12 +2606,10 @@ namespace internal { ...@@ -2613,12 +2606,10 @@ namespace internal {
// and INSTANTIATE_TEST_CASE_P into regular tests and registers those. // and INSTANTIATE_TEST_CASE_P into regular tests and registers those.
// This will be done just once during the program runtime. // This will be done just once during the program runtime.
void UnitTestImpl::RegisterParameterizedTests() { void UnitTestImpl::RegisterParameterizedTests() {
#if GTEST_HAS_PARAM_TEST
if (!parameterized_tests_registered_) { if (!parameterized_tests_registered_) {
parameterized_test_registry_.RegisterTests(); parameterized_test_registry_.RegisterTests();
parameterized_tests_registered_ = true; parameterized_tests_registered_ = true;
} }
#endif
} }
} // namespace internal } // namespace internal
...@@ -2883,10 +2874,10 @@ enum GTestColor { ...@@ -2883,10 +2874,10 @@ enum GTestColor {
}; };
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \ #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \
!GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
// Returns the character attribute for the given color. // Returns the character attribute for the given color.
WORD GetColorAttribute(GTestColor color) { static WORD GetColorAttribute(GTestColor color) {
switch (color) { switch (color) {
case COLOR_RED: return FOREGROUND_RED; case COLOR_RED: return FOREGROUND_RED;
case COLOR_GREEN: return FOREGROUND_GREEN; case COLOR_GREEN: return FOREGROUND_GREEN;
...@@ -2895,7 +2886,7 @@ WORD GetColorAttribute(GTestColor color) { ...@@ -2895,7 +2886,7 @@ WORD GetColorAttribute(GTestColor color) {
} }
} }
int GetBitOffset(WORD color_mask) { static int GetBitOffset(WORD color_mask) {
if (color_mask == 0) return 0; if (color_mask == 0) return 0;
int bitOffset = 0; int bitOffset = 0;
...@@ -2906,7 +2897,7 @@ int GetBitOffset(WORD color_mask) { ...@@ -2906,7 +2897,7 @@ int GetBitOffset(WORD color_mask) {
return bitOffset; return bitOffset;
} }
WORD GetNewColor(GTestColor color, WORD old_color_attrs) { static WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
// Let's reuse the BG // Let's reuse the BG
static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY; static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY; static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
...@@ -2926,7 +2917,7 @@ WORD GetNewColor(GTestColor color, WORD old_color_attrs) { ...@@ -2926,7 +2917,7 @@ WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
// Returns the ANSI color code for the given color. COLOR_DEFAULT is // Returns the ANSI color code for the given color. COLOR_DEFAULT is
// an invalid input. // an invalid input.
const char* GetAnsiColorCode(GTestColor color) { static const char* GetAnsiColorCode(GTestColor color) {
switch (color) { switch (color) {
case COLOR_RED: return "1"; case COLOR_RED: return "1";
case COLOR_GREEN: return "2"; case COLOR_GREEN: return "2";
...@@ -2942,7 +2933,7 @@ bool ShouldUseColor(bool stdout_is_tty) { ...@@ -2942,7 +2933,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
const char* const gtest_color = GTEST_FLAG(color).c_str(); const char* const gtest_color = GTEST_FLAG(color).c_str();
if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) { if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
// On Windows the TERM variable is usually not set, but the // On Windows the TERM variable is usually not set, but the
// console there does support colors. // console there does support colors.
return stdout_is_tty; return stdout_is_tty;
...@@ -2979,7 +2970,7 @@ bool ShouldUseColor(bool stdout_is_tty) { ...@@ -2979,7 +2970,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
// This routine must actually emit the characters rather than return a string // This routine must actually emit the characters rather than return a string
// that would be colored when printed, as can be done on Linux. // that would be colored when printed, as can be done on Linux.
GTEST_ATTRIBUTE_PRINTF_(2, 3) GTEST_ATTRIBUTE_PRINTF_(2, 3)
void ColoredPrintf(GTestColor color, const char* fmt, ...) { static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
...@@ -3000,7 +2991,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { ...@@ -3000,7 +2991,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
} }
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \ #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \
!GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
// Gets the current text color. // Gets the current text color.
...@@ -3033,7 +3024,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { ...@@ -3033,7 +3024,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
static const char kTypeParamLabel[] = "TypeParam"; static const char kTypeParamLabel[] = "TypeParam";
static const char kValueParamLabel[] = "GetParam()"; static const char kValueParamLabel[] = "GetParam()";
void PrintFullTestCommentIfPresent(const TestInfo& test_info) { static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
const char* const type_param = test_info.type_param(); const char* const type_param = test_info.type_param();
const char* const value_param = test_info.value_param(); const char* const value_param = test_info.value_param();
...@@ -3449,9 +3440,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener { ...@@ -3449,9 +3440,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file) XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)
: output_file_(output_file) { : output_file_(output_file) {
if (output_file_.c_str() == NULL || output_file_.empty()) { if (output_file_.c_str() == NULL || output_file_.empty()) {
fprintf(stderr, "XML output file may not be null\n"); GTEST_LOG_(FATAL) << "XML output file may not be null";
fflush(stderr);
exit(EXIT_FAILURE);
} }
} }
...@@ -3476,11 +3465,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, ...@@ -3476,11 +3465,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// 3. To interpret the meaning of errno in a thread-safe way, // 3. To interpret the meaning of errno in a thread-safe way,
// we need the strerror_r() function, which is not available on // we need the strerror_r() function, which is not available on
// Windows. // Windows.
fprintf(stderr, GTEST_LOG_(FATAL) << "Unable to open file \""
"Unable to open file \"%s\"\n", << output_file_ << "\"";
output_file_.c_str());
fflush(stderr);
exit(EXIT_FAILURE);
} }
std::stringstream stream; std::stringstream stream;
PrintXmlUnitTest(&stream, unit_test); PrintXmlUnitTest(&stream, unit_test);
...@@ -4313,7 +4299,6 @@ const TestInfo* UnitTest::current_test_info() const ...@@ -4313,7 +4299,6 @@ const TestInfo* UnitTest::current_test_info() const
// Returns the random seed used at the start of the current test run. // Returns the random seed used at the start of the current test run.
int UnitTest::random_seed() const { return impl_->random_seed(); } int UnitTest::random_seed() const { return impl_->random_seed(); }
#if GTEST_HAS_PARAM_TEST
// Returns ParameterizedTestCaseRegistry object used to keep track of // Returns ParameterizedTestCaseRegistry object used to keep track of
// value-parameterized tests and instantiate and register them. // value-parameterized tests and instantiate and register them.
internal::ParameterizedTestCaseRegistry& internal::ParameterizedTestCaseRegistry&
...@@ -4321,7 +4306,6 @@ internal::ParameterizedTestCaseRegistry& ...@@ -4321,7 +4306,6 @@ internal::ParameterizedTestCaseRegistry&
GTEST_LOCK_EXCLUDED_(mutex_) { GTEST_LOCK_EXCLUDED_(mutex_) {
return impl_->parameterized_test_registry(); return impl_->parameterized_test_registry();
} }
#endif // GTEST_HAS_PARAM_TEST
// Creates an empty UnitTest. // Creates an empty UnitTest.
UnitTest::UnitTest() { UnitTest::UnitTest() {
...@@ -4360,10 +4344,8 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent) ...@@ -4360,10 +4344,8 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
&default_global_test_part_result_reporter_), &default_global_test_part_result_reporter_),
per_thread_test_part_result_reporter_( per_thread_test_part_result_reporter_(
&default_per_thread_test_part_result_reporter_), &default_per_thread_test_part_result_reporter_),
#if GTEST_HAS_PARAM_TEST
parameterized_test_registry_(), parameterized_test_registry_(),
parameterized_tests_registered_(false), parameterized_tests_registered_(false),
#endif // GTEST_HAS_PARAM_TEST
last_death_test_case_(-1), last_death_test_case_(-1),
current_test_case_(NULL), current_test_case_(NULL),
current_test_info_(NULL), current_test_info_(NULL),
...@@ -4431,9 +4413,9 @@ void UnitTestImpl::ConfigureXmlOutput() { ...@@ -4431,9 +4413,9 @@ void UnitTestImpl::ConfigureXmlOutput() {
listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter( listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())); UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format != "") { } else if (output_format != "") {
printf("WARNING: unrecognized output format \"%s\" ignored.\n", GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
output_format.c_str()); << output_format
fflush(stdout); << "\" ignored.";
} }
} }
...@@ -4448,9 +4430,9 @@ void UnitTestImpl::ConfigureStreamingOutput() { ...@@ -4448,9 +4430,9 @@ void UnitTestImpl::ConfigureStreamingOutput() {
listeners()->Append(new StreamingListener(target.substr(0, pos), listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1))); target.substr(pos+1)));
} else { } else {
printf("WARNING: unrecognized streaming target \"%s\" ignored.\n", GTEST_LOG_(WARNING) << "unrecognized streaming target \""
target.c_str()); << target
fflush(stdout); << "\" ignored.";
} }
} }
} }
...@@ -4579,9 +4561,9 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); } ...@@ -4579,9 +4561,9 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
bool UnitTestImpl::RunAllTests() { bool UnitTestImpl::RunAllTests() {
// Makes sure InitGoogleTest() was called. // Makes sure InitGoogleTest() was called.
if (!GTestIsInitialized()) { if (!GTestIsInitialized()) {
printf("%s", GTEST_LOG_(ERROR) <<
"\nThis test program did NOT call ::testing::InitGoogleTest " "\nThis test program did NOT call ::testing::InitGoogleTest "
"before calling RUN_ALL_TESTS(). Please fix it.\n"); "before calling RUN_ALL_TESTS(). Please fix it.";
return false; return false;
} }
...@@ -5040,7 +5022,7 @@ bool SkipPrefix(const char* prefix, const char** pstr) { ...@@ -5040,7 +5022,7 @@ bool SkipPrefix(const char* prefix, const char** pstr) {
// part can be omitted. // part can be omitted.
// //
// Returns the value of the flag, or NULL if the parsing failed. // Returns the value of the flag, or NULL if the parsing failed.
const char* ParseFlagValue(const char* str, static const char* ParseFlagValue(const char* str,
const char* flag, const char* flag,
bool def_optional) { bool def_optional) {
// str and flag must not be NULL. // str and flag must not be NULL.
...@@ -5078,7 +5060,7 @@ const char* ParseFlagValue(const char* str, ...@@ -5078,7 +5060,7 @@ const char* ParseFlagValue(const char* str,
// //
// On success, stores the value of the flag in *value, and returns // On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value. // true. On failure, returns false without changing *value.
bool ParseBoolFlag(const char* str, const char* flag, bool* value) { static bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
// Gets the value of the flag as a string. // Gets the value of the flag as a string.
const char* const value_str = ParseFlagValue(str, flag, true); const char* const value_str = ParseFlagValue(str, flag, true);
...@@ -5112,7 +5094,9 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) { ...@@ -5112,7 +5094,9 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
// //
// On success, stores the value of the flag in *value, and returns // On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value. // true. On failure, returns false without changing *value.
bool ParseStringFlag(const char* str, const char* flag, std::string* value) { static bool ParseStringFlag(const char* str,
const char* flag,
std::string* value) {
// Gets the value of the flag as a string. // Gets the value of the flag as a string.
const char* const value_str = ParseFlagValue(str, flag, false); const char* const value_str = ParseFlagValue(str, flag, false);
...@@ -5248,7 +5232,7 @@ static const char kColorEncodedHelpMessage[] = ...@@ -5248,7 +5232,7 @@ static const char kColorEncodedHelpMessage[] =
"(not one in your own code or tests), please report it to\n" "(not one in your own code or tests), please report it to\n"
"@G<" GTEST_DEV_EMAIL_ ">@D.\n"; "@G<" GTEST_DEV_EMAIL_ ">@D.\n";
bool ParseGoogleTestFlag(const char* const arg) { static bool ParseGoogleTestFlag(const char* const arg) {
return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag, return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,
&GTEST_FLAG(also_run_disabled_tests)) || &GTEST_FLAG(also_run_disabled_tests)) ||
ParseBoolFlag(arg, kBreakOnFailureFlag, ParseBoolFlag(arg, kBreakOnFailureFlag,
...@@ -5278,14 +5262,12 @@ bool ParseGoogleTestFlag(const char* const arg) { ...@@ -5278,14 +5262,12 @@ bool ParseGoogleTestFlag(const char* const arg) {
} }
#if GTEST_USE_OWN_FLAGFILE_FLAG_ #if GTEST_USE_OWN_FLAGFILE_FLAG_
void LoadFlagsFromFile(const std::string& path) { static void LoadFlagsFromFile(const std::string& path) {
FILE* flagfile = posix::FOpen(path.c_str(), "r"); FILE* flagfile = posix::FOpen(path.c_str(), "r");
if (!flagfile) { if (!flagfile) {
fprintf(stderr, GTEST_LOG_(FATAL) << "Unable to open file \""
"Unable to open file \"%s\"\n", << GTEST_FLAG(flagfile)
GTEST_FLAG(flagfile).c_str()); << "\"";
fflush(stderr);
exit(EXIT_FAILURE);
} }
std::string contents(ReadEntireFile(flagfile)); std::string contents(ReadEntireFile(flagfile));
posix::FClose(flagfile); posix::FClose(flagfile);
......
...@@ -57,13 +57,15 @@ cc_test( ...@@ -57,13 +57,15 @@ cc_test(
"gtest-param-test_test.cc", "gtest-param-test_test.cc",
], ],
) + select({ ) + select({
"//:win": [], "//:windows": [],
"//:windows_msvc": [],
"//conditions:default": [ "//conditions:default": [
"gtest-tuple_test.cc", "gtest-tuple_test.cc",
], ],
}), }),
copts = select({ copts = select({
"//:win": ["-DGTEST_USE_OWN_TR1_TUPLE=0"], "//:windows": ["-DGTEST_USE_OWN_TR1_TUPLE=0"],
"//:windows_msvc": ["-DGTEST_USE_OWN_TR1_TUPLE=0"],
"//conditions:default": ["-DGTEST_USE_OWN_TR1_TUPLE=1"], "//conditions:default": ["-DGTEST_USE_OWN_TR1_TUPLE=1"],
}), }),
includes = [ includes = [
...@@ -73,7 +75,8 @@ cc_test( ...@@ -73,7 +75,8 @@ cc_test(
"googletest/test", "googletest/test",
], ],
linkopts = select({ linkopts = select({
"//:win": [], "//:windows": [],
"//:windows_msvc": [],
"//conditions:default": [ "//conditions:default": [
"-pthread", "-pthread",
], ],
......
...@@ -56,15 +56,7 @@ using testing::internal::AlwaysTrue; ...@@ -56,15 +56,7 @@ using testing::internal::AlwaysTrue;
# endif // GTEST_OS_LINUX # endif // GTEST_OS_LINUX
# include "gtest/gtest-spi.h" # include "gtest/gtest-spi.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
# define GTEST_IMPLEMENTATION_ 1
# include "src/gtest-internal-inl.h" # include "src/gtest-internal-inl.h"
# undef GTEST_IMPLEMENTATION_
namespace posix = ::testing::internal::posix; namespace posix = ::testing::internal::posix;
...@@ -313,14 +305,14 @@ void DieWithEmbeddedNul() { ...@@ -313,14 +305,14 @@ void DieWithEmbeddedNul() {
} }
# if GTEST_USES_PCRE # if GTEST_USES_PCRE
// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error // Tests that EXPECT_DEATH and ASSERT_DEATH work when the error
// message has a NUL character in it. // message has a NUL character in it.
TEST_F(TestForDeathTest, EmbeddedNulInMessage) { TEST_F(TestForDeathTest, EmbeddedNulInMessage) {
// TODO(wan@google.com): <regex.h> doesn't support matching strings
// with embedded NUL characters - find a way to workaround it.
EXPECT_DEATH(DieWithEmbeddedNul(), "my null world"); EXPECT_DEATH(DieWithEmbeddedNul(), "my null world");
ASSERT_DEATH(DieWithEmbeddedNul(), "my null world"); ASSERT_DEATH(DieWithEmbeddedNul(), "my null world");
} }
# endif // GTEST_USES_PCRE # endif // GTEST_USES_PCRE
// Tests that death test macros expand to code which interacts well with switch // Tests that death test macros expand to code which interacts well with switch
......
...@@ -27,28 +27,18 @@ ...@@ -27,28 +27,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// Authors: keith.ray@gmail.com (Keith Ray)
// //
// Google Test filepath utilities // Google Test filepath utilities
// //
// This file tests classes and functions used internally by // This file tests classes and functions used internally by
// Google Test. They are subject to change without notice. // Google Test. They are subject to change without notice.
// //
// This file is #included from gtest_unittest.cc, to avoid changing // This file is #included from gtest-internal.h.
// build or make-files for some existing Google Test clients. Do not // Do not #include this file anywhere else!
// #include this file anywhere else!
#include "gtest/internal/gtest-filepath.h" #include "gtest/internal/gtest-filepath.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_WINDOWS_MOBILE #if GTEST_OS_WINDOWS_MOBILE
# include <windows.h> // NOLINT # include <windows.h> // NOLINT
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// Authors: keith.ray@gmail.com (Keith Ray)
// //
// Google Test UnitTestOptions tests // Google Test UnitTestOptions tests
// //
...@@ -46,14 +45,7 @@ ...@@ -46,14 +45,7 @@
# include <direct.h> # include <direct.h>
#endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS_MOBILE
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
namespace internal { namespace internal {
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
#include "test/gtest-param-test_test.h" #include "test/gtest-param-test_test.h"
#if GTEST_HAS_PARAM_TEST
using ::testing::Values; using ::testing::Values;
using ::testing::internal::ParamGenerator; using ::testing::internal::ParamGenerator;
...@@ -62,4 +60,3 @@ INSTANTIATE_TEST_CASE_P(Sequence2, ...@@ -62,4 +60,3 @@ INSTANTIATE_TEST_CASE_P(Sequence2,
InstantiationInMultipleTranslaionUnitsTest, InstantiationInMultipleTranslaionUnitsTest,
Values(42*3, 42*4, 42*5)); Values(42*3, 42*4, 42*5));
#endif // GTEST_HAS_PARAM_TEST
...@@ -35,19 +35,13 @@ ...@@ -35,19 +35,13 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
# include <algorithm> # include <algorithm>
# include <iostream> # include <iostream>
# include <list> # include <list>
# include <sstream> # include <sstream>
# include <string> # include <string>
# include <vector> # include <vector>
// To include gtest-internal-inl.h.
# define GTEST_IMPLEMENTATION_ 1
# include "src/gtest-internal-inl.h" // for UnitTestOptions # include "src/gtest-internal-inl.h" // for UnitTestOptions
# undef GTEST_IMPLEMENTATION_
# include "test/gtest-param-test_test.h" # include "test/gtest-param-test_test.h"
...@@ -857,8 +851,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {} ...@@ -857,8 +851,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {}
INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, INSTANTIATE_TEST_CASE_P(CustomParamNameLambda,
CustomLambdaNamingTest, CustomLambdaNamingTest,
Values(std::string("LambdaName")), Values(std::string("LambdaName")),
[](const ::testing::TestParamInfo<std::string>& info) { [](const ::testing::TestParamInfo<std::string>& tpinfo) {
return info.param; return tpinfo.param;
}); });
#endif // GTEST_LANG_CXX11 #endif // GTEST_LANG_CXX11
...@@ -1025,31 +1019,19 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) { ...@@ -1025,31 +1019,19 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5)); INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));
#endif // GTEST_HAS_PARAM_TEST
TEST(CompileTest, CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined) {
#if GTEST_HAS_COMBINE && !GTEST_HAS_PARAM_TEST
FAIL() << "GTEST_HAS_COMBINE is defined while GTEST_HAS_PARAM_TEST is not\n"
#endif
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
#if GTEST_HAS_PARAM_TEST
// Used in TestGenerationTest test case. // Used in TestGenerationTest test case.
AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance()); AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
// Used in GeneratorEvaluationTest test case. Tests that the updated value // Used in GeneratorEvaluationTest test case. Tests that the updated value
// will be picked up for instantiating tests in GeneratorEvaluationTest. // will be picked up for instantiating tests in GeneratorEvaluationTest.
GeneratorEvaluationTest::set_param_value(1); GeneratorEvaluationTest::set_param_value(1);
#endif // GTEST_HAS_PARAM_TEST
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
#if GTEST_HAS_PARAM_TEST
// Used in GeneratorEvaluationTest test case. Tests that value updated // Used in GeneratorEvaluationTest test case. Tests that value updated
// here will NOT be used for instantiating tests in // here will NOT be used for instantiating tests in
// GeneratorEvaluationTest. // GeneratorEvaluationTest.
GeneratorEvaluationTest::set_param_value(2); GeneratorEvaluationTest::set_param_value(2);
#endif // GTEST_HAS_PARAM_TEST
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
// Test fixture for testing definition and instantiation of a test // Test fixture for testing definition and instantiation of a test
// in separate translation units. // in separate translation units.
class ExternalInstantiationTest : public ::testing::TestWithParam<int> { class ExternalInstantiationTest : public ::testing::TestWithParam<int> {
...@@ -52,6 +50,4 @@ class InstantiationInMultipleTranslaionUnitsTest ...@@ -52,6 +50,4 @@ class InstantiationInMultipleTranslaionUnitsTest
: public ::testing::TestWithParam<int> { : public ::testing::TestWithParam<int> {
}; };
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
...@@ -45,15 +45,7 @@ ...@@ -45,15 +45,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
using std::make_pair; using std::make_pair;
using std::pair; using std::pair;
...@@ -75,8 +67,8 @@ TEST(IsXDigitTest, WorksForNarrowAscii) { ...@@ -75,8 +67,8 @@ TEST(IsXDigitTest, WorksForNarrowAscii) {
} }
TEST(IsXDigitTest, ReturnsFalseForNarrowNonAscii) { TEST(IsXDigitTest, ReturnsFalseForNarrowNonAscii) {
EXPECT_FALSE(IsXDigit('\x80')); EXPECT_FALSE(IsXDigit(static_cast<char>(0x80)));
EXPECT_FALSE(IsXDigit(static_cast<char>('0' | '\x80'))); EXPECT_FALSE(IsXDigit(static_cast<char>('0' | 0x80)));
} }
TEST(IsXDigitTest, WorksForWideAscii) { TEST(IsXDigitTest, WorksForWideAscii) {
......
...@@ -51,10 +51,15 @@ ...@@ -51,10 +51,15 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
// hash_map and hash_set are available under Visual C++, or on Linux. // hash_map and hash_set are available under Visual C++, or on Linux.
#if GTEST_HAS_HASH_MAP_ #if GTEST_HAS_UNORDERED_MAP_
# include <unordered_map> // NOLINT
#elif GTEST_HAS_HASH_MAP_
# include <hash_map> // NOLINT # include <hash_map> // NOLINT
#endif // GTEST_HAS_HASH_MAP_ #endif // GTEST_HAS_HASH_MAP_
#if GTEST_HAS_HASH_SET_
#if GTEST_HAS_UNORDERED_SET_
# include <unordered_set> // NOLINT
#elif GTEST_HAS_HASH_SET_
# include <hash_set> // NOLINT # include <hash_set> // NOLINT
#endif // GTEST_HAS_HASH_SET_ #endif // GTEST_HAS_HASH_SET_
...@@ -239,21 +244,47 @@ using ::testing::internal::UniversalTersePrintTupleFieldsToStrings; ...@@ -239,21 +244,47 @@ using ::testing::internal::UniversalTersePrintTupleFieldsToStrings;
#endif #endif
using ::testing::internal::string; using ::testing::internal::string;
#if GTEST_HAS_HASH_MAP_
// The hash_* classes are not part of the C++ standard. STLport // The hash_* classes are not part of the C++ standard. STLport
// defines them in namespace std. MSVC defines them in ::stdext. GCC // defines them in namespace std. MSVC defines them in ::stdext. GCC
// defines them in ::. // defines them in ::.
#if GTEST_HAS_UNORDERED_MAP_
#define GTEST_HAS_HASH_MAP_ 1
template<class Key, class T>
using hash_map = ::std::unordered_map<Key, T>;
template<class Key, class T>
using hash_multimap = ::std::unordered_multimap<Key, T>;
#elif GTEST_HAS_HASH_MAP_
#ifdef _STLP_HASH_MAP // We got <hash_map> from STLport. #ifdef _STLP_HASH_MAP // We got <hash_map> from STLport.
using ::std::hash_map; using ::std::hash_map;
using ::std::hash_set;
using ::std::hash_multimap; using ::std::hash_multimap;
using ::std::hash_multiset;
#elif _MSC_VER #elif _MSC_VER
using ::stdext::hash_map; using ::stdext::hash_map;
using ::stdext::hash_set;
using ::stdext::hash_multimap; using ::stdext::hash_multimap;
#endif
#endif
#if GTEST_HAS_UNORDERED_SET_
#define GTEST_HAS_HASH_SET_ 1
template<class Key>
using hash_set = ::std::unordered_set<Key>;
template<class Key>
using hash_multiset = ::std::unordered_multiset<Key>;
#elif GTEST_HAS_HASH_SET_
#ifdef _STLP_HASH_MAP // We got <hash_map> from STLport.
using ::std::hash_set;
using ::std::hash_multiset;
#elif _MSC_VER
using ::stdext::hash_set;
using ::stdext::hash_multiset; using ::stdext::hash_multiset;
#endif #endif
#endif #endif
// Prints a value to a string using the universal value printer. This // Prints a value to a string using the universal value printer. This
...@@ -1061,8 +1092,8 @@ TEST(PrintTr1TupleTest, VariousSizes) { ...@@ -1061,8 +1092,8 @@ TEST(PrintTr1TupleTest, VariousSizes) {
::std::tr1::tuple<bool, char, short, testing::internal::Int32, // NOLINT ::std::tr1::tuple<bool, char, short, testing::internal::Int32, // NOLINT
testing::internal::Int64, float, double, const char*, void*, testing::internal::Int64, float, double, const char*, void*,
std::string> std::string>
t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, ImplicitCast_<void*>(NULL), t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str,
"10"); ImplicitCast_<void*>(NULL), "10");
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) + EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")", " pointing to \"8\", NULL, \"10\")",
Print(t10)); Print(t10));
...@@ -1121,8 +1152,8 @@ TEST(PrintStdTupleTest, VariousSizes) { ...@@ -1121,8 +1152,8 @@ TEST(PrintStdTupleTest, VariousSizes) {
::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT ::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT
testing::internal::Int64, float, double, const char*, void*, testing::internal::Int64, float, double, const char*, void*,
std::string> std::string>
t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, ImplicitCast_<void*>(NULL), t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str,
"10"); ImplicitCast_<void*>(NULL), "10");
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) + EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")", " pointing to \"8\", NULL, \"10\")",
Print(t10)); Print(t10));
......
...@@ -80,8 +80,7 @@ int main(int argc, char **argv) { ...@@ -80,8 +80,7 @@ int main(int argc, char **argv) {
SetUnhandledExceptionFilter(ExitWithExceptionCode); SetUnhandledExceptionFilter(ExitWithExceptionCode);
# endif # endif
#endif #endif // GTEST_OS_WINDOWS
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
......
...@@ -138,7 +138,7 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) { ...@@ -138,7 +138,7 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
} }
// Exceptions in destructors are not supported in C++11. // Exceptions in destructors are not supported in C++11.
#if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L && _MSC_VER < 1900 #if !GTEST_LANG_CXX11
class CxxExceptionInDestructorTest : public Test { class CxxExceptionInDestructorTest : public Test {
public: public:
static void TearDownTestCase() { static void TearDownTestCase() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment