Externals/GTest: Update to latest master
This commit is contained in:
parent
f3a18db9e0
commit
fe6e46f846
|
@ -44,9 +44,18 @@ endif()
|
||||||
# as ${gtest_SOURCE_DIR} and to the root binary directory as
|
# as ${gtest_SOURCE_DIR} and to the root binary directory as
|
||||||
# ${gtest_BINARY_DIR}.
|
# ${gtest_BINARY_DIR}.
|
||||||
# Language "C" is required for find_package(Threads).
|
# Language "C" is required for find_package(Threads).
|
||||||
project(gtest CXX C)
|
if (CMAKE_VERSION VERSION_LESS 3.0)
|
||||||
|
project(gtest CXX C)
|
||||||
|
else()
|
||||||
|
cmake_policy(SET CMP0048 NEW)
|
||||||
|
project(gtest VERSION 1.9.0 LANGUAGES CXX C)
|
||||||
|
endif()
|
||||||
cmake_minimum_required(VERSION 2.6.4)
|
cmake_minimum_required(VERSION 2.6.4)
|
||||||
|
|
||||||
|
if (POLICY CMP0063) # Visibility
|
||||||
|
cmake_policy(SET CMP0063 NEW)
|
||||||
|
endif (POLICY CMP0063)
|
||||||
|
|
||||||
if (COMMAND set_up_hermetic_build)
|
if (COMMAND set_up_hermetic_build)
|
||||||
set_up_hermetic_build()
|
set_up_hermetic_build()
|
||||||
endif()
|
endif()
|
||||||
|
@ -63,11 +72,8 @@ config_compiler_and_linker() # Defined in internal_utils.cmake.
|
||||||
|
|
||||||
# Where Google Test's .h files can be found.
|
# Where Google Test's .h files can be found.
|
||||||
include_directories(
|
include_directories(
|
||||||
${gtest_SOURCE_DIR}/include
|
"${gtest_SOURCE_DIR}/include"
|
||||||
${gtest_SOURCE_DIR})
|
"${gtest_SOURCE_DIR}")
|
||||||
|
|
||||||
# Where Google Test's libraries can be found.
|
|
||||||
link_directories(${gtest_BINARY_DIR}/src)
|
|
||||||
|
|
||||||
# Summary of tuple support for Microsoft Visual Studio:
|
# Summary of tuple support for Microsoft Visual Studio:
|
||||||
# Compiler version(MS) version(cmake) Support
|
# Compiler version(MS) version(cmake) Support
|
||||||
|
@ -75,6 +81,8 @@ link_directories(${gtest_BINARY_DIR}/src)
|
||||||
# <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple.
|
# <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple.
|
||||||
# VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10
|
# VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10
|
||||||
# VS 2013 12 1800 std::tr1::tuple
|
# VS 2013 12 1800 std::tr1::tuple
|
||||||
|
# VS 2015 14 1900 std::tuple
|
||||||
|
# VS 2017 15 >= 1910 std::tuple
|
||||||
if (MSVC AND MSVC_VERSION EQUAL 1700)
|
if (MSVC AND MSVC_VERSION EQUAL 1700)
|
||||||
add_definitions(/D _VARIADIC_MAX=10)
|
add_definitions(/D _VARIADIC_MAX=10)
|
||||||
endif()
|
endif()
|
||||||
|
@ -95,17 +103,33 @@ target_link_libraries(gtest_main gtest)
|
||||||
# to the targets for when we are part of a parent build (ie being pulled
|
# to the targets for when we are part of a parent build (ie being pulled
|
||||||
# in via add_subdirectory() rather than being a standalone build).
|
# in via add_subdirectory() rather than being a standalone build).
|
||||||
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
||||||
target_include_directories(gtest INTERFACE "${gtest_SOURCE_DIR}/include")
|
target_include_directories(gtest SYSTEM INTERFACE "${gtest_SOURCE_DIR}/include")
|
||||||
target_include_directories(gtest_main INTERFACE "${gtest_SOURCE_DIR}/include")
|
target_include_directories(gtest_main SYSTEM INTERFACE "${gtest_SOURCE_DIR}/include")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
#
|
#
|
||||||
# Install rules
|
# Install rules
|
||||||
install(TARGETS gtest gtest_main
|
if(INSTALL_GTEST)
|
||||||
DESTINATION lib)
|
install(TARGETS gtest gtest_main
|
||||||
install(DIRECTORY ${gtest_SOURCE_DIR}/include/gtest
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
DESTINATION include)
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
install(DIRECTORY "${gtest_SOURCE_DIR}/include/gtest"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
|
||||||
|
# configure and install pkgconfig files
|
||||||
|
configure_file(
|
||||||
|
cmake/gtest.pc.in
|
||||||
|
"${CMAKE_BINARY_DIR}/gtest.pc"
|
||||||
|
@ONLY)
|
||||||
|
configure_file(
|
||||||
|
cmake/gtest_main.pc.in
|
||||||
|
"${CMAKE_BINARY_DIR}/gtest_main.pc"
|
||||||
|
@ONLY)
|
||||||
|
install(FILES "${CMAKE_BINARY_DIR}/gtest.pc" "${CMAKE_BINARY_DIR}/gtest_main.pc"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||||
|
endif()
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
#
|
#
|
||||||
|
@ -280,7 +304,9 @@ if (gtest_build_tests)
|
||||||
cxx_executable(gtest_xml_outfile1_test_ test gtest_main)
|
cxx_executable(gtest_xml_outfile1_test_ test gtest_main)
|
||||||
cxx_executable(gtest_xml_outfile2_test_ test gtest_main)
|
cxx_executable(gtest_xml_outfile2_test_ test gtest_main)
|
||||||
py_test(gtest_xml_outfiles_test)
|
py_test(gtest_xml_outfiles_test)
|
||||||
|
py_test(gtest_json_outfiles_test)
|
||||||
|
|
||||||
cxx_executable(gtest_xml_output_unittest_ test gtest)
|
cxx_executable(gtest_xml_output_unittest_ test gtest)
|
||||||
py_test(gtest_xml_output_unittest)
|
py_test(gtest_xml_output_unittest)
|
||||||
|
py_test(gtest_json_output_unittest)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||||
|
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||||
|
|
||||||
|
Name: gtest
|
||||||
|
Description: GoogleTest (without main() function)
|
||||||
|
Version: @PROJECT_VERSION@
|
||||||
|
URL: https://github.com/google/googletest
|
||||||
|
Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@
|
||||||
|
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@
|
|
@ -0,0 +1,10 @@
|
||||||
|
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||||
|
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||||
|
|
||||||
|
Name: gtest_main
|
||||||
|
Description: GoogleTest (with main() function)
|
||||||
|
Version: @PROJECT_VERSION@
|
||||||
|
URL: https://github.com/google/googletest
|
||||||
|
Requires: gtest
|
||||||
|
Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@
|
||||||
|
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@
|
|
@ -48,9 +48,14 @@ endmacro()
|
||||||
macro(config_compiler_and_linker)
|
macro(config_compiler_and_linker)
|
||||||
# Note: pthreads on MinGW is not supported, even if available
|
# Note: pthreads on MinGW is not supported, even if available
|
||||||
# instead, we use windows threading primitives
|
# instead, we use windows threading primitives
|
||||||
|
unset(GTEST_HAS_PTHREAD)
|
||||||
if (NOT gtest_disable_pthreads AND NOT MINGW)
|
if (NOT gtest_disable_pthreads AND NOT MINGW)
|
||||||
# Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
|
# Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
|
||||||
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
|
if (CMAKE_USE_PTHREADS_INIT)
|
||||||
|
set(GTEST_HAS_PTHREAD ON)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
fix_default_compiler_settings_()
|
fix_default_compiler_settings_()
|
||||||
|
@ -81,17 +86,18 @@ macro(config_compiler_and_linker)
|
||||||
# Suppress "unreachable code" warning on VS 2012 and later.
|
# Suppress "unreachable code" warning on VS 2012 and later.
|
||||||
# http://stackoverflow.com/questions/3232669 explains the issue.
|
# http://stackoverflow.com/questions/3232669 explains the issue.
|
||||||
set(cxx_base_flags "${cxx_base_flags} -wd4702")
|
set(cxx_base_flags "${cxx_base_flags} -wd4702")
|
||||||
# BigObj required for tests.
|
|
||||||
set(cxx_base_flags "${cxx_base_flags} -bigobj")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
|
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_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
|
||||||
set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
|
set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
|
||||||
set(cxx_no_exception_flags "-D_HAS_EXCEPTIONS=0")
|
set(cxx_no_exception_flags "-EHs-c- -D_HAS_EXCEPTIONS=0")
|
||||||
set(cxx_no_rtti_flags "-GR-")
|
set(cxx_no_rtti_flags "-GR-")
|
||||||
elseif (CMAKE_COMPILER_IS_GNUCXX)
|
elseif (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(cxx_base_flags "-Wall -Wshadow")
|
set(cxx_base_flags "-Wall -Wshadow -Werror")
|
||||||
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)
|
||||||
|
set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else")
|
||||||
|
endif()
|
||||||
set(cxx_exception_flags "-fexceptions")
|
set(cxx_exception_flags "-fexceptions")
|
||||||
set(cxx_no_exception_flags "-fno-exceptions")
|
set(cxx_no_exception_flags "-fno-exceptions")
|
||||||
# Until version 4.3.2, GCC doesn't define a macro to indicate
|
# Until version 4.3.2, GCC doesn't define a macro to indicate
|
||||||
|
@ -123,11 +129,13 @@ macro(config_compiler_and_linker)
|
||||||
set(cxx_no_rtti_flags "")
|
set(cxx_no_rtti_flags "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_USE_PTHREADS_INIT) # The pthreads library is available and allowed.
|
# The pthreads library is available and allowed?
|
||||||
set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=1")
|
if (DEFINED GTEST_HAS_PTHREAD)
|
||||||
|
set(GTEST_HAS_PTHREAD_MACRO "-DGTEST_HAS_PTHREAD=1")
|
||||||
else()
|
else()
|
||||||
set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=0")
|
set(GTEST_HAS_PTHREAD_MACRO "-DGTEST_HAS_PTHREAD=0")
|
||||||
endif()
|
endif()
|
||||||
|
set(cxx_base_flags "${cxx_base_flags} ${GTEST_HAS_PTHREAD_MACRO}")
|
||||||
|
|
||||||
# For building gtest's own tests and samples.
|
# For building gtest's own tests and samples.
|
||||||
set(cxx_exception "${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_exception_flags}")
|
set(cxx_exception "${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_exception_flags}")
|
||||||
|
@ -150,12 +158,16 @@ function(cxx_library_with_type name type cxx_flags)
|
||||||
set_target_properties(${name}
|
set_target_properties(${name}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
COMPILE_FLAGS "${cxx_flags}")
|
COMPILE_FLAGS "${cxx_flags}")
|
||||||
|
# Generate debug library name with a postfix.
|
||||||
|
set_target_properties(${name}
|
||||||
|
PROPERTIES
|
||||||
|
DEBUG_POSTFIX "d")
|
||||||
if (BUILD_SHARED_LIBS OR type STREQUAL "SHARED")
|
if (BUILD_SHARED_LIBS OR type STREQUAL "SHARED")
|
||||||
set_target_properties(${name}
|
set_target_properties(${name}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
|
COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
|
||||||
endif()
|
endif()
|
||||||
if (CMAKE_USE_PTHREADS_INIT)
|
if (DEFINED GTEST_HAS_PTHREAD)
|
||||||
target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -178,6 +190,10 @@ endfunction()
|
||||||
# is built from the given source files with the given compiler flags.
|
# is built from the given source files with the given compiler flags.
|
||||||
function(cxx_executable_with_flags name cxx_flags libs)
|
function(cxx_executable_with_flags name cxx_flags libs)
|
||||||
add_executable(${name} ${ARGN})
|
add_executable(${name} ${ARGN})
|
||||||
|
if (MSVC AND (NOT (MSVC_VERSION LESS 1700))) # 1700 is Visual Studio 2012.
|
||||||
|
# BigObj required for tests.
|
||||||
|
set(cxx_flags "${cxx_flags} -bigobj")
|
||||||
|
endif()
|
||||||
if (cxx_flags)
|
if (cxx_flags)
|
||||||
set_target_properties(${name}
|
set_target_properties(${name}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
|
@ -232,23 +248,33 @@ endfunction()
|
||||||
# creates a Python test with the given name whose main module is in
|
# creates a Python test with the given name whose main module is in
|
||||||
# test/name.py. It does nothing if Python is not installed.
|
# test/name.py. It does nothing if Python is not installed.
|
||||||
function(py_test name)
|
function(py_test name)
|
||||||
# We are not supporting Python tests on Linux yet as they consider
|
|
||||||
# all Linux environments to be google3 and try to use google3 features.
|
|
||||||
if (PYTHONINTERP_FOUND)
|
if (PYTHONINTERP_FOUND)
|
||||||
# ${CMAKE_BINARY_DIR} is known at configuration time, so we can
|
|
||||||
# directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
|
|
||||||
# only at ctest runtime (by calling ctest -c <Configuration>), so
|
|
||||||
# we have to escape $ to delay variable substitution here.
|
|
||||||
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
|
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
|
||||||
|
if (CMAKE_CONFIGURATION_TYPES)
|
||||||
|
# Multi-configuration build generators as for Visual Studio save
|
||||||
|
# output in a subdirectory of CMAKE_CURRENT_BINARY_DIR (Debug,
|
||||||
|
# Release etc.), so we have to provide it here.
|
||||||
add_test(
|
add_test(
|
||||||
NAME ${name}
|
NAME ${name}
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
||||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
|
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
|
||||||
|
else (CMAKE_CONFIGURATION_TYPES)
|
||||||
|
# Single-configuration build generators like Makefile generators
|
||||||
|
# don't have subdirs below CMAKE_CURRENT_BINARY_DIR.
|
||||||
|
add_test(
|
||||||
|
NAME ${name}
|
||||||
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
||||||
|
--build_dir=${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
endif (CMAKE_CONFIGURATION_TYPES)
|
||||||
else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
|
else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
|
||||||
|
# ${CMAKE_CURRENT_BINARY_DIR} is known at configuration time, so we can
|
||||||
|
# directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
|
||||||
|
# only at ctest runtime (by calling ctest -c <Configuration>), so
|
||||||
|
# we have to escape $ to delay variable substitution here.
|
||||||
add_test(
|
add_test(
|
||||||
${name}
|
${name}
|
||||||
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
||||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE})
|
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE})
|
||||||
endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
|
endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
|
||||||
endif()
|
endif(PYTHONINTERP_FOUND)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
//
|
//
|
||||||
// Author: wan@google.com (Zhanyong Wan)
|
// Author: wan@google.com (Zhanyong Wan)
|
||||||
//
|
//
|
||||||
// The Google C++ Testing Framework (Google Test)
|
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||||
//
|
//
|
||||||
// This header file defines the public API for death tests. It is
|
// This header file defines the public API for death tests. It is
|
||||||
// #included by gtest.h so a user doesn't need to include this
|
// #included by gtest.h so a user doesn't need to include this
|
||||||
|
@ -102,7 +102,7 @@ GTEST_API_ bool InDeathTestChild();
|
||||||
// On POSIX-compliant systems (*nix), we use the <regex.h> library,
|
// On POSIX-compliant systems (*nix), we use the <regex.h> library,
|
||||||
// which uses the POSIX extended regex syntax.
|
// which uses the POSIX extended regex syntax.
|
||||||
//
|
//
|
||||||
// On other platforms (e.g. Windows), we only support a simple regex
|
// On other platforms (e.g. Windows or Mac), we only support a simple regex
|
||||||
// syntax implemented as part of Google Test. This limited
|
// syntax implemented as part of Google Test. This limited
|
||||||
// implementation should be enough most of the time when writing
|
// implementation should be enough most of the time when writing
|
||||||
// death tests; though it lacks many features you can find in PCRE
|
// death tests; though it lacks many features you can find in PCRE
|
||||||
|
@ -198,7 +198,7 @@ class GTEST_API_ ExitedWithCode {
|
||||||
const int exit_code_;
|
const int exit_code_;
|
||||||
};
|
};
|
||||||
|
|
||||||
# if !GTEST_OS_WINDOWS
|
# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
|
||||||
// Tests that an exit code describes an exit due to termination by a
|
// Tests that an exit code describes an exit due to termination by a
|
||||||
// given signal.
|
// given signal.
|
||||||
class GTEST_API_ KilledBySignal {
|
class GTEST_API_ KilledBySignal {
|
||||||
|
@ -272,6 +272,54 @@ class GTEST_API_ KilledBySignal {
|
||||||
# endif // NDEBUG for EXPECT_DEBUG_DEATH
|
# endif // NDEBUG for EXPECT_DEBUG_DEATH
|
||||||
#endif // GTEST_HAS_DEATH_TEST
|
#endif // GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
|
// This macro is used for implementing macros such as
|
||||||
|
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
|
||||||
|
// death tests are not supported. Those macros must compile on such systems
|
||||||
|
// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
|
||||||
|
// systems that support death tests. This allows one to write such a macro
|
||||||
|
// on a system that does not support death tests and be sure that it will
|
||||||
|
// compile on a death-test supporting system. It is exposed publicly so that
|
||||||
|
// systems that have death-tests with stricter requirements than
|
||||||
|
// GTEST_HAS_DEATH_TEST can write their own equivalent of
|
||||||
|
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED.
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// statement - A statement that a macro such as EXPECT_DEATH would test
|
||||||
|
// for program termination. This macro has to make sure this
|
||||||
|
// statement is compiled but not executed, to ensure that
|
||||||
|
// EXPECT_DEATH_IF_SUPPORTED compiles with a certain
|
||||||
|
// parameter iff EXPECT_DEATH compiles with it.
|
||||||
|
// regex - A regex that a macro such as EXPECT_DEATH would use to test
|
||||||
|
// the output of statement. This parameter has to be
|
||||||
|
// compiled but not evaluated by this macro, to ensure that
|
||||||
|
// this macro only accepts expressions that a macro such as
|
||||||
|
// EXPECT_DEATH would accept.
|
||||||
|
// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
|
||||||
|
// and a return statement for ASSERT_DEATH_IF_SUPPORTED.
|
||||||
|
// This ensures that ASSERT_DEATH_IF_SUPPORTED will not
|
||||||
|
// compile inside functions where ASSERT_DEATH doesn't
|
||||||
|
// compile.
|
||||||
|
//
|
||||||
|
// The branch that has an always false condition is used to ensure that
|
||||||
|
// statement and regex are compiled (and thus syntactically correct) but
|
||||||
|
// never executed. The unreachable code macro protects the terminator
|
||||||
|
// statement from generating an 'unreachable code' warning in case
|
||||||
|
// statement unconditionally returns or throws. The Message constructor at
|
||||||
|
// the end allows the syntax of streaming additional messages into the
|
||||||
|
// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
|
||||||
|
# define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \
|
||||||
|
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||||
|
if (::testing::internal::AlwaysTrue()) { \
|
||||||
|
GTEST_LOG_(WARNING) \
|
||||||
|
<< "Death tests are not supported on this platform.\n" \
|
||||||
|
<< "Statement '" #statement "' cannot be verified."; \
|
||||||
|
} else if (::testing::internal::AlwaysFalse()) { \
|
||||||
|
::testing::internal::RE::PartialMatch(".*", (regex)); \
|
||||||
|
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||||
|
terminator; \
|
||||||
|
} else \
|
||||||
|
::testing::Message()
|
||||||
|
|
||||||
// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
|
// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
|
||||||
// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
|
// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
|
||||||
// death tests are supported; otherwise they just issue a warning. This is
|
// death tests are supported; otherwise they just issue a warning. This is
|
||||||
|
@ -284,9 +332,9 @@ class GTEST_API_ KilledBySignal {
|
||||||
ASSERT_DEATH(statement, regex)
|
ASSERT_DEATH(statement, regex)
|
||||||
#else
|
#else
|
||||||
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||||
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
|
GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )
|
||||||
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||||
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)
|
GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
//
|
//
|
||||||
// Author: wan@google.com (Zhanyong Wan)
|
// Author: wan@google.com (Zhanyong Wan)
|
||||||
//
|
//
|
||||||
// The Google C++ Testing Framework (Google Test)
|
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||||
//
|
//
|
||||||
// This header file defines the Message class.
|
// This header file defines the Message class.
|
||||||
//
|
//
|
||||||
|
@ -196,7 +196,6 @@ class GTEST_API_ Message {
|
||||||
std::string GetString() const;
|
std::string GetString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#if GTEST_OS_SYMBIAN
|
#if GTEST_OS_SYMBIAN
|
||||||
// These are needed as the Nokia Symbian Compiler cannot decide between
|
// These are needed as the Nokia Symbian Compiler cannot decide between
|
||||||
// const T& and const T* in a function template. The Nokia compiler _can_
|
// const T& and const T* in a function template. The Nokia compiler _can_
|
||||||
|
|
|
@ -34,10 +34,11 @@
|
||||||
// Authors: vladl@google.com (Vlad Losev)
|
// Authors: vladl@google.com (Vlad Losev)
|
||||||
//
|
//
|
||||||
// Macros and functions for implementing parameterized tests
|
// Macros and functions for implementing parameterized tests
|
||||||
// in Google C++ Testing Framework (Google Test)
|
// in Google C++ Testing and Mocking Framework (Google Test)
|
||||||
//
|
//
|
||||||
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
||||||
|
|
||||||
|
@ -185,15 +186,10 @@ TEST_P(DerivedTest, DoesBlah) {
|
||||||
# include <utility>
|
# include <utility>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// scripts/fuse_gtest.py depends on gtest's own header being #included
|
|
||||||
// *unconditionally*. Therefore these #includes cannot be moved
|
|
||||||
// inside #if GTEST_HAS_PARAM_TEST.
|
|
||||||
#include "gtest/internal/gtest-internal.h"
|
#include "gtest/internal/gtest-internal.h"
|
||||||
#include "gtest/internal/gtest-param-util.h"
|
#include "gtest/internal/gtest-param-util.h"
|
||||||
#include "gtest/internal/gtest-param-util-generated.h"
|
#include "gtest/internal/gtest-param-util-generated.h"
|
||||||
|
|
||||||
#if GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
// Functions producing parameter generators.
|
// Functions producing parameter generators.
|
||||||
|
@ -273,7 +269,7 @@ internal::ParamGenerator<T> Range(T start, T end) {
|
||||||
// each with C-string values of "foo", "bar", and "baz":
|
// each with C-string values of "foo", "bar", and "baz":
|
||||||
//
|
//
|
||||||
// const char* strings[] = {"foo", "bar", "baz"};
|
// const char* strings[] = {"foo", "bar", "baz"};
|
||||||
// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));
|
// INSTANTIATE_TEST_CASE_P(StringSequence, StringTest, ValuesIn(strings));
|
||||||
//
|
//
|
||||||
// This instantiates tests from test case StlStringTest
|
// This instantiates tests from test case StlStringTest
|
||||||
// each with STL strings with values "a" and "b":
|
// each with STL strings with values "a" and "b":
|
||||||
|
@ -1375,8 +1371,6 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
|
||||||
}
|
}
|
||||||
# endif // GTEST_HAS_COMBINE
|
# endif // GTEST_HAS_COMBINE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# define TEST_P(test_case_name, test_name) \
|
# define TEST_P(test_case_name, test_name) \
|
||||||
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
|
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
|
||||||
: public test_case_name { \
|
: public test_case_name { \
|
||||||
|
@ -1390,8 +1384,8 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
|
||||||
#test_case_name, \
|
#test_case_name, \
|
||||||
::testing::internal::CodeLocation(\
|
::testing::internal::CodeLocation(\
|
||||||
__FILE__, __LINE__))->AddTestPattern(\
|
__FILE__, __LINE__))->AddTestPattern(\
|
||||||
#test_case_name, \
|
GTEST_STRINGIFY_(test_case_name), \
|
||||||
#test_name, \
|
GTEST_STRINGIFY_(test_name), \
|
||||||
new ::testing::internal::TestMetaFactory< \
|
new ::testing::internal::TestMetaFactory< \
|
||||||
GTEST_TEST_CLASS_NAME_(\
|
GTEST_TEST_CLASS_NAME_(\
|
||||||
test_case_name, test_name)>()); \
|
test_case_name, test_name)>()); \
|
||||||
|
@ -1412,33 +1406,33 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
|
||||||
// type testing::TestParamInfo<class ParamType>, and return std::string.
|
// type testing::TestParamInfo<class ParamType>, and return std::string.
|
||||||
//
|
//
|
||||||
// testing::PrintToStringParamName is a builtin test suffix generator that
|
// testing::PrintToStringParamName is a builtin test suffix generator that
|
||||||
// returns the value of testing::PrintToString(GetParam()). It does not work
|
// returns the value of testing::PrintToString(GetParam()).
|
||||||
// for std::string or C strings.
|
|
||||||
//
|
//
|
||||||
// Note: test names must be non-empty, unique, and may only contain ASCII
|
// Note: test names must be non-empty, unique, and may only contain ASCII
|
||||||
// alphanumeric characters or underscore.
|
// alphanumeric characters or underscore. Because PrintToString adds quotes
|
||||||
|
// to std::string and C strings, it won't work for these types.
|
||||||
|
|
||||||
# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \
|
#define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \
|
||||||
::testing::internal::ParamGenerator<test_case_name::ParamType> \
|
static ::testing::internal::ParamGenerator<test_case_name::ParamType> \
|
||||||
gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
|
gtest_##prefix##test_case_name##_EvalGenerator_() { \
|
||||||
::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \
|
return generator; \
|
||||||
const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \
|
|
||||||
return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \
|
|
||||||
(__VA_ARGS__)(info); \
|
|
||||||
} \
|
} \
|
||||||
int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \
|
static ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \
|
||||||
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
|
const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \
|
||||||
GetTestCasePatternHolder<test_case_name>(\
|
return ::testing::internal::GetParamNameGen<test_case_name::ParamType>( \
|
||||||
|
__VA_ARGS__)(info); \
|
||||||
|
} \
|
||||||
|
static int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \
|
||||||
|
::testing::UnitTest::GetInstance() \
|
||||||
|
->parameterized_test_registry() \
|
||||||
|
.GetTestCasePatternHolder<test_case_name>( \
|
||||||
#test_case_name, \
|
#test_case_name, \
|
||||||
::testing::internal::CodeLocation(\
|
::testing::internal::CodeLocation(__FILE__, __LINE__)) \
|
||||||
__FILE__, __LINE__))->AddTestCaseInstantiation(\
|
->AddTestCaseInstantiation( \
|
||||||
#prefix, \
|
#prefix, >est_##prefix##test_case_name##_EvalGenerator_, \
|
||||||
>est_##prefix##test_case_name##_EvalGenerator_, \
|
>est_##prefix##test_case_name##_EvalGenerateName_, __FILE__, \
|
||||||
>est_##prefix##test_case_name##_EvalGenerateName_, \
|
__LINE__)
|
||||||
__FILE__, __LINE__)
|
|
||||||
|
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
|
||||||
#endif // GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
||||||
|
|
|
@ -33,7 +33,7 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
|
||||||
// Authors: vladl@google.com (Vlad Losev)
|
// Authors: vladl@google.com (Vlad Losev)
|
||||||
//
|
//
|
||||||
// Macros and functions for implementing parameterized tests
|
// Macros and functions for implementing parameterized tests
|
||||||
// in Google C++ Testing Framework (Google Test)
|
// in Google C++ Testing and Mocking Framework (Google Test)
|
||||||
//
|
//
|
||||||
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
||||||
//
|
//
|
||||||
|
@ -184,15 +184,10 @@ TEST_P(DerivedTest, DoesBlah) {
|
||||||
# include <utility>
|
# include <utility>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// scripts/fuse_gtest.py depends on gtest's own header being #included
|
|
||||||
// *unconditionally*. Therefore these #includes cannot be moved
|
|
||||||
// inside #if GTEST_HAS_PARAM_TEST.
|
|
||||||
#include "gtest/internal/gtest-internal.h"
|
#include "gtest/internal/gtest-internal.h"
|
||||||
#include "gtest/internal/gtest-param-util.h"
|
#include "gtest/internal/gtest-param-util.h"
|
||||||
#include "gtest/internal/gtest-param-util-generated.h"
|
#include "gtest/internal/gtest-param-util-generated.h"
|
||||||
|
|
||||||
#if GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
// Functions producing parameter generators.
|
// Functions producing parameter generators.
|
||||||
|
@ -272,7 +267,7 @@ internal::ParamGenerator<T> Range(T start, T end) {
|
||||||
// each with C-string values of "foo", "bar", and "baz":
|
// each with C-string values of "foo", "bar", and "baz":
|
||||||
//
|
//
|
||||||
// const char* strings[] = {"foo", "bar", "baz"};
|
// const char* strings[] = {"foo", "bar", "baz"};
|
||||||
// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));
|
// INSTANTIATE_TEST_CASE_P(StringSequence, StringTest, ValuesIn(strings));
|
||||||
//
|
//
|
||||||
// This instantiates tests from test case StlStringTest
|
// This instantiates tests from test case StlStringTest
|
||||||
// each with STL strings with values "a" and "b":
|
// each with STL strings with values "a" and "b":
|
||||||
|
@ -441,8 +436,6 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
|
||||||
]]
|
]]
|
||||||
# endif // GTEST_HAS_COMBINE
|
# endif // GTEST_HAS_COMBINE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# define TEST_P(test_case_name, test_name) \
|
# define TEST_P(test_case_name, test_name) \
|
||||||
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
|
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
|
||||||
: public test_case_name { \
|
: public test_case_name { \
|
||||||
|
@ -456,8 +449,8 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
|
||||||
#test_case_name, \
|
#test_case_name, \
|
||||||
::testing::internal::CodeLocation(\
|
::testing::internal::CodeLocation(\
|
||||||
__FILE__, __LINE__))->AddTestPattern(\
|
__FILE__, __LINE__))->AddTestPattern(\
|
||||||
#test_case_name, \
|
GTEST_STRINGIFY_(test_case_name), \
|
||||||
#test_name, \
|
GTEST_STRINGIFY_(test_name), \
|
||||||
new ::testing::internal::TestMetaFactory< \
|
new ::testing::internal::TestMetaFactory< \
|
||||||
GTEST_TEST_CLASS_NAME_(\
|
GTEST_TEST_CLASS_NAME_(\
|
||||||
test_case_name, test_name)>()); \
|
test_case_name, test_name)>()); \
|
||||||
|
@ -485,14 +478,14 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
|
||||||
// to std::string and C strings, it won't work for these types.
|
// to std::string and C strings, it won't work for these types.
|
||||||
|
|
||||||
# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \
|
# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \
|
||||||
::testing::internal::ParamGenerator<test_case_name::ParamType> \
|
static ::testing::internal::ParamGenerator<test_case_name::ParamType> \
|
||||||
gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
|
gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
|
||||||
::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \
|
static ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \
|
||||||
const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \
|
const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \
|
||||||
return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \
|
return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \
|
||||||
(__VA_ARGS__)(info); \
|
(__VA_ARGS__)(info); \
|
||||||
} \
|
} \
|
||||||
int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \
|
static int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \
|
||||||
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
|
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
|
||||||
GetTestCasePatternHolder<test_case_name>(\
|
GetTestCasePatternHolder<test_case_name>(\
|
||||||
#test_case_name, \
|
#test_case_name, \
|
||||||
|
@ -505,6 +498,4 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
|
||||||
|
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
|
||||||
#endif // GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
//
|
//
|
||||||
// Author: wan@google.com (Zhanyong Wan)
|
// Author: wan@google.com (Zhanyong Wan)
|
||||||
|
|
||||||
// Google Test - The Google C++ Testing Framework
|
// Google Test - The Google C++ Testing and Mocking Framework
|
||||||
//
|
//
|
||||||
// This file implements a universal value printer that can print a
|
// This file implements a universal value printer that can print a
|
||||||
// value of any type T:
|
// value of any type T:
|
||||||
|
@ -46,6 +46,10 @@
|
||||||
// 2. operator<<(ostream&, const T&) defined in either foo or the
|
// 2. operator<<(ostream&, const T&) defined in either foo or the
|
||||||
// global namespace.
|
// global namespace.
|
||||||
//
|
//
|
||||||
|
// However if T is an STL-style container then it is printed element-wise
|
||||||
|
// unless foo::PrintTo(const T&, ostream*) is defined. Note that
|
||||||
|
// operator<<() is ignored for container types.
|
||||||
|
//
|
||||||
// If none of the above is defined, it will print the debug string of
|
// If none of the above is defined, it will print the debug string of
|
||||||
// the value if it is a protocol buffer, or print the raw bytes in the
|
// the value if it is a protocol buffer, or print the raw bytes in the
|
||||||
// value otherwise.
|
// value otherwise.
|
||||||
|
@ -107,6 +111,11 @@
|
||||||
# include <tuple>
|
# include <tuple>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GTEST_HAS_ABSL
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
|
#include "absl/types/optional.h"
|
||||||
|
#endif // GTEST_HAS_ABSL
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
// Definitions in the 'internal' and 'internal2' name spaces are
|
// Definitions in the 'internal' and 'internal2' name spaces are
|
||||||
|
@ -125,6 +134,10 @@ enum TypeKind {
|
||||||
kProtobuf, // a protobuf type
|
kProtobuf, // a protobuf type
|
||||||
kConvertibleToInteger, // a type implicitly convertible to BiggestInt
|
kConvertibleToInteger, // a type implicitly convertible to BiggestInt
|
||||||
// (e.g. a named or unnamed enum type)
|
// (e.g. a named or unnamed enum type)
|
||||||
|
#if GTEST_HAS_ABSL
|
||||||
|
kConvertibleToStringView, // a type implicitly convertible to
|
||||||
|
// absl::string_view
|
||||||
|
#endif
|
||||||
kOtherType // anything else
|
kOtherType // anything else
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -137,7 +150,8 @@ class TypeWithoutFormatter {
|
||||||
public:
|
public:
|
||||||
// This default version is called when kTypeKind is kOtherType.
|
// This default version is called when kTypeKind is kOtherType.
|
||||||
static void PrintValue(const T& value, ::std::ostream* os) {
|
static void PrintValue(const T& value, ::std::ostream* os) {
|
||||||
PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value),
|
PrintBytesInObjectTo(static_cast<const unsigned char*>(
|
||||||
|
reinterpret_cast<const void*>(&value)),
|
||||||
sizeof(value), os);
|
sizeof(value), os);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -151,10 +165,10 @@ template <typename T>
|
||||||
class TypeWithoutFormatter<T, kProtobuf> {
|
class TypeWithoutFormatter<T, kProtobuf> {
|
||||||
public:
|
public:
|
||||||
static void PrintValue(const T& value, ::std::ostream* os) {
|
static void PrintValue(const T& value, ::std::ostream* os) {
|
||||||
const ::testing::internal::string short_str = value.ShortDebugString();
|
std::string pretty_str = value.ShortDebugString();
|
||||||
const ::testing::internal::string pretty_str =
|
if (pretty_str.length() > kProtobufOneLinerMaxLength) {
|
||||||
short_str.length() <= kProtobufOneLinerMaxLength ?
|
pretty_str = "\n" + value.DebugString();
|
||||||
short_str : ("\n" + value.DebugString());
|
}
|
||||||
*os << ("<" + pretty_str + ">");
|
*os << ("<" + pretty_str + ">");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -175,6 +189,19 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if GTEST_HAS_ABSL
|
||||||
|
template <typename T>
|
||||||
|
class TypeWithoutFormatter<T, kConvertibleToStringView> {
|
||||||
|
public:
|
||||||
|
// Since T has neither operator<< nor PrintTo() but can be implicitly
|
||||||
|
// converted to absl::string_view, we print it as a absl::string_view.
|
||||||
|
//
|
||||||
|
// Note: the implementation is further below, as it depends on
|
||||||
|
// internal::PrintTo symbol which is defined later in the file.
|
||||||
|
static void PrintValue(const T& value, ::std::ostream* os);
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// Prints the given value to the given ostream. If the value is a
|
// Prints the given value to the given ostream. If the value is a
|
||||||
// protocol message, its debug string is printed; if it's an enum or
|
// protocol message, its debug string is printed; if it's an enum or
|
||||||
// of a type implicitly convertible to BiggestInt, it's printed as an
|
// of a type implicitly convertible to BiggestInt, it's printed as an
|
||||||
|
@ -202,10 +229,19 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> {
|
||||||
template <typename Char, typename CharTraits, typename T>
|
template <typename Char, typename CharTraits, typename T>
|
||||||
::std::basic_ostream<Char, CharTraits>& operator<<(
|
::std::basic_ostream<Char, CharTraits>& operator<<(
|
||||||
::std::basic_ostream<Char, CharTraits>& os, const T& x) {
|
::std::basic_ostream<Char, CharTraits>& os, const T& x) {
|
||||||
TypeWithoutFormatter<T,
|
TypeWithoutFormatter<T, (internal::IsAProtocolMessage<T>::value
|
||||||
(internal::IsAProtocolMessage<T>::value ? kProtobuf :
|
? kProtobuf
|
||||||
internal::ImplicitlyConvertible<const T&, internal::BiggestInt>::value ?
|
: internal::ImplicitlyConvertible<
|
||||||
kConvertibleToInteger : kOtherType)>::PrintValue(x, &os);
|
const T&, internal::BiggestInt>::value
|
||||||
|
? kConvertibleToInteger
|
||||||
|
:
|
||||||
|
#if GTEST_HAS_ABSL
|
||||||
|
internal::ImplicitlyConvertible<
|
||||||
|
const T&, absl::string_view>::value
|
||||||
|
? kConvertibleToStringView
|
||||||
|
:
|
||||||
|
#endif
|
||||||
|
kOtherType)>::PrintValue(x, &os);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,11 +400,18 @@ class UniversalPrinter;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void UniversalPrint(const T& value, ::std::ostream* os);
|
void UniversalPrint(const T& value, ::std::ostream* os);
|
||||||
|
|
||||||
|
enum DefaultPrinterType {
|
||||||
|
kPrintContainer,
|
||||||
|
kPrintPointer,
|
||||||
|
kPrintFunctionPointer,
|
||||||
|
kPrintOther,
|
||||||
|
};
|
||||||
|
template <DefaultPrinterType type> struct WrapPrinterType {};
|
||||||
|
|
||||||
// Used to print an STL-style container when the user doesn't define
|
// Used to print an STL-style container when the user doesn't define
|
||||||
// a PrintTo() for it.
|
// a PrintTo() for it.
|
||||||
template <typename C>
|
template <typename C>
|
||||||
void DefaultPrintTo(IsContainer /* dummy */,
|
void DefaultPrintTo(WrapPrinterType<kPrintContainer> /* dummy */,
|
||||||
false_type /* is not a pointer */,
|
|
||||||
const C& container, ::std::ostream* os) {
|
const C& container, ::std::ostream* os) {
|
||||||
const size_t kMaxCount = 32; // The maximum number of elements to print.
|
const size_t kMaxCount = 32; // The maximum number of elements to print.
|
||||||
*os << '{';
|
*os << '{';
|
||||||
|
@ -401,40 +444,34 @@ void DefaultPrintTo(IsContainer /* dummy */,
|
||||||
// implementation-defined. Therefore they will be printed as raw
|
// implementation-defined. Therefore they will be printed as raw
|
||||||
// bytes.)
|
// bytes.)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void DefaultPrintTo(IsNotContainer /* dummy */,
|
void DefaultPrintTo(WrapPrinterType<kPrintPointer> /* dummy */,
|
||||||
true_type /* is a pointer */,
|
|
||||||
T* p, ::std::ostream* os) {
|
T* p, ::std::ostream* os) {
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
*os << "NULL";
|
*os << "NULL";
|
||||||
} else {
|
} else {
|
||||||
// C++ doesn't allow casting from a function pointer to any object
|
|
||||||
// pointer.
|
|
||||||
//
|
|
||||||
// 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,
|
// T is not a function type. We just call << to print p,
|
||||||
// relying on ADL to pick up user-defined << for their pointer
|
// relying on ADL to pick up user-defined << for their pointer
|
||||||
// types, if any.
|
// types, if any.
|
||||||
*os << p;
|
*os << p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
void DefaultPrintTo(WrapPrinterType<kPrintFunctionPointer> /* dummy */,
|
||||||
|
T* p, ::std::ostream* os) {
|
||||||
|
if (p == NULL) {
|
||||||
|
*os << "NULL";
|
||||||
} else {
|
} else {
|
||||||
// T is a function type, so '*os << p' doesn't do what we want
|
// T is a function type, so '*os << p' doesn't do what we want
|
||||||
// (it just prints p as bool). We want to print p as a const
|
// (it just prints p as bool). We want to print p as a const
|
||||||
// void*. However, we cannot cast it to const void* directly,
|
// void*.
|
||||||
// even using reinterpret_cast, as earlier versions of gcc
|
*os << reinterpret_cast<const void*>(p);
|
||||||
// (e.g. 3.4.5) cannot compile the cast when p is a function
|
|
||||||
// pointer. Casting to UInt64 first solves the problem.
|
|
||||||
*os << reinterpret_cast<const void*>(
|
|
||||||
reinterpret_cast<internal::UInt64>(p));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to print a non-container, non-pointer value when the user
|
// Used to print a non-container, non-pointer value when the user
|
||||||
// doesn't define PrintTo() for it.
|
// doesn't define PrintTo() for it.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void DefaultPrintTo(IsNotContainer /* dummy */,
|
void DefaultPrintTo(WrapPrinterType<kPrintOther> /* dummy */,
|
||||||
false_type /* is not a pointer */,
|
|
||||||
const T& value, ::std::ostream* os) {
|
const T& value, ::std::ostream* os) {
|
||||||
::testing_internal::DefaultPrintNonContainerTo(value, os);
|
::testing_internal::DefaultPrintNonContainerTo(value, os);
|
||||||
}
|
}
|
||||||
|
@ -452,11 +489,8 @@ void DefaultPrintTo(IsNotContainer /* dummy */,
|
||||||
// wants).
|
// wants).
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void PrintTo(const T& value, ::std::ostream* os) {
|
void PrintTo(const T& value, ::std::ostream* os) {
|
||||||
// DefaultPrintTo() is overloaded. The type of its first two
|
// DefaultPrintTo() is overloaded. The type of its first argument
|
||||||
// arguments determine which version will be picked. If T is an
|
// determines which version will be picked.
|
||||||
// STL-style container, the version for container will be called; if
|
|
||||||
// T is a pointer, the pointer version will be called; otherwise the
|
|
||||||
// generic version will be called.
|
|
||||||
//
|
//
|
||||||
// Note that we check for container types here, prior to we check
|
// Note that we check for container types here, prior to we check
|
||||||
// for protocol message types in our operator<<. The rationale is:
|
// for protocol message types in our operator<<. The rationale is:
|
||||||
|
@ -468,13 +502,27 @@ void PrintTo(const T& value, ::std::ostream* os) {
|
||||||
// elements; therefore we check for container types here to ensure
|
// elements; therefore we check for container types here to ensure
|
||||||
// that our format is used.
|
// that our format is used.
|
||||||
//
|
//
|
||||||
// The second argument of DefaultPrintTo() is needed to bypass a bug
|
// Note that MSVC and clang-cl do allow an implicit conversion from
|
||||||
// in Symbian's C++ compiler that prevents it from picking the right
|
// pointer-to-function to pointer-to-object, but clang-cl warns on it.
|
||||||
// overload between:
|
// So don't use ImplicitlyConvertible if it can be helped since it will
|
||||||
//
|
// cause this warning, and use a separate overload of DefaultPrintTo for
|
||||||
// PrintTo(const T& x, ...);
|
// function pointers so that the `*os << p` in the object pointer overload
|
||||||
// PrintTo(T* x, ...);
|
// doesn't cause that warning either.
|
||||||
DefaultPrintTo(IsContainerTest<T>(0), is_pointer<T>(), value, os);
|
DefaultPrintTo(
|
||||||
|
WrapPrinterType <
|
||||||
|
(sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) &&
|
||||||
|
!IsRecursiveContainer<T>::value
|
||||||
|
? kPrintContainer
|
||||||
|
: !is_pointer<T>::value
|
||||||
|
? kPrintOther
|
||||||
|
#if GTEST_LANG_CXX11
|
||||||
|
: std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
#else
|
||||||
|
: !internal::ImplicitlyConvertible<T, const void*>::value
|
||||||
|
#endif
|
||||||
|
? kPrintFunctionPointer
|
||||||
|
: kPrintPointer > (),
|
||||||
|
value, os);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following list of PrintTo() overloads tells
|
// The following list of PrintTo() overloads tells
|
||||||
|
@ -581,6 +629,17 @@ inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
|
||||||
}
|
}
|
||||||
#endif // GTEST_HAS_STD_WSTRING
|
#endif // GTEST_HAS_STD_WSTRING
|
||||||
|
|
||||||
|
#if GTEST_HAS_ABSL
|
||||||
|
// Overload for absl::string_view.
|
||||||
|
inline void PrintTo(absl::string_view sp, ::std::ostream* os) {
|
||||||
|
PrintTo(::std::string(sp), os);
|
||||||
|
}
|
||||||
|
#endif // GTEST_HAS_ABSL
|
||||||
|
|
||||||
|
#if GTEST_LANG_CXX11
|
||||||
|
inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
|
||||||
|
#endif // GTEST_LANG_CXX11
|
||||||
|
|
||||||
#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
|
#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
|
||||||
// Helper function for printing a tuple. T must be instantiated with
|
// Helper function for printing a tuple. T must be instantiated with
|
||||||
// a tuple type.
|
// a tuple type.
|
||||||
|
@ -710,6 +769,26 @@ class UniversalPrinter {
|
||||||
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if GTEST_HAS_ABSL
|
||||||
|
|
||||||
|
// Printer for absl::optional
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class UniversalPrinter<::absl::optional<T>> {
|
||||||
|
public:
|
||||||
|
static void Print(const ::absl::optional<T>& value, ::std::ostream* os) {
|
||||||
|
*os << '(';
|
||||||
|
if (!value) {
|
||||||
|
*os << "nullopt";
|
||||||
|
} else {
|
||||||
|
UniversalPrint(*value, os);
|
||||||
|
}
|
||||||
|
*os << ')';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GTEST_HAS_ABSL
|
||||||
|
|
||||||
// UniversalPrintArray(begin, len, os) prints an array of 'len'
|
// UniversalPrintArray(begin, len, os) prints an array of 'len'
|
||||||
// elements, starting at address 'begin'.
|
// elements, starting at address 'begin'.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -805,7 +884,7 @@ class UniversalTersePrinter<const char*> {
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
*os << "NULL";
|
*os << "NULL";
|
||||||
} else {
|
} else {
|
||||||
UniversalPrint(string(str), os);
|
UniversalPrint(std::string(str), os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -856,7 +935,7 @@ void UniversalPrint(const T& value, ::std::ostream* os) {
|
||||||
UniversalPrinter<T1>::Print(value, os);
|
UniversalPrinter<T1>::Print(value, os);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef ::std::vector<string> Strings;
|
typedef ::std::vector< ::std::string> Strings;
|
||||||
|
|
||||||
// TuplePolicy<TupleT> must provide:
|
// TuplePolicy<TupleT> must provide:
|
||||||
// - tuple_size
|
// - tuple_size
|
||||||
|
@ -976,6 +1055,16 @@ Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
|
#if GTEST_HAS_ABSL
|
||||||
|
namespace internal2 {
|
||||||
|
template <typename T>
|
||||||
|
void TypeWithoutFormatter<T, kConvertibleToStringView>::PrintValue(
|
||||||
|
const T& value, ::std::ostream* os) {
|
||||||
|
internal::PrintTo(absl::string_view(value), os);
|
||||||
|
}
|
||||||
|
} // namespace internal2
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
::std::string PrintToString(const T& value) {
|
::std::string PrintToString(const T& value) {
|
||||||
::std::stringstream ss;
|
::std::stringstream ss;
|
||||||
|
|
|
@ -97,13 +97,12 @@ class GTEST_API_ SingleFailureChecker {
|
||||||
public:
|
public:
|
||||||
// The constructor remembers the arguments.
|
// The constructor remembers the arguments.
|
||||||
SingleFailureChecker(const TestPartResultArray* results,
|
SingleFailureChecker(const TestPartResultArray* results,
|
||||||
TestPartResult::Type type,
|
TestPartResult::Type type, const std::string& substr);
|
||||||
const string& substr);
|
|
||||||
~SingleFailureChecker();
|
~SingleFailureChecker();
|
||||||
private:
|
private:
|
||||||
const TestPartResultArray* const results_;
|
const TestPartResultArray* const results_;
|
||||||
const TestPartResult::Type type_;
|
const TestPartResult::Type type_;
|
||||||
const string substr_;
|
const std::string substr_;
|
||||||
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
|
GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
|
||||||
};
|
};
|
||||||
|
|
|
@ -241,8 +241,9 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
|
||||||
namespace GTEST_CASE_NAMESPACE_(CaseName) { \
|
namespace GTEST_CASE_NAMESPACE_(CaseName) { \
|
||||||
typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
|
typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
|
||||||
} \
|
} \
|
||||||
static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \
|
static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) \
|
||||||
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\
|
GTEST_ATTRIBUTE_UNUSED_ = \
|
||||||
|
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames( \
|
||||||
__FILE__, __LINE__, #__VA_ARGS__)
|
__FILE__, __LINE__, #__VA_ARGS__)
|
||||||
|
|
||||||
// The 'Types' template argument below must have spaces around it
|
// The 'Types' template argument below must have spaces around it
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
//
|
//
|
||||||
// Author: wan@google.com (Zhanyong Wan)
|
// Author: wan@google.com (Zhanyong Wan)
|
||||||
//
|
//
|
||||||
// The Google C++ Testing Framework (Google Test)
|
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||||
//
|
//
|
||||||
// This header file defines the public API for Google Test. It should be
|
// This header file defines the public API for Google Test. It should be
|
||||||
// included by any test program that uses Google Test.
|
// included by any test program that uses Google Test.
|
||||||
|
@ -82,6 +82,15 @@
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
|
// Silence C4100 (unreferenced formal parameter) and 4805
|
||||||
|
// unsafe mix of type 'const int' and type 'const bool'
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# pragma warning(push)
|
||||||
|
# pragma warning(disable:4805)
|
||||||
|
# pragma warning(disable:4100)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Declares the flags.
|
// Declares the flags.
|
||||||
|
|
||||||
// This flag temporary enables the disabled tests.
|
// This flag temporary enables the disabled tests.
|
||||||
|
@ -115,6 +124,9 @@ GTEST_DECLARE_string_(output);
|
||||||
// test.
|
// test.
|
||||||
GTEST_DECLARE_bool_(print_time);
|
GTEST_DECLARE_bool_(print_time);
|
||||||
|
|
||||||
|
// This flags control whether Google Test prints UTF8 characters as text.
|
||||||
|
GTEST_DECLARE_bool_(print_utf8);
|
||||||
|
|
||||||
// This flag specifies the random number seed.
|
// This flag specifies the random number seed.
|
||||||
GTEST_DECLARE_int32_(random_seed);
|
GTEST_DECLARE_int32_(random_seed);
|
||||||
|
|
||||||
|
@ -135,7 +147,7 @@ GTEST_DECLARE_int32_(stack_trace_depth);
|
||||||
|
|
||||||
// When this flag is specified, a failed assertion will throw an
|
// When this flag is specified, a failed assertion will throw an
|
||||||
// exception if exceptions are enabled, or exit the program with a
|
// exception if exceptions are enabled, or exit the program with a
|
||||||
// non-zero code otherwise.
|
// non-zero code otherwise. For use with an external test framework.
|
||||||
GTEST_DECLARE_bool_(throw_on_failure);
|
GTEST_DECLARE_bool_(throw_on_failure);
|
||||||
|
|
||||||
// When this flag is set with a "host:port" string, on supported
|
// When this flag is set with a "host:port" string, on supported
|
||||||
|
@ -160,6 +172,7 @@ class TestEventListenersAccessor;
|
||||||
class TestEventRepeater;
|
class TestEventRepeater;
|
||||||
class UnitTestRecordPropertyTestHelper;
|
class UnitTestRecordPropertyTestHelper;
|
||||||
class WindowsDeathTest;
|
class WindowsDeathTest;
|
||||||
|
class FuchsiaDeathTest;
|
||||||
class UnitTestImpl* GetUnitTestImpl();
|
class UnitTestImpl* GetUnitTestImpl();
|
||||||
void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
|
void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
|
||||||
const std::string& message);
|
const std::string& message);
|
||||||
|
@ -259,7 +272,9 @@ class GTEST_API_ AssertionResult {
|
||||||
// Used in EXPECT_TRUE/FALSE(assertion_result).
|
// Used in EXPECT_TRUE/FALSE(assertion_result).
|
||||||
AssertionResult(const AssertionResult& other);
|
AssertionResult(const AssertionResult& other);
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER < 1910
|
||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)
|
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Used in the EXPECT_TRUE/FALSE(bool_expression).
|
// Used in the EXPECT_TRUE/FALSE(bool_expression).
|
||||||
//
|
//
|
||||||
|
@ -276,7 +291,9 @@ class GTEST_API_ AssertionResult {
|
||||||
/*enabler*/ = NULL)
|
/*enabler*/ = NULL)
|
||||||
: success_(success) {}
|
: success_(success) {}
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER < 1910
|
||||||
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||||
|
#endif
|
||||||
|
|
||||||
// Assignment operator.
|
// Assignment operator.
|
||||||
AssertionResult& operator=(AssertionResult other) {
|
AssertionResult& operator=(AssertionResult other) {
|
||||||
|
@ -345,6 +362,15 @@ GTEST_API_ AssertionResult AssertionFailure();
|
||||||
// Deprecated; use AssertionFailure() << msg.
|
// Deprecated; use AssertionFailure() << msg.
|
||||||
GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
|
GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
|
||||||
|
|
||||||
|
} // namespace testing
|
||||||
|
|
||||||
|
// Includes the auto-generated header that implements a family of generic
|
||||||
|
// predicate assertion macros. This include comes late because it relies on
|
||||||
|
// APIs declared above.
|
||||||
|
#include "gtest/gtest_pred_impl.h"
|
||||||
|
|
||||||
|
namespace testing {
|
||||||
|
|
||||||
// The abstract class that all tests inherit from.
|
// The abstract class that all tests inherit from.
|
||||||
//
|
//
|
||||||
// In Google Test, a unit test program contains one or many TestCases, and
|
// In Google Test, a unit test program contains one or many TestCases, and
|
||||||
|
@ -355,7 +381,7 @@ GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
|
||||||
// this for you.
|
// this for you.
|
||||||
//
|
//
|
||||||
// The only time you derive from Test is when defining a test fixture
|
// The only time you derive from Test is when defining a test fixture
|
||||||
// to be used a TEST_F. For example:
|
// to be used in a TEST_F. For example:
|
||||||
//
|
//
|
||||||
// class FooTest : public testing::Test {
|
// class FooTest : public testing::Test {
|
||||||
// protected:
|
// protected:
|
||||||
|
@ -550,9 +576,8 @@ class GTEST_API_ TestResult {
|
||||||
// Returns the elapsed time, in milliseconds.
|
// Returns the elapsed time, in milliseconds.
|
||||||
TimeInMillis elapsed_time() const { return elapsed_time_; }
|
TimeInMillis elapsed_time() const { return elapsed_time_; }
|
||||||
|
|
||||||
// Returns the i-th test part result among all the results. i can range
|
// Returns the i-th test part result among all the results. i can range from 0
|
||||||
// from 0 to test_property_count() - 1. If i is not in that range, aborts
|
// to total_part_count() - 1. If i is not in that range, aborts the program.
|
||||||
// the program.
|
|
||||||
const TestPartResult& GetTestPartResult(int i) const;
|
const TestPartResult& GetTestPartResult(int i) const;
|
||||||
|
|
||||||
// Returns the i-th test property. i can range from 0 to
|
// Returns the i-th test property. i can range from 0 to
|
||||||
|
@ -569,6 +594,7 @@ class GTEST_API_ TestResult {
|
||||||
friend class internal::TestResultAccessor;
|
friend class internal::TestResultAccessor;
|
||||||
friend class internal::UnitTestImpl;
|
friend class internal::UnitTestImpl;
|
||||||
friend class internal::WindowsDeathTest;
|
friend class internal::WindowsDeathTest;
|
||||||
|
friend class internal::FuchsiaDeathTest;
|
||||||
|
|
||||||
// Gets the vector of TestPartResults.
|
// Gets the vector of TestPartResults.
|
||||||
const std::vector<TestPartResult>& test_part_results() const {
|
const std::vector<TestPartResult>& test_part_results() const {
|
||||||
|
@ -675,6 +701,9 @@ class GTEST_API_ TestInfo {
|
||||||
// Returns the line where this test is defined.
|
// Returns the line where this test is defined.
|
||||||
int line() const { return location_.line; }
|
int line() const { return location_.line; }
|
||||||
|
|
||||||
|
// Return true if this test should not be run because it's in another shard.
|
||||||
|
bool is_in_another_shard() const { return is_in_another_shard_; }
|
||||||
|
|
||||||
// Returns true if this test should run, that is if the test is not
|
// Returns true if this test should run, that is if the test is not
|
||||||
// disabled (or it is disabled but the also_run_disabled_tests flag has
|
// disabled (or it is disabled but the also_run_disabled_tests flag has
|
||||||
// been specified) and its full name matches the user-specified filter.
|
// been specified) and its full name matches the user-specified filter.
|
||||||
|
@ -695,10 +724,9 @@ class GTEST_API_ TestInfo {
|
||||||
|
|
||||||
// Returns true iff this test will appear in the XML report.
|
// Returns true iff this test will appear in the XML report.
|
||||||
bool is_reportable() const {
|
bool is_reportable() const {
|
||||||
// For now, the XML report includes all tests matching the filter.
|
// The XML report includes tests matching the filter, excluding those
|
||||||
// In the future, we may trim tests that are excluded because of
|
// run in other shards.
|
||||||
// sharding.
|
return matches_filter_ && !is_in_another_shard_;
|
||||||
return matches_filter_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the result of the test.
|
// Returns the result of the test.
|
||||||
|
@ -762,6 +790,7 @@ class GTEST_API_ TestInfo {
|
||||||
bool is_disabled_; // True iff this test is disabled
|
bool is_disabled_; // True iff this test is disabled
|
||||||
bool matches_filter_; // True if this test matches the
|
bool matches_filter_; // True if this test matches the
|
||||||
// user-specified filter.
|
// user-specified filter.
|
||||||
|
bool is_in_another_shard_; // Will be run in another shard.
|
||||||
internal::TestFactoryBase* const factory_; // The factory that creates
|
internal::TestFactoryBase* const factory_; // The factory that creates
|
||||||
// the test object
|
// the test object
|
||||||
|
|
||||||
|
@ -986,6 +1015,18 @@ class Environment {
|
||||||
virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
|
virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if GTEST_HAS_EXCEPTIONS
|
||||||
|
|
||||||
|
// Exception which can be thrown from TestEventListener::OnTestPartResult.
|
||||||
|
class GTEST_API_ AssertionException
|
||||||
|
: public internal::GoogleTestFailureException {
|
||||||
|
public:
|
||||||
|
explicit AssertionException(const TestPartResult& result)
|
||||||
|
: GoogleTestFailureException(result) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GTEST_HAS_EXCEPTIONS
|
||||||
|
|
||||||
// The interface for tracing execution of tests. The methods are organized in
|
// The interface for tracing execution of tests. The methods are organized in
|
||||||
// the order the corresponding events are fired.
|
// the order the corresponding events are fired.
|
||||||
class TestEventListener {
|
class TestEventListener {
|
||||||
|
@ -1014,6 +1055,8 @@ class TestEventListener {
|
||||||
virtual void OnTestStart(const TestInfo& test_info) = 0;
|
virtual void OnTestStart(const TestInfo& test_info) = 0;
|
||||||
|
|
||||||
// Fired after a failed assertion or a SUCCEED() invocation.
|
// Fired after a failed assertion or a SUCCEED() invocation.
|
||||||
|
// If you want to throw an exception from this function to skip to the next
|
||||||
|
// TEST, it must be AssertionException defined above, or inherited from it.
|
||||||
virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
|
virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
|
||||||
|
|
||||||
// Fired after the test ends.
|
// Fired after the test ends.
|
||||||
|
@ -1180,14 +1223,12 @@ class GTEST_API_ UnitTest {
|
||||||
// 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 random_seed() const;
|
int random_seed() const;
|
||||||
|
|
||||||
#if GTEST_HAS_PARAM_TEST
|
|
||||||
// Returns the ParameterizedTestCaseRegistry object used to keep track of
|
// Returns the ParameterizedTestCaseRegistry object used to keep track of
|
||||||
// value-parameterized tests and instantiate and register them.
|
// value-parameterized tests and instantiate and register them.
|
||||||
//
|
//
|
||||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||||
internal::ParameterizedTestCaseRegistry& parameterized_test_registry()
|
internal::ParameterizedTestCaseRegistry& parameterized_test_registry()
|
||||||
GTEST_LOCK_EXCLUDED_(mutex_);
|
GTEST_LOCK_EXCLUDED_(mutex_);
|
||||||
#endif // GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
// Gets the number of successful test cases.
|
// Gets the number of successful test cases.
|
||||||
int successful_test_case_count() const;
|
int successful_test_case_count() const;
|
||||||
|
@ -1287,11 +1328,11 @@ class GTEST_API_ UnitTest {
|
||||||
internal::UnitTestImpl* impl() { return impl_; }
|
internal::UnitTestImpl* impl() { return impl_; }
|
||||||
const internal::UnitTestImpl* impl() const { return impl_; }
|
const internal::UnitTestImpl* impl() const { return impl_; }
|
||||||
|
|
||||||
// These classes and funcions are friends as they need to access private
|
// These classes and functions are friends as they need to access private
|
||||||
// members of UnitTest.
|
// members of UnitTest.
|
||||||
|
friend class ScopedTrace;
|
||||||
friend class Test;
|
friend class Test;
|
||||||
friend class internal::AssertHelper;
|
friend class internal::AssertHelper;
|
||||||
friend class internal::ScopedTrace;
|
|
||||||
friend class internal::StreamingListenerTest;
|
friend class internal::StreamingListenerTest;
|
||||||
friend class internal::UnitTestRecordPropertyTestHelper;
|
friend class internal::UnitTestRecordPropertyTestHelper;
|
||||||
friend Environment* AddGlobalTestEnvironment(Environment* env);
|
friend Environment* AddGlobalTestEnvironment(Environment* env);
|
||||||
|
@ -1388,11 +1429,9 @@ AssertionResult CmpHelperEQ(const char* lhs_expression,
|
||||||
const char* rhs_expression,
|
const char* rhs_expression,
|
||||||
const T1& lhs,
|
const T1& lhs,
|
||||||
const T2& rhs) {
|
const T2& rhs) {
|
||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4389 /* signed/unsigned mismatch */)
|
|
||||||
if (lhs == rhs) {
|
if (lhs == rhs) {
|
||||||
return AssertionSuccess();
|
return AssertionSuccess();
|
||||||
}
|
}
|
||||||
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
|
||||||
|
|
||||||
return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
|
return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
|
||||||
}
|
}
|
||||||
|
@ -1706,7 +1745,6 @@ class GTEST_API_ AssertHelper {
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
#if GTEST_HAS_PARAM_TEST
|
|
||||||
// The pure interface class that all value-parameterized tests inherit from.
|
// The pure interface class that all value-parameterized tests inherit from.
|
||||||
// A value-parameterized class must inherit from both ::testing::Test and
|
// A value-parameterized class must inherit from both ::testing::Test and
|
||||||
// ::testing::WithParamInterface. In most cases that just means inheriting
|
// ::testing::WithParamInterface. In most cases that just means inheriting
|
||||||
|
@ -1783,8 +1821,6 @@ template <typename T>
|
||||||
class TestWithParam : public Test, public WithParamInterface<T> {
|
class TestWithParam : public Test, public WithParamInterface<T> {
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
// Macros for indicating success/failure in test code.
|
// Macros for indicating success/failure in test code.
|
||||||
|
|
||||||
// ADD_FAILURE unconditionally adds a failure to the current test.
|
// ADD_FAILURE unconditionally adds a failure to the current test.
|
||||||
|
@ -1857,22 +1893,18 @@ class TestWithParam : public Test, public WithParamInterface<T> {
|
||||||
// AssertionResult. For more information on how to use AssertionResult with
|
// AssertionResult. For more information on how to use AssertionResult with
|
||||||
// these macros see comments on that class.
|
// these macros see comments on that class.
|
||||||
#define EXPECT_TRUE(condition) \
|
#define EXPECT_TRUE(condition) \
|
||||||
GTEST_TEST_BOOLEAN_((condition), #condition, false, true, \
|
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
|
||||||
GTEST_NONFATAL_FAILURE_)
|
GTEST_NONFATAL_FAILURE_)
|
||||||
#define EXPECT_FALSE(condition) \
|
#define EXPECT_FALSE(condition) \
|
||||||
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
|
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
|
||||||
GTEST_NONFATAL_FAILURE_)
|
GTEST_NONFATAL_FAILURE_)
|
||||||
#define ASSERT_TRUE(condition) \
|
#define ASSERT_TRUE(condition) \
|
||||||
GTEST_TEST_BOOLEAN_((condition), #condition, false, true, \
|
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
|
||||||
GTEST_FATAL_FAILURE_)
|
GTEST_FATAL_FAILURE_)
|
||||||
#define ASSERT_FALSE(condition) \
|
#define ASSERT_FALSE(condition) \
|
||||||
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
|
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
|
||||||
GTEST_FATAL_FAILURE_)
|
GTEST_FATAL_FAILURE_)
|
||||||
|
|
||||||
// Includes the auto-generated header that implements a family of
|
|
||||||
// generic predicate assertion macros.
|
|
||||||
#include "gtest/gtest_pred_impl.h"
|
|
||||||
|
|
||||||
// Macros for testing equalities and inequalities.
|
// Macros for testing equalities and inequalities.
|
||||||
//
|
//
|
||||||
// * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2
|
// * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2
|
||||||
|
@ -1914,8 +1946,8 @@ class TestWithParam : public Test, public WithParamInterface<T> {
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
//
|
//
|
||||||
// EXPECT_NE(5, Foo());
|
// EXPECT_NE(Foo(), 5);
|
||||||
// EXPECT_EQ(NULL, a_pointer);
|
// EXPECT_EQ(a_pointer, NULL);
|
||||||
// ASSERT_LT(i, array_size);
|
// ASSERT_LT(i, array_size);
|
||||||
// ASSERT_GT(records.size(), 0) << "There is no record left.";
|
// ASSERT_GT(records.size(), 0) << "There is no record left.";
|
||||||
|
|
||||||
|
@ -2101,6 +2133,57 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||||
#define EXPECT_NO_FATAL_FAILURE(statement) \
|
#define EXPECT_NO_FATAL_FAILURE(statement) \
|
||||||
GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
|
GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
|
||||||
|
|
||||||
|
// Causes a trace (including the given source file path and line number,
|
||||||
|
// and the given message) to be included in every test failure message generated
|
||||||
|
// by code in the scope of the lifetime of an instance of this class. The effect
|
||||||
|
// is undone with the destruction of the instance.
|
||||||
|
//
|
||||||
|
// The message argument can be anything streamable to std::ostream.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
// testing::ScopedTrace trace("file.cc", 123, "message");
|
||||||
|
//
|
||||||
|
class GTEST_API_ ScopedTrace {
|
||||||
|
public:
|
||||||
|
// The c'tor pushes the given source file location and message onto
|
||||||
|
// a trace stack maintained by Google Test.
|
||||||
|
|
||||||
|
// Template version. Uses Message() to convert the values into strings.
|
||||||
|
// Slow, but flexible.
|
||||||
|
template <typename T>
|
||||||
|
ScopedTrace(const char* file, int line, const T& message) {
|
||||||
|
PushTrace(file, line, (Message() << message).GetString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optimize for some known types.
|
||||||
|
ScopedTrace(const char* file, int line, const char* message) {
|
||||||
|
PushTrace(file, line, message ? message : "(null)");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if GTEST_HAS_GLOBAL_STRING
|
||||||
|
ScopedTrace(const char* file, int line, const ::string& message) {
|
||||||
|
PushTrace(file, line, message);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ScopedTrace(const char* file, int line, const std::string& message) {
|
||||||
|
PushTrace(file, line, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The d'tor pops the info pushed by the c'tor.
|
||||||
|
//
|
||||||
|
// Note that the d'tor is not virtual in order to be efficient.
|
||||||
|
// Don't inherit from ScopedTrace!
|
||||||
|
~ScopedTrace();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void PushTrace(const char* file, int line, std::string message);
|
||||||
|
|
||||||
|
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
|
||||||
|
} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its
|
||||||
|
// c'tor and d'tor. Therefore it doesn't
|
||||||
|
// need to be used otherwise.
|
||||||
|
|
||||||
// Causes a trace (including the source file path, the current line
|
// Causes a trace (including the source file path, the current line
|
||||||
// number, and the given message) to be included in every test failure
|
// number, and the given message) to be included in every test failure
|
||||||
// message generated by code in the current scope. The effect is
|
// message generated by code in the current scope. The effect is
|
||||||
|
@ -2112,9 +2195,14 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||||
// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s
|
// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s
|
||||||
// to appear in the same block - as long as they are on different
|
// to appear in the same block - as long as they are on different
|
||||||
// lines.
|
// lines.
|
||||||
|
//
|
||||||
|
// Assuming that each thread maintains its own stack of traces.
|
||||||
|
// Therefore, a SCOPED_TRACE() would (correctly) only affect the
|
||||||
|
// assertions in its own thread.
|
||||||
#define SCOPED_TRACE(message) \
|
#define SCOPED_TRACE(message) \
|
||||||
::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
|
::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
|
||||||
__FILE__, __LINE__, ::testing::Message() << (message))
|
__FILE__, __LINE__, (message))
|
||||||
|
|
||||||
|
|
||||||
// Compile-time assertion for type equality.
|
// Compile-time assertion for type equality.
|
||||||
// StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
|
// StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
|
||||||
|
@ -2194,7 +2282,7 @@ bool StaticAssertTypeEq() {
|
||||||
// name of the test within the test case.
|
// name of the test within the test case.
|
||||||
//
|
//
|
||||||
// A test fixture class must be declared earlier. The user should put
|
// A test fixture class must be declared earlier. The user should put
|
||||||
// his test code between braces after using this macro. Example:
|
// the test code between braces after using this macro. Example:
|
||||||
//
|
//
|
||||||
// class FooTest : public testing::Test {
|
// class FooTest : public testing::Test {
|
||||||
// protected:
|
// protected:
|
||||||
|
@ -2209,14 +2297,22 @@ bool StaticAssertTypeEq() {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// TEST_F(FooTest, ReturnsElementCountCorrectly) {
|
// TEST_F(FooTest, ReturnsElementCountCorrectly) {
|
||||||
// EXPECT_EQ(0, a_.size());
|
// EXPECT_EQ(a_.size(), 0);
|
||||||
// EXPECT_EQ(1, b_.size());
|
// EXPECT_EQ(b_.size(), 1);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#define TEST_F(test_fixture, test_name)\
|
#define TEST_F(test_fixture, test_name)\
|
||||||
GTEST_TEST_(test_fixture, test_name, test_fixture, \
|
GTEST_TEST_(test_fixture, test_name, test_fixture, \
|
||||||
::testing::internal::GetTypeId<test_fixture>())
|
::testing::internal::GetTypeId<test_fixture>())
|
||||||
|
|
||||||
|
// Returns a path to temporary directory.
|
||||||
|
// Tries to determine an appropriate directory for the platform.
|
||||||
|
GTEST_API_ std::string TempDir();
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
|
||||||
// Use this function in main() to run all tests. It returns 0 if all
|
// Use this function in main() to run all tests. It returns 0 if all
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// (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.
|
||||||
|
|
||||||
// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command
|
// This file is AUTOMATICALLY GENERATED on 01/02/2018 by command
|
||||||
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
|
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
|
||||||
//
|
//
|
||||||
// Implements a family of generic predicate assertion macros.
|
// Implements a family of generic predicate assertion macros.
|
||||||
|
@ -35,10 +35,9 @@
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||||
|
|
||||||
// Makes sure this header is not included before gtest.h.
|
#include "gtest/gtest.h"
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
|
|
||||||
# error Do not include gtest_pred_impl.h directly. Include gtest.h instead.
|
namespace testing {
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_H_
|
|
||||||
|
|
||||||
// This header implements a family of generic predicate assertion
|
// This header implements a family of generic predicate assertion
|
||||||
// macros:
|
// macros:
|
||||||
|
@ -66,8 +65,6 @@
|
||||||
// We also define the EXPECT_* variations.
|
// We also define the EXPECT_* variations.
|
||||||
//
|
//
|
||||||
// For now we only support predicates whose arity is at most 5.
|
// For now we only support predicates whose arity is at most 5.
|
||||||
// Please email googletestframework@googlegroups.com if you need
|
|
||||||
// support for higher arities.
|
|
||||||
|
|
||||||
// GTEST_ASSERT_ is the basic statement to which all of the assertions
|
// GTEST_ASSERT_ is the basic statement to which all of the assertions
|
||||||
// in this file reduce. Don't use this in your code.
|
// in this file reduce. Don't use this in your code.
|
||||||
|
@ -355,4 +352,6 @@ AssertionResult AssertPred5Helper(const char* pred_text,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace testing
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
#endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
//
|
//
|
||||||
// Author: wan@google.com (Zhanyong Wan)
|
// Author: wan@google.com (Zhanyong Wan)
|
||||||
//
|
//
|
||||||
// Google C++ Testing Framework definitions useful in production code.
|
// Google C++ Testing and Mocking Framework definitions useful in production code.
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
|
#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
|
#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
|
||||||
|
@ -40,17 +40,20 @@
|
||||||
//
|
//
|
||||||
// class MyClass {
|
// class MyClass {
|
||||||
// private:
|
// private:
|
||||||
// void MyMethod();
|
// void PrivateMethod();
|
||||||
// FRIEND_TEST(MyClassTest, MyMethod);
|
// FRIEND_TEST(MyClassTest, PrivateMethodWorks);
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// class MyClassTest : public testing::Test {
|
// class MyClassTest : public testing::Test {
|
||||||
// // ...
|
// // ...
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// TEST_F(MyClassTest, MyMethod) {
|
// TEST_F(MyClassTest, PrivateMethodWorks) {
|
||||||
// // Can call MyClass::MyMethod() here.
|
// // Can call MyClass::PrivateMethod() here.
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
// Note: The test class must be in the same namespace as the class being tested.
|
||||||
|
// For example, putting MyClassTest in an anonymous namespace will not work.
|
||||||
|
|
||||||
#define FRIEND_TEST(test_case_name, test_name)\
|
#define FRIEND_TEST(test_case_name, test_name)\
|
||||||
friend class test_case_name##_##test_name##_Test
|
friend class test_case_name##_##test_name##_Test
|
||||||
|
|
|
@ -61,6 +61,12 @@
|
||||||
// GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
|
// GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
|
||||||
// GTEST_LOCK_EXCLUDED_(locks)
|
// GTEST_LOCK_EXCLUDED_(locks)
|
||||||
//
|
//
|
||||||
|
// Underlying library support features:
|
||||||
|
// GTEST_HAS_CXXABI_H_
|
||||||
|
//
|
||||||
|
// Exporting API symbols:
|
||||||
|
// GTEST_API_ - Specifier for exported symbols.
|
||||||
|
//
|
||||||
// ** Custom implementation starts here **
|
// ** Custom implementation starts here **
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
|
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
|
||||||
|
|
|
@ -33,6 +33,10 @@
|
||||||
// GTEST_OS_STACK_TRACE_GETTER_ - The name of an implementation of
|
// GTEST_OS_STACK_TRACE_GETTER_ - The name of an implementation of
|
||||||
// OsStackTraceGetterInterface.
|
// OsStackTraceGetterInterface.
|
||||||
//
|
//
|
||||||
|
// GTEST_CUSTOM_TEMPDIR_FUNCTION_ - An override for testing::TempDir().
|
||||||
|
// See testing::TempDir for semantics and
|
||||||
|
// signature.
|
||||||
|
//
|
||||||
// ** Custom implementation starts here **
|
// ** Custom implementation starts here **
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_
|
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_
|
||||||
|
|
|
@ -27,9 +27,8 @@
|
||||||
// (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: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
|
|
||||||
//
|
//
|
||||||
// The Google C++ Testing Framework (Google Test)
|
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||||
//
|
//
|
||||||
// This header file defines internal utilities needed for implementing
|
// This header file defines internal utilities needed for implementing
|
||||||
// death tests. They are subject to change without notice.
|
// death tests. They are subject to change without notice.
|
||||||
|
@ -218,13 +217,17 @@ GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
|
||||||
// can be streamed.
|
// can be streamed.
|
||||||
|
|
||||||
// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
|
// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
|
||||||
// NDEBUG mode. In this case we need the statements to be executed, the regex is
|
// NDEBUG mode. In this case we need the statements to be executed and the macro
|
||||||
// ignored, and the macro must accept a streamed message even though the message
|
// must accept a streamed message even though the message is never printed.
|
||||||
// is never printed.
|
// The regex object is not evaluated, but it is used to prevent "unused"
|
||||||
# define GTEST_EXECUTE_STATEMENT_(statement, regex) \
|
// warnings and to avoid an expression that doesn't compile in debug mode.
|
||||||
|
#define GTEST_EXECUTE_STATEMENT_(statement, regex) \
|
||||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||||
if (::testing::internal::AlwaysTrue()) { \
|
if (::testing::internal::AlwaysTrue()) { \
|
||||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||||
|
} else if (!::testing::internal::AlwaysTrue()) { \
|
||||||
|
const ::testing::internal::RE& gtest_regex = (regex); \
|
||||||
|
static_cast<void>(gtest_regex); \
|
||||||
} else \
|
} else \
|
||||||
::testing::Message()
|
::testing::Message()
|
||||||
|
|
||||||
|
@ -264,53 +267,6 @@ class InternalRunDeathTestFlag {
|
||||||
// the flag is specified; otherwise returns NULL.
|
// the flag is specified; otherwise returns NULL.
|
||||||
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
|
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
|
||||||
|
|
||||||
#else // GTEST_HAS_DEATH_TEST
|
|
||||||
|
|
||||||
// This macro is used for implementing macros such as
|
|
||||||
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
|
|
||||||
// death tests are not supported. Those macros must compile on such systems
|
|
||||||
// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
|
|
||||||
// systems that support death tests. This allows one to write such a macro
|
|
||||||
// on a system that does not support death tests and be sure that it will
|
|
||||||
// compile on a death-test supporting system.
|
|
||||||
//
|
|
||||||
// Parameters:
|
|
||||||
// statement - A statement that a macro such as EXPECT_DEATH would test
|
|
||||||
// for program termination. This macro has to make sure this
|
|
||||||
// statement is compiled but not executed, to ensure that
|
|
||||||
// EXPECT_DEATH_IF_SUPPORTED compiles with a certain
|
|
||||||
// parameter iff EXPECT_DEATH compiles with it.
|
|
||||||
// regex - A regex that a macro such as EXPECT_DEATH would use to test
|
|
||||||
// the output of statement. This parameter has to be
|
|
||||||
// compiled but not evaluated by this macro, to ensure that
|
|
||||||
// this macro only accepts expressions that a macro such as
|
|
||||||
// EXPECT_DEATH would accept.
|
|
||||||
// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
|
|
||||||
// and a return statement for ASSERT_DEATH_IF_SUPPORTED.
|
|
||||||
// This ensures that ASSERT_DEATH_IF_SUPPORTED will not
|
|
||||||
// compile inside functions where ASSERT_DEATH doesn't
|
|
||||||
// compile.
|
|
||||||
//
|
|
||||||
// The branch that has an always false condition is used to ensure that
|
|
||||||
// statement and regex are compiled (and thus syntactically correct) but
|
|
||||||
// never executed. The unreachable code macro protects the terminator
|
|
||||||
// statement from generating an 'unreachable code' warning in case
|
|
||||||
// statement unconditionally returns or throws. The Message constructor at
|
|
||||||
// the end allows the syntax of streaming additional messages into the
|
|
||||||
// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
|
|
||||||
# define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \
|
|
||||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
|
||||||
if (::testing::internal::AlwaysTrue()) { \
|
|
||||||
GTEST_LOG_(WARNING) \
|
|
||||||
<< "Death tests are not supported on this platform.\n" \
|
|
||||||
<< "Statement '" #statement "' cannot be verified."; \
|
|
||||||
} else if (::testing::internal::AlwaysFalse()) { \
|
|
||||||
::testing::internal::RE::PartialMatch(".*", (regex)); \
|
|
||||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
|
||||||
terminator; \
|
|
||||||
} else \
|
|
||||||
::testing::Message()
|
|
||||||
|
|
||||||
#endif // GTEST_HAS_DEATH_TEST
|
#endif // GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
|
@ -27,14 +27,13 @@
|
||||||
// (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.
|
||||||
//
|
//
|
||||||
// Author: keith.ray@gmail.com (Keith Ray)
|
|
||||||
//
|
//
|
||||||
// Google Test filepath utilities
|
// Google Test filepath utilities
|
||||||
//
|
//
|
||||||
// This header file declares classes and functions used internally by
|
// This header file declares 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 in <gtest/internal/gtest-internal.h>.
|
// This file is #included in gtest/internal/gtest-internal.h.
|
||||||
// Do not include this header file separately!
|
// Do not include this header file separately!
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
||||||
|
|
|
@ -27,9 +27,8 @@
|
||||||
// (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: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
|
|
||||||
//
|
//
|
||||||
// The Google C++ Testing Framework (Google Test)
|
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||||
//
|
//
|
||||||
// This header file declares functions and macros used internally by
|
// This header file declares functions and macros used internally by
|
||||||
// Google Test. They are subject to change without notice.
|
// Google Test. They are subject to change without notice.
|
||||||
|
@ -61,8 +60,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "gtest/gtest-message.h"
|
#include "gtest/gtest-message.h"
|
||||||
#include "gtest/internal/gtest-string.h"
|
|
||||||
#include "gtest/internal/gtest-filepath.h"
|
#include "gtest/internal/gtest-filepath.h"
|
||||||
|
#include "gtest/internal/gtest-string.h"
|
||||||
#include "gtest/internal/gtest-type-util.h"
|
#include "gtest/internal/gtest-type-util.h"
|
||||||
|
|
||||||
// Due to C++ preprocessor weirdness, we need double indirection to
|
// Due to C++ preprocessor weirdness, we need double indirection to
|
||||||
|
@ -76,6 +75,9 @@
|
||||||
#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
|
#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
|
||||||
#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
|
#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
|
||||||
|
|
||||||
|
// Stringifies its argument.
|
||||||
|
#define GTEST_STRINGIFY_(name) #name
|
||||||
|
|
||||||
class ProtocolMessage;
|
class ProtocolMessage;
|
||||||
namespace proto2 { class Message; }
|
namespace proto2 { class Message; }
|
||||||
|
|
||||||
|
@ -96,7 +98,6 @@ template <typename T>
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
struct TraceInfo; // Information about a trace point.
|
struct TraceInfo; // Information about a trace point.
|
||||||
class ScopedTrace; // Implements scoped trace.
|
|
||||||
class TestInfoImpl; // Opaque implementation of TestInfo
|
class TestInfoImpl; // Opaque implementation of TestInfo
|
||||||
class UnitTestImpl; // Opaque implementation of UnitTest
|
class UnitTestImpl; // Opaque implementation of UnitTest
|
||||||
|
|
||||||
|
@ -152,30 +153,11 @@ class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {
|
||||||
|
|
||||||
#endif // GTEST_HAS_EXCEPTIONS
|
#endif // GTEST_HAS_EXCEPTIONS
|
||||||
|
|
||||||
// A helper class for creating scoped traces in user programs.
|
|
||||||
class GTEST_API_ ScopedTrace {
|
|
||||||
public:
|
|
||||||
// The c'tor pushes the given source file location and message onto
|
|
||||||
// a trace stack maintained by Google Test.
|
|
||||||
ScopedTrace(const char* file, int line, const Message& message);
|
|
||||||
|
|
||||||
// The d'tor pops the info pushed by the c'tor.
|
|
||||||
//
|
|
||||||
// Note that the d'tor is not virtual in order to be efficient.
|
|
||||||
// Don't inherit from ScopedTrace!
|
|
||||||
~ScopedTrace();
|
|
||||||
|
|
||||||
private:
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
|
|
||||||
} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its
|
|
||||||
// c'tor and d'tor. Therefore it doesn't
|
|
||||||
// need to be used otherwise.
|
|
||||||
|
|
||||||
namespace edit_distance {
|
namespace edit_distance {
|
||||||
// Returns the optimal edits to go from 'left' to 'right'.
|
// Returns the optimal edits to go from 'left' to 'right'.
|
||||||
// All edits cost the same, with replace having lower priority than
|
// All edits cost the same, with replace having lower priority than
|
||||||
// add/remove.
|
// add/remove.
|
||||||
// Simple implementation of the Wagner–Fischer algorithm.
|
// Simple implementation of the Wagner-Fischer algorithm.
|
||||||
// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
|
// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
|
||||||
enum EditType { kMatch, kAdd, kRemove, kReplace };
|
enum EditType { kMatch, kAdd, kRemove, kReplace };
|
||||||
GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
|
GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
|
||||||
|
@ -502,9 +484,10 @@ typedef void (*SetUpTestCaseFunc)();
|
||||||
typedef void (*TearDownTestCaseFunc)();
|
typedef void (*TearDownTestCaseFunc)();
|
||||||
|
|
||||||
struct CodeLocation {
|
struct CodeLocation {
|
||||||
CodeLocation(const string& a_file, int a_line) : file(a_file), line(a_line) {}
|
CodeLocation(const std::string& a_file, int a_line)
|
||||||
|
: file(a_file), line(a_line) {}
|
||||||
|
|
||||||
string file;
|
std::string file;
|
||||||
int line;
|
int line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -627,7 +610,7 @@ class TypeParameterizedTest {
|
||||||
// Types). Valid values for 'index' are [0, N - 1] where N is the
|
// Types). Valid values for 'index' are [0, N - 1] where N is the
|
||||||
// length of Types.
|
// length of Types.
|
||||||
static bool Register(const char* prefix,
|
static bool Register(const char* prefix,
|
||||||
CodeLocation code_location,
|
const CodeLocation& code_location,
|
||||||
const char* case_name, const char* test_names,
|
const char* case_name, const char* test_names,
|
||||||
int index) {
|
int index) {
|
||||||
typedef typename Types::Head Type;
|
typedef typename Types::Head Type;
|
||||||
|
@ -658,7 +641,7 @@ class TypeParameterizedTest {
|
||||||
template <GTEST_TEMPLATE_ Fixture, class TestSel>
|
template <GTEST_TEMPLATE_ Fixture, class TestSel>
|
||||||
class TypeParameterizedTest<Fixture, TestSel, Types0> {
|
class TypeParameterizedTest<Fixture, TestSel, Types0> {
|
||||||
public:
|
public:
|
||||||
static bool Register(const char* /*prefix*/, CodeLocation,
|
static bool Register(const char* /*prefix*/, const CodeLocation&,
|
||||||
const char* /*case_name*/, const char* /*test_names*/,
|
const char* /*case_name*/, const char* /*test_names*/,
|
||||||
int /*index*/) {
|
int /*index*/) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -704,7 +687,7 @@ class TypeParameterizedTestCase {
|
||||||
template <GTEST_TEMPLATE_ Fixture, typename Types>
|
template <GTEST_TEMPLATE_ Fixture, typename Types>
|
||||||
class TypeParameterizedTestCase<Fixture, Templates0, Types> {
|
class TypeParameterizedTestCase<Fixture, Templates0, Types> {
|
||||||
public:
|
public:
|
||||||
static bool Register(const char* /*prefix*/, CodeLocation,
|
static bool Register(const char* /*prefix*/, const CodeLocation&,
|
||||||
const TypedTestCasePState* /*state*/,
|
const TypedTestCasePState* /*state*/,
|
||||||
const char* /*case_name*/, const char* /*test_names*/) {
|
const char* /*case_name*/, const char* /*test_names*/) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -823,31 +806,6 @@ struct RemoveConst<T[N]> {
|
||||||
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
|
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
|
||||||
GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
|
GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
|
||||||
|
|
||||||
// Adds reference to a type if it is not a reference type,
|
|
||||||
// otherwise leaves it unchanged. This is the same as
|
|
||||||
// tr1::add_reference, which is not widely available yet.
|
|
||||||
template <typename T>
|
|
||||||
struct AddReference { typedef T& type; }; // NOLINT
|
|
||||||
template <typename T>
|
|
||||||
struct AddReference<T&> { typedef T& type; }; // NOLINT
|
|
||||||
|
|
||||||
// A handy wrapper around AddReference that works when the argument T
|
|
||||||
// depends on template parameters.
|
|
||||||
#define GTEST_ADD_REFERENCE_(T) \
|
|
||||||
typename ::testing::internal::AddReference<T>::type
|
|
||||||
|
|
||||||
// Adds a reference to const on top of T as necessary. For example,
|
|
||||||
// it transforms
|
|
||||||
//
|
|
||||||
// char ==> const char&
|
|
||||||
// const char ==> const char&
|
|
||||||
// char& ==> const char&
|
|
||||||
// const char& ==> const char&
|
|
||||||
//
|
|
||||||
// The argument T must depend on some template parameters.
|
|
||||||
#define GTEST_REFERENCE_TO_CONST_(T) \
|
|
||||||
GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))
|
|
||||||
|
|
||||||
// ImplicitlyConvertible<From, To>::value is a compile-time bool
|
// ImplicitlyConvertible<From, To>::value is a compile-time bool
|
||||||
// constant that's true iff type From can be implicitly converted to
|
// constant that's true iff type From can be implicitly converted to
|
||||||
// type To.
|
// type To.
|
||||||
|
@ -917,8 +875,11 @@ struct IsAProtocolMessage
|
||||||
// a container class by checking the type of IsContainerTest<C>(0).
|
// a container class by checking the type of IsContainerTest<C>(0).
|
||||||
// The value of the expression is insignificant.
|
// The value of the expression is insignificant.
|
||||||
//
|
//
|
||||||
// Note that we look for both C::iterator and C::const_iterator. The
|
// In C++11 mode we check the existence of a const_iterator and that an
|
||||||
// reason is that C++ injects the name of a class as a member of the
|
// iterator is properly implemented for the container.
|
||||||
|
//
|
||||||
|
// For pre-C++11 that we look for both C::iterator and C::const_iterator.
|
||||||
|
// The reason is that C++ injects the name of a class as a member of the
|
||||||
// class itself (e.g. you can refer to class iterator as either
|
// class itself (e.g. you can refer to class iterator as either
|
||||||
// 'iterator' or 'iterator::iterator'). If we look for C::iterator
|
// 'iterator' or 'iterator::iterator'). If we look for C::iterator
|
||||||
// only, for example, we would mistakenly think that a class named
|
// only, for example, we would mistakenly think that a class named
|
||||||
|
@ -928,17 +889,96 @@ struct IsAProtocolMessage
|
||||||
// IsContainerTest(typename C::const_iterator*) and
|
// IsContainerTest(typename C::const_iterator*) and
|
||||||
// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
|
// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
|
||||||
typedef int IsContainer;
|
typedef int IsContainer;
|
||||||
|
#if GTEST_LANG_CXX11
|
||||||
|
template <class C,
|
||||||
|
class Iterator = decltype(::std::declval<const C&>().begin()),
|
||||||
|
class = decltype(::std::declval<const C&>().end()),
|
||||||
|
class = decltype(++::std::declval<Iterator&>()),
|
||||||
|
class = decltype(*::std::declval<Iterator>()),
|
||||||
|
class = typename C::const_iterator>
|
||||||
|
IsContainer IsContainerTest(int /* dummy */) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
template <class C>
|
template <class C>
|
||||||
IsContainer IsContainerTest(int /* dummy */,
|
IsContainer IsContainerTest(int /* dummy */,
|
||||||
typename C::iterator* /* it */ = NULL,
|
typename C::iterator* /* it */ = NULL,
|
||||||
typename C::const_iterator* /* const_it */ = NULL) {
|
typename C::const_iterator* /* const_it */ = NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif // GTEST_LANG_CXX11
|
||||||
|
|
||||||
typedef char IsNotContainer;
|
typedef char IsNotContainer;
|
||||||
template <class C>
|
template <class C>
|
||||||
IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; }
|
IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; }
|
||||||
|
|
||||||
|
// Trait to detect whether a type T is a hash table.
|
||||||
|
// The heuristic used is that the type contains an inner type `hasher` and does
|
||||||
|
// not contain an inner type `reverse_iterator`.
|
||||||
|
// If the container is iterable in reverse, then order might actually matter.
|
||||||
|
template <typename T>
|
||||||
|
struct IsHashTable {
|
||||||
|
private:
|
||||||
|
template <typename U>
|
||||||
|
static char test(typename U::hasher*, typename U::reverse_iterator*);
|
||||||
|
template <typename U>
|
||||||
|
static int test(typename U::hasher*, ...);
|
||||||
|
template <typename U>
|
||||||
|
static char test(...);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static const bool value = sizeof(test<T>(0, 0)) == sizeof(int);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
const bool IsHashTable<T>::value;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct VoidT {
|
||||||
|
typedef void value_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename = void>
|
||||||
|
struct HasValueType : false_type {};
|
||||||
|
template <typename T>
|
||||||
|
struct HasValueType<T, VoidT<typename T::value_type> > : true_type {
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename C,
|
||||||
|
bool = sizeof(IsContainerTest<C>(0)) == sizeof(IsContainer),
|
||||||
|
bool = HasValueType<C>::value>
|
||||||
|
struct IsRecursiveContainerImpl;
|
||||||
|
|
||||||
|
template <typename C, bool HV>
|
||||||
|
struct IsRecursiveContainerImpl<C, false, HV> : public false_type {};
|
||||||
|
|
||||||
|
// Since the IsRecursiveContainerImpl depends on the IsContainerTest we need to
|
||||||
|
// obey the same inconsistencies as the IsContainerTest, namely check if
|
||||||
|
// something is a container is relying on only const_iterator in C++11 and
|
||||||
|
// is relying on both const_iterator and iterator otherwise
|
||||||
|
template <typename C>
|
||||||
|
struct IsRecursiveContainerImpl<C, true, false> : public false_type {};
|
||||||
|
|
||||||
|
template <typename C>
|
||||||
|
struct IsRecursiveContainerImpl<C, true, true> {
|
||||||
|
#if GTEST_LANG_CXX11
|
||||||
|
typedef typename IteratorTraits<typename C::const_iterator>::value_type
|
||||||
|
value_type;
|
||||||
|
#else
|
||||||
|
typedef typename IteratorTraits<typename C::iterator>::value_type value_type;
|
||||||
|
#endif
|
||||||
|
typedef is_same<value_type, C> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
// IsRecursiveContainer<Type> is a unary compile-time predicate that
|
||||||
|
// evaluates whether C is a recursive container type. A recursive container
|
||||||
|
// type is a container type whose value_type is equal to the container type
|
||||||
|
// itself. An example for a recursive container type is
|
||||||
|
// boost::filesystem::path, whose iterator has a value_type that is equal to
|
||||||
|
// boost::filesystem::path.
|
||||||
|
template <typename C>
|
||||||
|
struct IsRecursiveContainer : public IsRecursiveContainerImpl<C>::type {};
|
||||||
|
|
||||||
// EnableIf<condition>::type is void when 'Cond' is true, and
|
// EnableIf<condition>::type is void when 'Cond' is true, and
|
||||||
// undefined when 'Cond' is false. To use SFINAE to make a function
|
// undefined when 'Cond' is false. To use SFINAE to make a function
|
||||||
// overload only apply when a particular expression is true, add
|
// overload only apply when a particular expression is true, add
|
||||||
|
@ -1070,7 +1110,7 @@ class NativeArray {
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
kCheckTypeIsNotConstOrAReference = StaticAssertTypeEqHelper<
|
kCheckTypeIsNotConstOrAReference = StaticAssertTypeEqHelper<
|
||||||
Element, GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>::value,
|
Element, GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>::value
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initializes this object with a copy of the input.
|
// Initializes this object with a copy of the input.
|
||||||
|
@ -1115,7 +1155,7 @@ class NativeArray {
|
||||||
#define GTEST_SUCCESS_(message) \
|
#define GTEST_SUCCESS_(message) \
|
||||||
GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
|
GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
|
||||||
|
|
||||||
// Suppresses MSVC warnings 4072 (unreachable code) for the code following
|
// Suppress MSVC warning 4702 (unreachable code) for the code following
|
||||||
// statement if it returns or throws (or doesn't return or throw in some
|
// statement if it returns or throws (or doesn't return or throw in some
|
||||||
// situations).
|
// situations).
|
||||||
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
|
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
|
||||||
|
@ -1235,4 +1275,3 @@ class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
|
||||||
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
|
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||||
|
|
||||||
|
|
|
@ -46,14 +46,9 @@
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
||||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
||||||
|
|
||||||
// scripts/fuse_gtest.py depends on gtest's own header being #included
|
|
||||||
// *unconditionally*. Therefore these #includes cannot be moved
|
|
||||||
// inside #if GTEST_HAS_PARAM_TEST.
|
|
||||||
#include "gtest/internal/gtest-param-util.h"
|
#include "gtest/internal/gtest-param-util.h"
|
||||||
#include "gtest/internal/gtest-port.h"
|
#include "gtest/internal/gtest-port.h"
|
||||||
|
|
||||||
#if GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
// Forward declarations of ValuesIn(), which is implemented in
|
// Forward declarations of ValuesIn(), which is implemented in
|
||||||
|
@ -3208,7 +3203,7 @@ class CartesianProductGenerator2
|
||||||
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
||||||
return new Iterator(*this);
|
return new Iterator(*this);
|
||||||
}
|
}
|
||||||
virtual const ParamType* Current() const { return ¤t_value_; }
|
virtual const ParamType* Current() const { return current_value_.get(); }
|
||||||
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
||||||
// Having the same base generator guarantees that the other
|
// Having the same base generator guarantees that the other
|
||||||
// iterator is of the same type and we can downcast.
|
// iterator is of the same type and we can downcast.
|
||||||
|
@ -3240,7 +3235,7 @@ class CartesianProductGenerator2
|
||||||
|
|
||||||
void ComputeCurrentValue() {
|
void ComputeCurrentValue() {
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
current_value_ = ParamType(*current1_, *current2_);
|
current_value_.reset(new ParamType(*current1_, *current2_));
|
||||||
}
|
}
|
||||||
bool AtEnd() const {
|
bool AtEnd() const {
|
||||||
// We must report iterator past the end of the range when either of the
|
// We must report iterator past the end of the range when either of the
|
||||||
|
@ -3262,7 +3257,7 @@ class CartesianProductGenerator2
|
||||||
const typename ParamGenerator<T2>::iterator begin2_;
|
const typename ParamGenerator<T2>::iterator begin2_;
|
||||||
const typename ParamGenerator<T2>::iterator end2_;
|
const typename ParamGenerator<T2>::iterator end2_;
|
||||||
typename ParamGenerator<T2>::iterator current2_;
|
typename ParamGenerator<T2>::iterator current2_;
|
||||||
ParamType current_value_;
|
linked_ptr<ParamType> current_value_;
|
||||||
}; // class CartesianProductGenerator2::Iterator
|
}; // class CartesianProductGenerator2::Iterator
|
||||||
|
|
||||||
// No implementation - assignment is unsupported.
|
// No implementation - assignment is unsupported.
|
||||||
|
@ -3331,7 +3326,7 @@ class CartesianProductGenerator3
|
||||||
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
||||||
return new Iterator(*this);
|
return new Iterator(*this);
|
||||||
}
|
}
|
||||||
virtual const ParamType* Current() const { return ¤t_value_; }
|
virtual const ParamType* Current() const { return current_value_.get(); }
|
||||||
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
||||||
// Having the same base generator guarantees that the other
|
// Having the same base generator guarantees that the other
|
||||||
// iterator is of the same type and we can downcast.
|
// iterator is of the same type and we can downcast.
|
||||||
|
@ -3367,7 +3362,7 @@ class CartesianProductGenerator3
|
||||||
|
|
||||||
void ComputeCurrentValue() {
|
void ComputeCurrentValue() {
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
current_value_ = ParamType(*current1_, *current2_, *current3_);
|
current_value_.reset(new ParamType(*current1_, *current2_, *current3_));
|
||||||
}
|
}
|
||||||
bool AtEnd() const {
|
bool AtEnd() const {
|
||||||
// We must report iterator past the end of the range when either of the
|
// We must report iterator past the end of the range when either of the
|
||||||
|
@ -3393,7 +3388,7 @@ class CartesianProductGenerator3
|
||||||
const typename ParamGenerator<T3>::iterator begin3_;
|
const typename ParamGenerator<T3>::iterator begin3_;
|
||||||
const typename ParamGenerator<T3>::iterator end3_;
|
const typename ParamGenerator<T3>::iterator end3_;
|
||||||
typename ParamGenerator<T3>::iterator current3_;
|
typename ParamGenerator<T3>::iterator current3_;
|
||||||
ParamType current_value_;
|
linked_ptr<ParamType> current_value_;
|
||||||
}; // class CartesianProductGenerator3::Iterator
|
}; // class CartesianProductGenerator3::Iterator
|
||||||
|
|
||||||
// No implementation - assignment is unsupported.
|
// No implementation - assignment is unsupported.
|
||||||
|
@ -3472,7 +3467,7 @@ class CartesianProductGenerator4
|
||||||
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
||||||
return new Iterator(*this);
|
return new Iterator(*this);
|
||||||
}
|
}
|
||||||
virtual const ParamType* Current() const { return ¤t_value_; }
|
virtual const ParamType* Current() const { return current_value_.get(); }
|
||||||
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
||||||
// Having the same base generator guarantees that the other
|
// Having the same base generator guarantees that the other
|
||||||
// iterator is of the same type and we can downcast.
|
// iterator is of the same type and we can downcast.
|
||||||
|
@ -3512,8 +3507,8 @@ class CartesianProductGenerator4
|
||||||
|
|
||||||
void ComputeCurrentValue() {
|
void ComputeCurrentValue() {
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
current_value_ = ParamType(*current1_, *current2_, *current3_,
|
current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
|
||||||
*current4_);
|
*current4_));
|
||||||
}
|
}
|
||||||
bool AtEnd() const {
|
bool AtEnd() const {
|
||||||
// We must report iterator past the end of the range when either of the
|
// We must report iterator past the end of the range when either of the
|
||||||
|
@ -3543,7 +3538,7 @@ class CartesianProductGenerator4
|
||||||
const typename ParamGenerator<T4>::iterator begin4_;
|
const typename ParamGenerator<T4>::iterator begin4_;
|
||||||
const typename ParamGenerator<T4>::iterator end4_;
|
const typename ParamGenerator<T4>::iterator end4_;
|
||||||
typename ParamGenerator<T4>::iterator current4_;
|
typename ParamGenerator<T4>::iterator current4_;
|
||||||
ParamType current_value_;
|
linked_ptr<ParamType> current_value_;
|
||||||
}; // class CartesianProductGenerator4::Iterator
|
}; // class CartesianProductGenerator4::Iterator
|
||||||
|
|
||||||
// No implementation - assignment is unsupported.
|
// No implementation - assignment is unsupported.
|
||||||
|
@ -3630,7 +3625,7 @@ class CartesianProductGenerator5
|
||||||
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
||||||
return new Iterator(*this);
|
return new Iterator(*this);
|
||||||
}
|
}
|
||||||
virtual const ParamType* Current() const { return ¤t_value_; }
|
virtual const ParamType* Current() const { return current_value_.get(); }
|
||||||
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
||||||
// Having the same base generator guarantees that the other
|
// Having the same base generator guarantees that the other
|
||||||
// iterator is of the same type and we can downcast.
|
// iterator is of the same type and we can downcast.
|
||||||
|
@ -3674,8 +3669,8 @@ class CartesianProductGenerator5
|
||||||
|
|
||||||
void ComputeCurrentValue() {
|
void ComputeCurrentValue() {
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
current_value_ = ParamType(*current1_, *current2_, *current3_,
|
current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
|
||||||
*current4_, *current5_);
|
*current4_, *current5_));
|
||||||
}
|
}
|
||||||
bool AtEnd() const {
|
bool AtEnd() const {
|
||||||
// We must report iterator past the end of the range when either of the
|
// We must report iterator past the end of the range when either of the
|
||||||
|
@ -3709,7 +3704,7 @@ class CartesianProductGenerator5
|
||||||
const typename ParamGenerator<T5>::iterator begin5_;
|
const typename ParamGenerator<T5>::iterator begin5_;
|
||||||
const typename ParamGenerator<T5>::iterator end5_;
|
const typename ParamGenerator<T5>::iterator end5_;
|
||||||
typename ParamGenerator<T5>::iterator current5_;
|
typename ParamGenerator<T5>::iterator current5_;
|
||||||
ParamType current_value_;
|
linked_ptr<ParamType> current_value_;
|
||||||
}; // class CartesianProductGenerator5::Iterator
|
}; // class CartesianProductGenerator5::Iterator
|
||||||
|
|
||||||
// No implementation - assignment is unsupported.
|
// No implementation - assignment is unsupported.
|
||||||
|
@ -3807,7 +3802,7 @@ class CartesianProductGenerator6
|
||||||
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
||||||
return new Iterator(*this);
|
return new Iterator(*this);
|
||||||
}
|
}
|
||||||
virtual const ParamType* Current() const { return ¤t_value_; }
|
virtual const ParamType* Current() const { return current_value_.get(); }
|
||||||
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
||||||
// Having the same base generator guarantees that the other
|
// Having the same base generator guarantees that the other
|
||||||
// iterator is of the same type and we can downcast.
|
// iterator is of the same type and we can downcast.
|
||||||
|
@ -3855,8 +3850,8 @@ class CartesianProductGenerator6
|
||||||
|
|
||||||
void ComputeCurrentValue() {
|
void ComputeCurrentValue() {
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
current_value_ = ParamType(*current1_, *current2_, *current3_,
|
current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
|
||||||
*current4_, *current5_, *current6_);
|
*current4_, *current5_, *current6_));
|
||||||
}
|
}
|
||||||
bool AtEnd() const {
|
bool AtEnd() const {
|
||||||
// We must report iterator past the end of the range when either of the
|
// We must report iterator past the end of the range when either of the
|
||||||
|
@ -3894,7 +3889,7 @@ class CartesianProductGenerator6
|
||||||
const typename ParamGenerator<T6>::iterator begin6_;
|
const typename ParamGenerator<T6>::iterator begin6_;
|
||||||
const typename ParamGenerator<T6>::iterator end6_;
|
const typename ParamGenerator<T6>::iterator end6_;
|
||||||
typename ParamGenerator<T6>::iterator current6_;
|
typename ParamGenerator<T6>::iterator current6_;
|
||||||
ParamType current_value_;
|
linked_ptr<ParamType> current_value_;
|
||||||
}; // class CartesianProductGenerator6::Iterator
|
}; // class CartesianProductGenerator6::Iterator
|
||||||
|
|
||||||
// No implementation - assignment is unsupported.
|
// No implementation - assignment is unsupported.
|
||||||
|
@ -4001,7 +3996,7 @@ class CartesianProductGenerator7
|
||||||
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
||||||
return new Iterator(*this);
|
return new Iterator(*this);
|
||||||
}
|
}
|
||||||
virtual const ParamType* Current() const { return ¤t_value_; }
|
virtual const ParamType* Current() const { return current_value_.get(); }
|
||||||
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
||||||
// Having the same base generator guarantees that the other
|
// Having the same base generator guarantees that the other
|
||||||
// iterator is of the same type and we can downcast.
|
// iterator is of the same type and we can downcast.
|
||||||
|
@ -4053,8 +4048,8 @@ class CartesianProductGenerator7
|
||||||
|
|
||||||
void ComputeCurrentValue() {
|
void ComputeCurrentValue() {
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
current_value_ = ParamType(*current1_, *current2_, *current3_,
|
current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
|
||||||
*current4_, *current5_, *current6_, *current7_);
|
*current4_, *current5_, *current6_, *current7_));
|
||||||
}
|
}
|
||||||
bool AtEnd() const {
|
bool AtEnd() const {
|
||||||
// We must report iterator past the end of the range when either of the
|
// We must report iterator past the end of the range when either of the
|
||||||
|
@ -4096,7 +4091,7 @@ class CartesianProductGenerator7
|
||||||
const typename ParamGenerator<T7>::iterator begin7_;
|
const typename ParamGenerator<T7>::iterator begin7_;
|
||||||
const typename ParamGenerator<T7>::iterator end7_;
|
const typename ParamGenerator<T7>::iterator end7_;
|
||||||
typename ParamGenerator<T7>::iterator current7_;
|
typename ParamGenerator<T7>::iterator current7_;
|
||||||
ParamType current_value_;
|
linked_ptr<ParamType> current_value_;
|
||||||
}; // class CartesianProductGenerator7::Iterator
|
}; // class CartesianProductGenerator7::Iterator
|
||||||
|
|
||||||
// No implementation - assignment is unsupported.
|
// No implementation - assignment is unsupported.
|
||||||
|
@ -4214,7 +4209,7 @@ class CartesianProductGenerator8
|
||||||
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
||||||
return new Iterator(*this);
|
return new Iterator(*this);
|
||||||
}
|
}
|
||||||
virtual const ParamType* Current() const { return ¤t_value_; }
|
virtual const ParamType* Current() const { return current_value_.get(); }
|
||||||
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
||||||
// Having the same base generator guarantees that the other
|
// Having the same base generator guarantees that the other
|
||||||
// iterator is of the same type and we can downcast.
|
// iterator is of the same type and we can downcast.
|
||||||
|
@ -4270,8 +4265,8 @@ class CartesianProductGenerator8
|
||||||
|
|
||||||
void ComputeCurrentValue() {
|
void ComputeCurrentValue() {
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
current_value_ = ParamType(*current1_, *current2_, *current3_,
|
current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
|
||||||
*current4_, *current5_, *current6_, *current7_, *current8_);
|
*current4_, *current5_, *current6_, *current7_, *current8_));
|
||||||
}
|
}
|
||||||
bool AtEnd() const {
|
bool AtEnd() const {
|
||||||
// We must report iterator past the end of the range when either of the
|
// We must report iterator past the end of the range when either of the
|
||||||
|
@ -4317,7 +4312,7 @@ class CartesianProductGenerator8
|
||||||
const typename ParamGenerator<T8>::iterator begin8_;
|
const typename ParamGenerator<T8>::iterator begin8_;
|
||||||
const typename ParamGenerator<T8>::iterator end8_;
|
const typename ParamGenerator<T8>::iterator end8_;
|
||||||
typename ParamGenerator<T8>::iterator current8_;
|
typename ParamGenerator<T8>::iterator current8_;
|
||||||
ParamType current_value_;
|
linked_ptr<ParamType> current_value_;
|
||||||
}; // class CartesianProductGenerator8::Iterator
|
}; // class CartesianProductGenerator8::Iterator
|
||||||
|
|
||||||
// No implementation - assignment is unsupported.
|
// No implementation - assignment is unsupported.
|
||||||
|
@ -4443,7 +4438,7 @@ class CartesianProductGenerator9
|
||||||
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
||||||
return new Iterator(*this);
|
return new Iterator(*this);
|
||||||
}
|
}
|
||||||
virtual const ParamType* Current() const { return ¤t_value_; }
|
virtual const ParamType* Current() const { return current_value_.get(); }
|
||||||
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
||||||
// Having the same base generator guarantees that the other
|
// Having the same base generator guarantees that the other
|
||||||
// iterator is of the same type and we can downcast.
|
// iterator is of the same type and we can downcast.
|
||||||
|
@ -4503,9 +4498,9 @@ class CartesianProductGenerator9
|
||||||
|
|
||||||
void ComputeCurrentValue() {
|
void ComputeCurrentValue() {
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
current_value_ = ParamType(*current1_, *current2_, *current3_,
|
current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
|
||||||
*current4_, *current5_, *current6_, *current7_, *current8_,
|
*current4_, *current5_, *current6_, *current7_, *current8_,
|
||||||
*current9_);
|
*current9_));
|
||||||
}
|
}
|
||||||
bool AtEnd() const {
|
bool AtEnd() const {
|
||||||
// We must report iterator past the end of the range when either of the
|
// We must report iterator past the end of the range when either of the
|
||||||
|
@ -4555,7 +4550,7 @@ class CartesianProductGenerator9
|
||||||
const typename ParamGenerator<T9>::iterator begin9_;
|
const typename ParamGenerator<T9>::iterator begin9_;
|
||||||
const typename ParamGenerator<T9>::iterator end9_;
|
const typename ParamGenerator<T9>::iterator end9_;
|
||||||
typename ParamGenerator<T9>::iterator current9_;
|
typename ParamGenerator<T9>::iterator current9_;
|
||||||
ParamType current_value_;
|
linked_ptr<ParamType> current_value_;
|
||||||
}; // class CartesianProductGenerator9::Iterator
|
}; // class CartesianProductGenerator9::Iterator
|
||||||
|
|
||||||
// No implementation - assignment is unsupported.
|
// No implementation - assignment is unsupported.
|
||||||
|
@ -4690,7 +4685,7 @@ class CartesianProductGenerator10
|
||||||
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
||||||
return new Iterator(*this);
|
return new Iterator(*this);
|
||||||
}
|
}
|
||||||
virtual const ParamType* Current() const { return ¤t_value_; }
|
virtual const ParamType* Current() const { return current_value_.get(); }
|
||||||
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
||||||
// Having the same base generator guarantees that the other
|
// Having the same base generator guarantees that the other
|
||||||
// iterator is of the same type and we can downcast.
|
// iterator is of the same type and we can downcast.
|
||||||
|
@ -4754,9 +4749,9 @@ class CartesianProductGenerator10
|
||||||
|
|
||||||
void ComputeCurrentValue() {
|
void ComputeCurrentValue() {
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
current_value_ = ParamType(*current1_, *current2_, *current3_,
|
current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
|
||||||
*current4_, *current5_, *current6_, *current7_, *current8_,
|
*current4_, *current5_, *current6_, *current7_, *current8_,
|
||||||
*current9_, *current10_);
|
*current9_, *current10_));
|
||||||
}
|
}
|
||||||
bool AtEnd() const {
|
bool AtEnd() const {
|
||||||
// We must report iterator past the end of the range when either of the
|
// We must report iterator past the end of the range when either of the
|
||||||
|
@ -4810,7 +4805,7 @@ class CartesianProductGenerator10
|
||||||
const typename ParamGenerator<T10>::iterator begin10_;
|
const typename ParamGenerator<T10>::iterator begin10_;
|
||||||
const typename ParamGenerator<T10>::iterator end10_;
|
const typename ParamGenerator<T10>::iterator end10_;
|
||||||
typename ParamGenerator<T10>::iterator current10_;
|
typename ParamGenerator<T10>::iterator current10_;
|
||||||
ParamType current_value_;
|
linked_ptr<ParamType> current_value_;
|
||||||
}; // class CartesianProductGenerator10::Iterator
|
}; // class CartesianProductGenerator10::Iterator
|
||||||
|
|
||||||
// No implementation - assignment is unsupported.
|
// No implementation - assignment is unsupported.
|
||||||
|
@ -5141,6 +5136,4 @@ CartesianProductHolder10(const Generator1& g1, const Generator2& g2,
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
|
||||||
#endif // GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
||||||
|
|
|
@ -45,14 +45,9 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
||||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
||||||
|
|
||||||
// scripts/fuse_gtest.py depends on gtest's own header being #included
|
|
||||||
// *unconditionally*. Therefore these #includes cannot be moved
|
|
||||||
// inside #if GTEST_HAS_PARAM_TEST.
|
|
||||||
#include "gtest/internal/gtest-param-util.h"
|
#include "gtest/internal/gtest-param-util.h"
|
||||||
#include "gtest/internal/gtest-port.h"
|
#include "gtest/internal/gtest-port.h"
|
||||||
|
|
||||||
#if GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
// Forward declarations of ValuesIn(), which is implemented in
|
// Forward declarations of ValuesIn(), which is implemented in
|
||||||
|
@ -165,7 +160,7 @@ $for k [[
|
||||||
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
virtual ParamIteratorInterface<ParamType>* Clone() const {
|
||||||
return new Iterator(*this);
|
return new Iterator(*this);
|
||||||
}
|
}
|
||||||
virtual const ParamType* Current() const { return ¤t_value_; }
|
virtual const ParamType* Current() const { return current_value_.get(); }
|
||||||
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
|
||||||
// Having the same base generator guarantees that the other
|
// Having the same base generator guarantees that the other
|
||||||
// iterator is of the same type and we can downcast.
|
// iterator is of the same type and we can downcast.
|
||||||
|
@ -197,7 +192,7 @@ $for k [[
|
||||||
|
|
||||||
void ComputeCurrentValue() {
|
void ComputeCurrentValue() {
|
||||||
if (!AtEnd())
|
if (!AtEnd())
|
||||||
current_value_ = ParamType($for j, [[*current$(j)_]]);
|
current_value_.reset(new ParamType($for j, [[*current$(j)_]]));
|
||||||
}
|
}
|
||||||
bool AtEnd() const {
|
bool AtEnd() const {
|
||||||
// We must report iterator past the end of the range when either of the
|
// We must report iterator past the end of the range when either of the
|
||||||
|
@ -222,7 +217,7 @@ $for j [[
|
||||||
typename ParamGenerator<T$j>::iterator current$(j)_;
|
typename ParamGenerator<T$j>::iterator current$(j)_;
|
||||||
]]
|
]]
|
||||||
|
|
||||||
ParamType current_value_;
|
linked_ptr<ParamType> current_value_;
|
||||||
}; // class CartesianProductGenerator$i::Iterator
|
}; // class CartesianProductGenerator$i::Iterator
|
||||||
|
|
||||||
// No implementation - assignment is unsupported.
|
// No implementation - assignment is unsupported.
|
||||||
|
@ -281,6 +276,4 @@ $for j [[
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
|
||||||
#endif // GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
||||||
|
|
|
@ -41,16 +41,11 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// scripts/fuse_gtest.py depends on gtest's own header being #included
|
|
||||||
// *unconditionally*. Therefore these #includes cannot be moved
|
|
||||||
// inside #if GTEST_HAS_PARAM_TEST.
|
|
||||||
#include "gtest/internal/gtest-internal.h"
|
#include "gtest/internal/gtest-internal.h"
|
||||||
#include "gtest/internal/gtest-linked_ptr.h"
|
#include "gtest/internal/gtest-linked_ptr.h"
|
||||||
#include "gtest/internal/gtest-port.h"
|
#include "gtest/internal/gtest-port.h"
|
||||||
#include "gtest/gtest-printers.h"
|
#include "gtest/gtest-printers.h"
|
||||||
|
|
||||||
#if GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
// Input to a parameterized test name generator, describing a test parameter.
|
// Input to a parameterized test name generator, describing a test parameter.
|
||||||
|
@ -472,7 +467,7 @@ class ParameterizedTestCaseInfoBase {
|
||||||
virtual ~ParameterizedTestCaseInfoBase() {}
|
virtual ~ParameterizedTestCaseInfoBase() {}
|
||||||
|
|
||||||
// Base part of test case name for display purposes.
|
// Base part of test case name for display purposes.
|
||||||
virtual const string& GetTestCaseName() const = 0;
|
virtual const std::string& GetTestCaseName() const = 0;
|
||||||
// Test case id to verify identity.
|
// Test case id to verify identity.
|
||||||
virtual TypeId GetTestCaseTypeId() const = 0;
|
virtual TypeId GetTestCaseTypeId() const = 0;
|
||||||
// UnitTest class invokes this method to register tests in this
|
// UnitTest class invokes this method to register tests in this
|
||||||
|
@ -511,7 +506,7 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
|
||||||
: test_case_name_(name), code_location_(code_location) {}
|
: test_case_name_(name), code_location_(code_location) {}
|
||||||
|
|
||||||
// Test case base name for display purposes.
|
// Test case base name for display purposes.
|
||||||
virtual const string& GetTestCaseName() const { return test_case_name_; }
|
virtual const std::string& GetTestCaseName() const { return test_case_name_; }
|
||||||
// Test case id to verify identity.
|
// Test case id to verify identity.
|
||||||
virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }
|
virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }
|
||||||
// TEST_P macro uses AddTestPattern() to record information
|
// TEST_P macro uses AddTestPattern() to record information
|
||||||
|
@ -529,11 +524,10 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
|
||||||
}
|
}
|
||||||
// INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information
|
// INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information
|
||||||
// about a generator.
|
// about a generator.
|
||||||
int AddTestCaseInstantiation(const string& instantiation_name,
|
int AddTestCaseInstantiation(const std::string& instantiation_name,
|
||||||
GeneratorCreationFunc* func,
|
GeneratorCreationFunc* func,
|
||||||
ParamNameGeneratorFunc* name_func,
|
ParamNameGeneratorFunc* name_func,
|
||||||
const char* file,
|
const char* file, int line) {
|
||||||
int line) {
|
|
||||||
instantiations_.push_back(
|
instantiations_.push_back(
|
||||||
InstantiationInfo(instantiation_name, func, name_func, file, line));
|
InstantiationInfo(instantiation_name, func, name_func, file, line));
|
||||||
return 0; // Return value used only to run this method in namespace scope.
|
return 0; // Return value used only to run this method in namespace scope.
|
||||||
|
@ -550,13 +544,13 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
|
||||||
for (typename InstantiationContainer::iterator gen_it =
|
for (typename InstantiationContainer::iterator gen_it =
|
||||||
instantiations_.begin(); gen_it != instantiations_.end();
|
instantiations_.begin(); gen_it != instantiations_.end();
|
||||||
++gen_it) {
|
++gen_it) {
|
||||||
const string& instantiation_name = gen_it->name;
|
const std::string& instantiation_name = gen_it->name;
|
||||||
ParamGenerator<ParamType> generator((*gen_it->generator)());
|
ParamGenerator<ParamType> generator((*gen_it->generator)());
|
||||||
ParamNameGeneratorFunc* name_func = gen_it->name_func;
|
ParamNameGeneratorFunc* name_func = gen_it->name_func;
|
||||||
const char* file = gen_it->file;
|
const char* file = gen_it->file;
|
||||||
int line = gen_it->line;
|
int line = gen_it->line;
|
||||||
|
|
||||||
string test_case_name;
|
std::string test_case_name;
|
||||||
if ( !instantiation_name.empty() )
|
if ( !instantiation_name.empty() )
|
||||||
test_case_name = instantiation_name + "/";
|
test_case_name = instantiation_name + "/";
|
||||||
test_case_name += test_info->test_case_base_name;
|
test_case_name += test_info->test_case_base_name;
|
||||||
|
@ -609,8 +603,8 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
|
||||||
test_base_name(a_test_base_name),
|
test_base_name(a_test_base_name),
|
||||||
test_meta_factory(a_test_meta_factory) {}
|
test_meta_factory(a_test_meta_factory) {}
|
||||||
|
|
||||||
const string test_case_base_name;
|
const std::string test_case_base_name;
|
||||||
const string test_base_name;
|
const std::string test_base_name;
|
||||||
const scoped_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
|
const scoped_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
|
||||||
};
|
};
|
||||||
typedef ::std::vector<linked_ptr<TestInfo> > TestInfoContainer;
|
typedef ::std::vector<linked_ptr<TestInfo> > TestInfoContainer;
|
||||||
|
@ -651,7 +645,7 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string test_case_name_;
|
const std::string test_case_name_;
|
||||||
CodeLocation code_location_;
|
CodeLocation code_location_;
|
||||||
TestInfoContainer tests_;
|
TestInfoContainer tests_;
|
||||||
InstantiationContainer instantiations_;
|
InstantiationContainer instantiations_;
|
||||||
|
@ -726,6 +720,4 @@ class ParameterizedTestCaseRegistry {
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
|
||||||
#endif // GTEST_HAS_PARAM_TEST
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
|
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// (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.
|
||||||
//
|
//
|
||||||
// The Google C++ Testing Framework (Google Test)
|
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||||
//
|
//
|
||||||
// This header file defines the GTEST_OS_* macro.
|
// This header file defines the GTEST_OS_* macro.
|
||||||
// It is separate from gtest-port.h so that custom/gtest-port.h can include it.
|
// It is separate from gtest-port.h so that custom/gtest-port.h can include it.
|
||||||
|
@ -54,6 +54,9 @@
|
||||||
# define GTEST_OS_WINDOWS_PHONE 1
|
# define GTEST_OS_WINDOWS_PHONE 1
|
||||||
# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||||
# define GTEST_OS_WINDOWS_RT 1
|
# define GTEST_OS_WINDOWS_RT 1
|
||||||
|
# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
|
||||||
|
# define GTEST_OS_WINDOWS_PHONE 1
|
||||||
|
# define GTEST_OS_WINDOWS_TV_TITLE 1
|
||||||
# else
|
# else
|
||||||
// WINAPI_FAMILY defined but no known partition matched.
|
// WINAPI_FAMILY defined but no known partition matched.
|
||||||
// Default to desktop.
|
// Default to desktop.
|
||||||
|
@ -69,6 +72,8 @@
|
||||||
# endif
|
# endif
|
||||||
#elif defined __FreeBSD__
|
#elif defined __FreeBSD__
|
||||||
# define GTEST_OS_FREEBSD 1
|
# define GTEST_OS_FREEBSD 1
|
||||||
|
#elif defined __Fuchsia__
|
||||||
|
# define GTEST_OS_FUCHSIA 1
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
# define GTEST_OS_LINUX 1
|
# define GTEST_OS_LINUX 1
|
||||||
# if defined __ANDROID__
|
# if defined __ANDROID__
|
||||||
|
@ -84,6 +89,8 @@
|
||||||
# define GTEST_OS_HPUX 1
|
# define GTEST_OS_HPUX 1
|
||||||
#elif defined __native_client__
|
#elif defined __native_client__
|
||||||
# define GTEST_OS_NACL 1
|
# define GTEST_OS_NACL 1
|
||||||
|
#elif defined __NetBSD__
|
||||||
|
# define GTEST_OS_NETBSD 1
|
||||||
#elif defined __OpenBSD__
|
#elif defined __OpenBSD__
|
||||||
# define GTEST_OS_OPENBSD 1
|
# define GTEST_OS_OPENBSD 1
|
||||||
#elif defined __QNX__
|
#elif defined __QNX__
|
||||||
|
|
|
@ -73,11 +73,9 @@
|
||||||
// GTEST_HAS_EXCEPTIONS - Define it to 1/0 to indicate that exceptions
|
// GTEST_HAS_EXCEPTIONS - Define it to 1/0 to indicate that exceptions
|
||||||
// are enabled.
|
// are enabled.
|
||||||
// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string
|
// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string
|
||||||
// is/isn't available (some systems define
|
// is/isn't available
|
||||||
// ::string, which is different to std::string).
|
// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::wstring
|
||||||
// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string
|
// is/isn't available
|
||||||
// is/isn't available (some systems define
|
|
||||||
// ::wstring, which is different to std::wstring).
|
|
||||||
// GTEST_HAS_POSIX_RE - Define it to 1/0 to indicate that POSIX regular
|
// GTEST_HAS_POSIX_RE - Define it to 1/0 to indicate that POSIX regular
|
||||||
// expressions are/aren't available.
|
// expressions are/aren't available.
|
||||||
// GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread.h>
|
// GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread.h>
|
||||||
|
@ -109,6 +107,12 @@
|
||||||
// GTEST_CREATE_SHARED_LIBRARY
|
// GTEST_CREATE_SHARED_LIBRARY
|
||||||
// - Define to 1 when compiling Google Test itself
|
// - Define to 1 when compiling Google Test itself
|
||||||
// as a shared library.
|
// as a shared library.
|
||||||
|
// GTEST_DEFAULT_DEATH_TEST_STYLE
|
||||||
|
// - The default value of --gtest_death_test_style.
|
||||||
|
// The legacy default has been "fast" in the open
|
||||||
|
// source version since 2008. The recommended value
|
||||||
|
// is "threadsafe", and can be set in
|
||||||
|
// custom/gtest-port.h.
|
||||||
|
|
||||||
// Platform-indicating macros
|
// Platform-indicating macros
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
@ -122,12 +126,14 @@
|
||||||
// GTEST_OS_AIX - IBM AIX
|
// GTEST_OS_AIX - IBM AIX
|
||||||
// GTEST_OS_CYGWIN - Cygwin
|
// GTEST_OS_CYGWIN - Cygwin
|
||||||
// GTEST_OS_FREEBSD - FreeBSD
|
// GTEST_OS_FREEBSD - FreeBSD
|
||||||
|
// GTEST_OS_FUCHSIA - Fuchsia
|
||||||
// GTEST_OS_HPUX - HP-UX
|
// GTEST_OS_HPUX - HP-UX
|
||||||
// GTEST_OS_LINUX - Linux
|
// GTEST_OS_LINUX - Linux
|
||||||
// GTEST_OS_LINUX_ANDROID - Google Android
|
// GTEST_OS_LINUX_ANDROID - Google Android
|
||||||
// GTEST_OS_MAC - Mac OS X
|
// GTEST_OS_MAC - Mac OS X
|
||||||
// GTEST_OS_IOS - iOS
|
// GTEST_OS_IOS - iOS
|
||||||
// GTEST_OS_NACL - Google Native Client (NaCl)
|
// GTEST_OS_NACL - Google Native Client (NaCl)
|
||||||
|
// GTEST_OS_NETBSD - NetBSD
|
||||||
// GTEST_OS_OPENBSD - OpenBSD
|
// GTEST_OS_OPENBSD - OpenBSD
|
||||||
// GTEST_OS_QNX - QNX
|
// GTEST_OS_QNX - QNX
|
||||||
// GTEST_OS_SOLARIS - Sun Solaris
|
// GTEST_OS_SOLARIS - Sun Solaris
|
||||||
|
@ -169,7 +175,6 @@
|
||||||
// GTEST_HAS_COMBINE - the Combine() function (for value-parameterized
|
// GTEST_HAS_COMBINE - the Combine() function (for value-parameterized
|
||||||
// tests)
|
// tests)
|
||||||
// GTEST_HAS_DEATH_TEST - death tests
|
// GTEST_HAS_DEATH_TEST - death tests
|
||||||
// GTEST_HAS_PARAM_TEST - value-parameterized tests
|
|
||||||
// GTEST_HAS_TYPED_TEST - typed tests
|
// GTEST_HAS_TYPED_TEST - typed tests
|
||||||
// GTEST_HAS_TYPED_TEST_P - type-parameterized tests
|
// GTEST_HAS_TYPED_TEST_P - type-parameterized tests
|
||||||
// GTEST_IS_THREADSAFE - Google Test is thread-safe.
|
// GTEST_IS_THREADSAFE - Google Test is thread-safe.
|
||||||
|
@ -177,7 +182,7 @@
|
||||||
// GTEST_HAS_POSIX_RE (see above) which users can
|
// GTEST_HAS_POSIX_RE (see above) which users can
|
||||||
// define themselves.
|
// define themselves.
|
||||||
// GTEST_USES_SIMPLE_RE - our own simple regex is used;
|
// GTEST_USES_SIMPLE_RE - our own simple regex is used;
|
||||||
// the above two are mutually exclusive.
|
// the above RE\b(s) are mutually exclusive.
|
||||||
// GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().
|
// GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().
|
||||||
|
|
||||||
// Misc public macros
|
// Misc public macros
|
||||||
|
@ -206,6 +211,7 @@
|
||||||
//
|
//
|
||||||
// C++11 feature wrappers:
|
// C++11 feature wrappers:
|
||||||
//
|
//
|
||||||
|
// testing::internal::forward - portability wrapper for std::forward.
|
||||||
// testing::internal::move - portability wrapper for std::move.
|
// testing::internal::move - portability wrapper for std::move.
|
||||||
//
|
//
|
||||||
// Synchronization:
|
// Synchronization:
|
||||||
|
@ -222,10 +228,9 @@
|
||||||
//
|
//
|
||||||
// Regular expressions:
|
// Regular expressions:
|
||||||
// RE - a simple regular expression class using the POSIX
|
// RE - a simple regular expression class using the POSIX
|
||||||
// Extended Regular Expression syntax on UNIX-like
|
// Extended Regular Expression syntax on UNIX-like platforms
|
||||||
// platforms, or a reduced regular exception syntax on
|
// or a reduced regular exception syntax on other
|
||||||
// other platforms, including Windows.
|
// platforms, including Windows.
|
||||||
//
|
|
||||||
// Logging:
|
// Logging:
|
||||||
// GTEST_LOG_() - logs messages at the specified severity level.
|
// GTEST_LOG_() - logs messages at the specified severity level.
|
||||||
// LogToStderr() - directs all log messages to stderr.
|
// LogToStderr() - directs all log messages to stderr.
|
||||||
|
@ -271,10 +276,12 @@
|
||||||
# include <TargetConditionals.h>
|
# include <TargetConditionals.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Brings in the definition of HAS_GLOBAL_STRING. This must be done
|
||||||
|
// BEFORE we test HAS_GLOBAL_STRING.
|
||||||
|
#include <string> // NOLINT
|
||||||
#include <algorithm> // NOLINT
|
#include <algorithm> // NOLINT
|
||||||
#include <iostream> // NOLINT
|
#include <iostream> // NOLINT
|
||||||
#include <sstream> // NOLINT
|
#include <sstream> // NOLINT
|
||||||
#include <string> // NOLINT
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector> // NOLINT
|
#include <vector> // NOLINT
|
||||||
|
|
||||||
|
@ -355,14 +362,14 @@
|
||||||
#if GTEST_STDLIB_CXX11
|
#if GTEST_STDLIB_CXX11
|
||||||
# define GTEST_HAS_STD_BEGIN_AND_END_ 1
|
# define GTEST_HAS_STD_BEGIN_AND_END_ 1
|
||||||
# define GTEST_HAS_STD_FORWARD_LIST_ 1
|
# define GTEST_HAS_STD_FORWARD_LIST_ 1
|
||||||
# if !defined(_MSC_VER) || (_MSC_FULL_VER >= 190023824) // works only with VS2015U2 and better
|
# if !defined(_MSC_VER) || (_MSC_FULL_VER >= 190023824)
|
||||||
|
// works only with VS2015U2 and better
|
||||||
# define GTEST_HAS_STD_FUNCTION_ 1
|
# define GTEST_HAS_STD_FUNCTION_ 1
|
||||||
# endif
|
# endif
|
||||||
# define GTEST_HAS_STD_INITIALIZER_LIST_ 1
|
# define GTEST_HAS_STD_INITIALIZER_LIST_ 1
|
||||||
# define GTEST_HAS_STD_MOVE_ 1
|
# define GTEST_HAS_STD_MOVE_ 1
|
||||||
# define GTEST_HAS_STD_SHARED_PTR_ 1
|
|
||||||
# define GTEST_HAS_STD_TYPE_TRAITS_ 1
|
|
||||||
# define GTEST_HAS_STD_UNIQUE_PTR_ 1
|
# define GTEST_HAS_STD_UNIQUE_PTR_ 1
|
||||||
|
# define GTEST_HAS_STD_SHARED_PTR_ 1
|
||||||
# define GTEST_HAS_UNORDERED_MAP_ 1
|
# define GTEST_HAS_UNORDERED_MAP_ 1
|
||||||
# define GTEST_HAS_UNORDERED_SET_ 1
|
# define GTEST_HAS_UNORDERED_SET_ 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -463,8 +470,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||||
#ifndef GTEST_HAS_EXCEPTIONS
|
#ifndef GTEST_HAS_EXCEPTIONS
|
||||||
// The user didn't tell us whether exceptions are enabled, so we need
|
// The user didn't tell us whether exceptions are enabled, so we need
|
||||||
// to figure it out.
|
// to figure it out.
|
||||||
# if defined(_MSC_VER) || defined(__BORLANDC__)
|
# if defined(_MSC_VER) && defined(_CPPUNWIND)
|
||||||
// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS
|
// MSVC defines _CPPUNWIND to 1 iff exceptions are enabled.
|
||||||
|
# define GTEST_HAS_EXCEPTIONS 1
|
||||||
|
# elif defined(__BORLANDC__)
|
||||||
|
// C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS
|
||||||
// macro to enable exceptions, so we'll do the same.
|
// macro to enable exceptions, so we'll do the same.
|
||||||
// Assumes that exceptions are enabled by default.
|
// Assumes that exceptions are enabled by default.
|
||||||
# ifndef _HAS_EXCEPTIONS
|
# ifndef _HAS_EXCEPTIONS
|
||||||
|
@ -508,7 +518,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||||
# define GTEST_HAS_STD_STRING 1
|
# define GTEST_HAS_STD_STRING 1
|
||||||
#elif !GTEST_HAS_STD_STRING
|
#elif !GTEST_HAS_STD_STRING
|
||||||
// The user told us that ::std::string isn't available.
|
// The user told us that ::std::string isn't available.
|
||||||
# error "Google Test cannot be used where ::std::string isn't available."
|
# error "::std::string isn't available."
|
||||||
#endif // !defined(GTEST_HAS_STD_STRING)
|
#endif // !defined(GTEST_HAS_STD_STRING)
|
||||||
|
|
||||||
#ifndef GTEST_HAS_GLOBAL_STRING
|
#ifndef GTEST_HAS_GLOBAL_STRING
|
||||||
|
@ -610,8 +620,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||||
//
|
//
|
||||||
// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
|
// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
|
||||||
// to your compiler flags.
|
// to your compiler flags.
|
||||||
# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \
|
#define GTEST_HAS_PTHREAD \
|
||||||
|| GTEST_OS_QNX || GTEST_OS_FREEBSD || GTEST_OS_NACL)
|
(GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \
|
||||||
|
GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA)
|
||||||
#endif // GTEST_HAS_PTHREAD
|
#endif // GTEST_HAS_PTHREAD
|
||||||
|
|
||||||
#if GTEST_HAS_PTHREAD
|
#if GTEST_HAS_PTHREAD
|
||||||
|
@ -626,7 +637,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||||
// Determines if hash_map/hash_set are available.
|
// Determines if hash_map/hash_set are available.
|
||||||
// Only used for testing against those containers.
|
// Only used for testing against those containers.
|
||||||
#if !defined(GTEST_HAS_HASH_MAP_)
|
#if !defined(GTEST_HAS_HASH_MAP_)
|
||||||
# if _MSC_VER
|
# if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||||
# define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available.
|
# define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available.
|
||||||
# define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available.
|
# define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available.
|
||||||
# endif // _MSC_VER
|
# endif // _MSC_VER
|
||||||
|
@ -639,6 +650,14 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||||
# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR)
|
# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR)
|
||||||
// STLport, provided with the Android NDK, has neither <tr1/tuple> or <tuple>.
|
// STLport, provided with the Android NDK, has neither <tr1/tuple> or <tuple>.
|
||||||
# define GTEST_HAS_TR1_TUPLE 0
|
# define GTEST_HAS_TR1_TUPLE 0
|
||||||
|
# elif defined(_MSC_VER) && (_MSC_VER >= 1910)
|
||||||
|
// Prevent `warning C4996: 'std::tr1': warning STL4002:
|
||||||
|
// The non-Standard std::tr1 namespace and TR1-only machinery
|
||||||
|
// are deprecated and will be REMOVED.`
|
||||||
|
# define GTEST_HAS_TR1_TUPLE 0
|
||||||
|
# elif GTEST_LANG_CXX11 && defined(_LIBCPP_VERSION)
|
||||||
|
// libc++ doesn't support TR1.
|
||||||
|
# define GTEST_HAS_TR1_TUPLE 0
|
||||||
# else
|
# else
|
||||||
// The user didn't tell us not to do it, so we assume it's OK.
|
// The user didn't tell us not to do it, so we assume it's OK.
|
||||||
# define GTEST_HAS_TR1_TUPLE 1
|
# define GTEST_HAS_TR1_TUPLE 1
|
||||||
|
@ -648,6 +667,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||||
// Determines whether Google Test's own tr1 tuple implementation
|
// Determines whether Google Test's own tr1 tuple implementation
|
||||||
// should be used.
|
// should be used.
|
||||||
#ifndef GTEST_USE_OWN_TR1_TUPLE
|
#ifndef GTEST_USE_OWN_TR1_TUPLE
|
||||||
|
// We use our own tuple implementation on Symbian.
|
||||||
|
# if GTEST_OS_SYMBIAN
|
||||||
|
# define GTEST_USE_OWN_TR1_TUPLE 1
|
||||||
|
# else
|
||||||
// The user didn't tell us, so we need to figure it out.
|
// The user didn't tell us, so we need to figure it out.
|
||||||
|
|
||||||
// We use our own TR1 tuple if we aren't sure the user has an
|
// We use our own TR1 tuple if we aren't sure the user has an
|
||||||
|
@ -661,7 +684,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||||
// support TR1 tuple. libc++ only provides std::tuple, in C++11 mode,
|
// support TR1 tuple. libc++ only provides std::tuple, in C++11 mode,
|
||||||
// and it can be used with some compilers that define __GNUC__.
|
// and it can be used with some compilers that define __GNUC__.
|
||||||
# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \
|
# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \
|
||||||
&& !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600
|
&& !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) \
|
||||||
|
|| (_MSC_VER >= 1600 && _MSC_VER < 1900)
|
||||||
# define GTEST_ENV_HAS_TR1_TUPLE_ 1
|
# define GTEST_ENV_HAS_TR1_TUPLE_ 1
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -677,12 +701,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||||
# else
|
# else
|
||||||
# define GTEST_USE_OWN_TR1_TUPLE 1
|
# define GTEST_USE_OWN_TR1_TUPLE 1
|
||||||
# endif
|
# endif
|
||||||
|
# endif // GTEST_OS_SYMBIAN
|
||||||
#endif // GTEST_USE_OWN_TR1_TUPLE
|
#endif // GTEST_USE_OWN_TR1_TUPLE
|
||||||
|
|
||||||
// To avoid conditional compilation everywhere, we make it
|
// To avoid conditional compilation we make it gtest-port.h's responsibility
|
||||||
// gtest-port.h's responsibility to #include the header implementing
|
// to #include the header implementing tuple.
|
||||||
// tuple.
|
|
||||||
#if GTEST_HAS_STD_TUPLE_
|
#if GTEST_HAS_STD_TUPLE_
|
||||||
# include <tuple> // IWYU pragma: export
|
# include <tuple> // IWYU pragma: export
|
||||||
# define GTEST_TUPLE_NAMESPACE_ ::std
|
# define GTEST_TUPLE_NAMESPACE_ ::std
|
||||||
|
@ -697,22 +720,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||||
|
|
||||||
# if GTEST_USE_OWN_TR1_TUPLE
|
# if GTEST_USE_OWN_TR1_TUPLE
|
||||||
# include "gtest/internal/gtest-tuple.h" // IWYU pragma: export // NOLINT
|
# include "gtest/internal/gtest-tuple.h" // IWYU pragma: export // NOLINT
|
||||||
# elif GTEST_ENV_HAS_STD_TUPLE_
|
|
||||||
# include <tuple>
|
|
||||||
// C++11 puts its tuple into the ::std namespace rather than
|
|
||||||
// ::std::tr1. gtest expects tuple to live in ::std::tr1, so put it there.
|
|
||||||
// This causes undefined behavior, but supported compilers react in
|
|
||||||
// the way we intend.
|
|
||||||
namespace std {
|
|
||||||
namespace tr1 {
|
|
||||||
using ::std::get;
|
|
||||||
using ::std::make_tuple;
|
|
||||||
using ::std::tuple;
|
|
||||||
using ::std::tuple_element;
|
|
||||||
using ::std::tuple_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# elif GTEST_OS_SYMBIAN
|
# elif GTEST_OS_SYMBIAN
|
||||||
|
|
||||||
// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to
|
// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to
|
||||||
|
@ -742,15 +749,17 @@ using ::std::tuple_size;
|
||||||
# define _TR1_FUNCTIONAL 1
|
# define _TR1_FUNCTIONAL 1
|
||||||
# include <tr1/tuple>
|
# include <tr1/tuple>
|
||||||
# undef _TR1_FUNCTIONAL // Allows the user to #include
|
# undef _TR1_FUNCTIONAL // Allows the user to #include
|
||||||
// <tr1/functional> if he chooses to.
|
// <tr1/functional> if they choose to.
|
||||||
# else
|
# else
|
||||||
# include <tr1/tuple> // NOLINT
|
# include <tr1/tuple> // NOLINT
|
||||||
# endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
|
# endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
|
||||||
|
|
||||||
# else
|
// VS 2010 now has tr1 support.
|
||||||
// If the compiler is not GCC 4.0+, we assume the user is using a
|
# elif _MSC_VER >= 1600
|
||||||
// spec-conforming TR1 implementation.
|
|
||||||
# include <tuple> // IWYU pragma: export // NOLINT
|
# include <tuple> // IWYU pragma: export // NOLINT
|
||||||
|
|
||||||
|
# else // GTEST_USE_OWN_TR1_TUPLE
|
||||||
|
# include <tr1/tuple> // IWYU pragma: export // NOLINT
|
||||||
# endif // GTEST_USE_OWN_TR1_TUPLE
|
# endif // GTEST_USE_OWN_TR1_TUPLE
|
||||||
|
|
||||||
#endif // GTEST_HAS_TR1_TUPLE
|
#endif // GTEST_HAS_TR1_TUPLE
|
||||||
|
@ -804,15 +813,11 @@ using ::std::tuple_size;
|
||||||
(GTEST_OS_MAC && !GTEST_OS_IOS) || \
|
(GTEST_OS_MAC && !GTEST_OS_IOS) || \
|
||||||
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
|
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
|
||||||
GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
|
GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
|
||||||
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD)
|
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || \
|
||||||
|
GTEST_OS_NETBSD || GTEST_OS_FUCHSIA)
|
||||||
# define GTEST_HAS_DEATH_TEST 1
|
# define GTEST_HAS_DEATH_TEST 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We don't support MSVC 7.1 with exceptions disabled now. Therefore
|
|
||||||
// all the compilers we care about are adequate for supporting
|
|
||||||
// value-parameterized tests.
|
|
||||||
#define GTEST_HAS_PARAM_TEST 1
|
|
||||||
|
|
||||||
// Determines whether to support type-driven tests.
|
// Determines whether to support type-driven tests.
|
||||||
|
|
||||||
// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
|
// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
|
||||||
|
@ -827,7 +832,7 @@ using ::std::tuple_size;
|
||||||
// value-parameterized tests are enabled. The implementation doesn't
|
// value-parameterized tests are enabled. The implementation doesn't
|
||||||
// work on Sun Studio since it doesn't understand templated conversion
|
// work on Sun Studio since it doesn't understand templated conversion
|
||||||
// operators.
|
// operators.
|
||||||
#if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC)
|
#if (GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_) && !defined(__SUNPRO_CC)
|
||||||
# define GTEST_HAS_COMBINE 1
|
# define GTEST_HAS_COMBINE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -878,15 +883,39 @@ using ::std::tuple_size;
|
||||||
# define GTEST_ATTRIBUTE_UNUSED_
|
# define GTEST_ATTRIBUTE_UNUSED_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GTEST_LANG_CXX11
|
||||||
|
# define GTEST_CXX11_EQUALS_DELETE_ = delete
|
||||||
|
#else // GTEST_LANG_CXX11
|
||||||
|
# define GTEST_CXX11_EQUALS_DELETE_
|
||||||
|
#endif // GTEST_LANG_CXX11
|
||||||
|
|
||||||
|
// Use this annotation before a function that takes a printf format string.
|
||||||
|
#if (defined(__GNUC__) || defined(__clang__)) && !defined(COMPILER_ICC)
|
||||||
|
# if defined(__MINGW_PRINTF_FORMAT)
|
||||||
|
// MinGW has two different printf implementations. Ensure the format macro
|
||||||
|
// matches the selected implementation. See
|
||||||
|
// https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/.
|
||||||
|
# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
|
||||||
|
__attribute__((__format__(__MINGW_PRINTF_FORMAT, string_index, \
|
||||||
|
first_to_check)))
|
||||||
|
# else
|
||||||
|
# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
|
||||||
|
__attribute__((__format__(__printf__, string_index, first_to_check)))
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// A macro to disallow operator=
|
// A macro to disallow operator=
|
||||||
// This should be used in the private: declarations for a class.
|
// This should be used in the private: declarations for a class.
|
||||||
#define GTEST_DISALLOW_ASSIGN_(type)\
|
#define GTEST_DISALLOW_ASSIGN_(type) \
|
||||||
void operator=(type const &)
|
void operator=(type const &) GTEST_CXX11_EQUALS_DELETE_
|
||||||
|
|
||||||
// A macro to disallow copy constructor and operator=
|
// A macro to disallow copy constructor and operator=
|
||||||
// This should be used in the private: declarations for a class.
|
// This should be used in the private: declarations for a class.
|
||||||
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\
|
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \
|
||||||
type(type const &);\
|
type(type const &) GTEST_CXX11_EQUALS_DELETE_; \
|
||||||
GTEST_DISALLOW_ASSIGN_(type)
|
GTEST_DISALLOW_ASSIGN_(type)
|
||||||
|
|
||||||
// Tell the compiler to warn about unused return values for functions declared
|
// Tell the compiler to warn about unused return values for functions declared
|
||||||
|
@ -934,6 +963,11 @@ using ::std::tuple_size;
|
||||||
|
|
||||||
#endif // GTEST_HAS_SEH
|
#endif // GTEST_HAS_SEH
|
||||||
|
|
||||||
|
// GTEST_API_ qualifies all symbols that must be exported. The definitions below
|
||||||
|
// are guarded by #ifndef to give embedders a chance to define GTEST_API_ in
|
||||||
|
// gtest/internal/custom/gtest-port.h
|
||||||
|
#ifndef GTEST_API_
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# if GTEST_LINKED_AS_SHARED_LIBRARY
|
# if GTEST_LINKED_AS_SHARED_LIBRARY
|
||||||
# define GTEST_API_ __declspec(dllimport)
|
# define GTEST_API_ __declspec(dllimport)
|
||||||
|
@ -944,9 +978,15 @@ using ::std::tuple_size;
|
||||||
# define GTEST_API_ __attribute__((visibility ("default")))
|
# define GTEST_API_ __attribute__((visibility ("default")))
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
#endif // GTEST_API_
|
||||||
|
|
||||||
#ifndef GTEST_API_
|
#ifndef GTEST_API_
|
||||||
# define GTEST_API_
|
# define GTEST_API_
|
||||||
#endif
|
#endif // GTEST_API_
|
||||||
|
|
||||||
|
#ifndef GTEST_DEFAULT_DEATH_TEST_STYLE
|
||||||
|
# define GTEST_DEFAULT_DEATH_TEST_STYLE "fast"
|
||||||
|
#endif // GTEST_DEFAULT_DEATH_TEST_STYLE
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
// Ask the compiler to never inline a given function.
|
// Ask the compiler to never inline a given function.
|
||||||
|
@ -956,10 +996,12 @@ using ::std::tuple_size;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.
|
// _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.
|
||||||
#if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)
|
#if !defined(GTEST_HAS_CXXABI_H_)
|
||||||
|
# if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER))
|
||||||
# define GTEST_HAS_CXXABI_H_ 1
|
# define GTEST_HAS_CXXABI_H_ 1
|
||||||
#else
|
# else
|
||||||
# define GTEST_HAS_CXXABI_H_ 0
|
# define GTEST_HAS_CXXABI_H_ 0
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// A function level attribute to disable checking for use of uninitialized
|
// A function level attribute to disable checking for use of uninitialized
|
||||||
|
@ -1102,6 +1144,16 @@ struct StaticAssertTypeEqHelper<T, T> {
|
||||||
enum { value = true };
|
enum { value = true };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Same as std::is_same<>.
|
||||||
|
template <typename T, typename U>
|
||||||
|
struct IsSame {
|
||||||
|
enum { value = false };
|
||||||
|
};
|
||||||
|
template <typename T>
|
||||||
|
struct IsSame<T, T> {
|
||||||
|
enum { value = true };
|
||||||
|
};
|
||||||
|
|
||||||
// Evaluates to the number of elements in 'array'.
|
// Evaluates to the number of elements in 'array'.
|
||||||
#define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))
|
#define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))
|
||||||
|
|
||||||
|
@ -1165,6 +1217,10 @@ class scoped_ptr {
|
||||||
|
|
||||||
// Defines RE.
|
// Defines RE.
|
||||||
|
|
||||||
|
#if GTEST_USES_PCRE
|
||||||
|
using ::RE;
|
||||||
|
#elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE
|
||||||
|
|
||||||
// A simple C++ wrapper for <regex.h>. It uses the POSIX Extended
|
// A simple C++ wrapper for <regex.h>. It uses the POSIX Extended
|
||||||
// Regular Expression syntax.
|
// Regular Expression syntax.
|
||||||
class GTEST_API_ RE {
|
class GTEST_API_ RE {
|
||||||
|
@ -1176,11 +1232,11 @@ class GTEST_API_ RE {
|
||||||
// Constructs an RE from a string.
|
// Constructs an RE from a string.
|
||||||
RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT
|
RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT
|
||||||
|
|
||||||
#if GTEST_HAS_GLOBAL_STRING
|
# if GTEST_HAS_GLOBAL_STRING
|
||||||
|
|
||||||
RE(const ::string& regex) { Init(regex.c_str()); } // NOLINT
|
RE(const ::string& regex) { Init(regex.c_str()); } // NOLINT
|
||||||
|
|
||||||
#endif // GTEST_HAS_GLOBAL_STRING
|
# endif // GTEST_HAS_GLOBAL_STRING
|
||||||
|
|
||||||
RE(const char* regex) { Init(regex); } // NOLINT
|
RE(const char* regex) { Init(regex); } // NOLINT
|
||||||
~RE();
|
~RE();
|
||||||
|
@ -1202,7 +1258,7 @@ class GTEST_API_ RE {
|
||||||
return PartialMatch(str.c_str(), re);
|
return PartialMatch(str.c_str(), re);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GTEST_HAS_GLOBAL_STRING
|
# if GTEST_HAS_GLOBAL_STRING
|
||||||
|
|
||||||
static bool FullMatch(const ::string& str, const RE& re) {
|
static bool FullMatch(const ::string& str, const RE& re) {
|
||||||
return FullMatch(str.c_str(), re);
|
return FullMatch(str.c_str(), re);
|
||||||
|
@ -1211,7 +1267,7 @@ class GTEST_API_ RE {
|
||||||
return PartialMatch(str.c_str(), re);
|
return PartialMatch(str.c_str(), re);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // GTEST_HAS_GLOBAL_STRING
|
# endif // GTEST_HAS_GLOBAL_STRING
|
||||||
|
|
||||||
static bool FullMatch(const char* str, const RE& re);
|
static bool FullMatch(const char* str, const RE& re);
|
||||||
static bool PartialMatch(const char* str, const RE& re);
|
static bool PartialMatch(const char* str, const RE& re);
|
||||||
|
@ -1225,20 +1281,22 @@ class GTEST_API_ RE {
|
||||||
const char* pattern_;
|
const char* pattern_;
|
||||||
bool is_valid_;
|
bool is_valid_;
|
||||||
|
|
||||||
#if GTEST_USES_POSIX_RE
|
# if GTEST_USES_POSIX_RE
|
||||||
|
|
||||||
regex_t full_regex_; // For FullMatch().
|
regex_t full_regex_; // For FullMatch().
|
||||||
regex_t partial_regex_; // For PartialMatch().
|
regex_t partial_regex_; // For PartialMatch().
|
||||||
|
|
||||||
#else // GTEST_USES_SIMPLE_RE
|
# else // GTEST_USES_SIMPLE_RE
|
||||||
|
|
||||||
const char* full_pattern_; // For FullMatch();
|
const char* full_pattern_; // For FullMatch();
|
||||||
|
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
GTEST_DISALLOW_ASSIGN_(RE);
|
GTEST_DISALLOW_ASSIGN_(RE);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // GTEST_USES_PCRE
|
||||||
|
|
||||||
// Formats a source file path and a line number as they would appear
|
// Formats a source file path and a line number as they would appear
|
||||||
// in an error message from the compiler used to compile this code.
|
// in an error message from the compiler used to compile this code.
|
||||||
GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
|
GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
|
||||||
|
@ -1324,13 +1382,59 @@ inline void FlushInfoLog() { fflush(NULL); }
|
||||||
GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
|
GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
|
||||||
<< gtest_error
|
<< gtest_error
|
||||||
|
|
||||||
|
// Adds reference to a type if it is not a reference type,
|
||||||
|
// otherwise leaves it unchanged. This is the same as
|
||||||
|
// tr1::add_reference, which is not widely available yet.
|
||||||
|
template <typename T>
|
||||||
|
struct AddReference { typedef T& type; }; // NOLINT
|
||||||
|
template <typename T>
|
||||||
|
struct AddReference<T&> { typedef T& type; }; // NOLINT
|
||||||
|
|
||||||
|
// A handy wrapper around AddReference that works when the argument T
|
||||||
|
// depends on template parameters.
|
||||||
|
#define GTEST_ADD_REFERENCE_(T) \
|
||||||
|
typename ::testing::internal::AddReference<T>::type
|
||||||
|
|
||||||
|
// Transforms "T" into "const T&" according to standard reference collapsing
|
||||||
|
// rules (this is only needed as a backport for C++98 compilers that do not
|
||||||
|
// support reference collapsing). Specifically, it transforms:
|
||||||
|
//
|
||||||
|
// char ==> const char&
|
||||||
|
// const char ==> const char&
|
||||||
|
// char& ==> char&
|
||||||
|
// const char& ==> const char&
|
||||||
|
//
|
||||||
|
// Note that the non-const reference will not have "const" added. This is
|
||||||
|
// standard, and necessary so that "T" can always bind to "const T&".
|
||||||
|
template <typename T>
|
||||||
|
struct ConstRef { typedef const T& type; };
|
||||||
|
template <typename T>
|
||||||
|
struct ConstRef<T&> { typedef T& type; };
|
||||||
|
|
||||||
|
// The argument T must depend on some template parameters.
|
||||||
|
#define GTEST_REFERENCE_TO_CONST_(T) \
|
||||||
|
typename ::testing::internal::ConstRef<T>::type
|
||||||
|
|
||||||
#if GTEST_HAS_STD_MOVE_
|
#if GTEST_HAS_STD_MOVE_
|
||||||
|
using std::forward;
|
||||||
using std::move;
|
using std::move;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct RvalueRef {
|
||||||
|
typedef T&& type;
|
||||||
|
};
|
||||||
#else // GTEST_HAS_STD_MOVE_
|
#else // GTEST_HAS_STD_MOVE_
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T& move(const T& t) {
|
const T& move(const T& t) {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
template <typename T>
|
||||||
|
GTEST_ADD_REFERENCE_(T) forward(GTEST_ADD_REFERENCE_(T) t) { return t; }
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct RvalueRef {
|
||||||
|
typedef const T& type;
|
||||||
|
};
|
||||||
#endif // GTEST_HAS_STD_MOVE_
|
#endif // GTEST_HAS_STD_MOVE_
|
||||||
|
|
||||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
||||||
|
@ -1431,10 +1535,6 @@ GTEST_API_ void CaptureStderr();
|
||||||
GTEST_API_ std::string GetCapturedStderr();
|
GTEST_API_ std::string GetCapturedStderr();
|
||||||
|
|
||||||
#endif // GTEST_HAS_STREAM_REDIRECTION
|
#endif // GTEST_HAS_STREAM_REDIRECTION
|
||||||
|
|
||||||
// Returns a path to temporary directory.
|
|
||||||
GTEST_API_ std::string TempDir();
|
|
||||||
|
|
||||||
// Returns the size (in bytes) of a file.
|
// Returns the size (in bytes) of a file.
|
||||||
GTEST_API_ size_t GetFileSize(FILE* file);
|
GTEST_API_ size_t GetFileSize(FILE* file);
|
||||||
|
|
||||||
|
@ -1442,14 +1542,18 @@ GTEST_API_ size_t GetFileSize(FILE* file);
|
||||||
GTEST_API_ std::string ReadEntireFile(FILE* file);
|
GTEST_API_ std::string ReadEntireFile(FILE* file);
|
||||||
|
|
||||||
// All command line arguments.
|
// All command line arguments.
|
||||||
GTEST_API_ const ::std::vector<testing::internal::string>& GetArgvs();
|
GTEST_API_ std::vector<std::string> GetArgvs();
|
||||||
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
#if GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
const ::std::vector<testing::internal::string>& GetInjectableArgvs();
|
std::vector<std::string> GetInjectableArgvs();
|
||||||
void SetInjectableArgvs(const ::std::vector<testing::internal::string>*
|
// Deprecated: pass the args vector by value instead.
|
||||||
new_argvs);
|
void SetInjectableArgvs(const std::vector<std::string>* new_argvs);
|
||||||
|
void SetInjectableArgvs(const std::vector<std::string>& new_argvs);
|
||||||
|
#if GTEST_HAS_GLOBAL_STRING
|
||||||
|
void SetInjectableArgvs(const std::vector< ::string>& new_argvs);
|
||||||
|
#endif // GTEST_HAS_GLOBAL_STRING
|
||||||
|
void ClearInjectableArgvs();
|
||||||
|
|
||||||
#endif // GTEST_HAS_DEATH_TEST
|
#endif // GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
|
@ -1983,8 +2087,13 @@ class MutexBase {
|
||||||
extern ::testing::internal::MutexBase mutex
|
extern ::testing::internal::MutexBase mutex
|
||||||
|
|
||||||
// Defines and statically (i.e. at link time) initializes a static mutex.
|
// Defines and statically (i.e. at link time) initializes a static mutex.
|
||||||
|
// The initialization list here does not explicitly initialize each field,
|
||||||
|
// instead relying on default initialization for the unspecified fields. In
|
||||||
|
// particular, the owner_ field (a pthread_t) is not explicitly initialized.
|
||||||
|
// This allows initialization to work whether pthread_t is a scalar or struct.
|
||||||
|
// The flag -Wmissing-field-initializers must not be specified for this to work.
|
||||||
# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
|
# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
|
||||||
::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, false, pthread_t() }
|
::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, false }
|
||||||
|
|
||||||
// The Mutex class can only be used for mutexes created at runtime. It
|
// The Mutex class can only be used for mutexes created at runtime. It
|
||||||
// shares its API with MutexBase otherwise.
|
// shares its API with MutexBase otherwise.
|
||||||
|
@ -2041,7 +2150,7 @@ extern "C" inline void DeleteThreadLocalValue(void* value_holder) {
|
||||||
|
|
||||||
// Implements thread-local storage on pthreads-based systems.
|
// Implements thread-local storage on pthreads-based systems.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class ThreadLocal {
|
class GTEST_API_ ThreadLocal {
|
||||||
public:
|
public:
|
||||||
ThreadLocal()
|
ThreadLocal()
|
||||||
: key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}
|
: key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}
|
||||||
|
@ -2173,7 +2282,7 @@ class GTestMutexLock {
|
||||||
typedef GTestMutexLock MutexLock;
|
typedef GTestMutexLock MutexLock;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class ThreadLocal {
|
class GTEST_API_ ThreadLocal {
|
||||||
public:
|
public:
|
||||||
ThreadLocal() : value_() {}
|
ThreadLocal() : value_() {}
|
||||||
explicit ThreadLocal(const T& value) : value_(value) {}
|
explicit ThreadLocal(const T& value) : value_(value) {}
|
||||||
|
@ -2192,12 +2301,13 @@ class ThreadLocal {
|
||||||
GTEST_API_ size_t GetThreadCount();
|
GTEST_API_ size_t GetThreadCount();
|
||||||
|
|
||||||
// Passing non-POD classes through ellipsis (...) crashes the ARM
|
// Passing non-POD classes through ellipsis (...) crashes the ARM
|
||||||
// compiler and generates a warning in Sun Studio. The Nokia Symbian
|
// compiler and generates a warning in Sun Studio before 12u4. The Nokia Symbian
|
||||||
// and the IBM XL C/C++ compiler try to instantiate a copy constructor
|
// and the IBM XL C/C++ compiler try to instantiate a copy constructor
|
||||||
// for objects passed through ellipsis (...), failing for uncopyable
|
// for objects passed through ellipsis (...), failing for uncopyable
|
||||||
// objects. We define this to ensure that only POD is passed through
|
// objects. We define this to ensure that only POD is passed through
|
||||||
// ellipsis on these systems.
|
// ellipsis on these systems.
|
||||||
#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)
|
#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || \
|
||||||
|
(defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5130)
|
||||||
// We lose support for NULL detection where the compiler doesn't like
|
// We lose support for NULL detection where the compiler doesn't like
|
||||||
// passing non-POD classes through ellipsis (...).
|
// passing non-POD classes through ellipsis (...).
|
||||||
# define GTEST_ELLIPSIS_NEEDS_POD_ 1
|
# define GTEST_ELLIPSIS_NEEDS_POD_ 1
|
||||||
|
@ -2223,6 +2333,13 @@ template <bool bool_value> const bool bool_constant<bool_value>::value;
|
||||||
typedef bool_constant<false> false_type;
|
typedef bool_constant<false> false_type;
|
||||||
typedef bool_constant<true> true_type;
|
typedef bool_constant<true> true_type;
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
struct is_same : public false_type {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_same<T, T> : public true_type {};
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_pointer : public false_type {};
|
struct is_pointer : public false_type {};
|
||||||
|
|
||||||
|
@ -2234,6 +2351,7 @@ struct IteratorTraits {
|
||||||
typedef typename Iterator::value_type value_type;
|
typedef typename Iterator::value_type value_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct IteratorTraits<T*> {
|
struct IteratorTraits<T*> {
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
@ -2399,7 +2517,7 @@ inline int Close(int fd) { return close(fd); }
|
||||||
inline const char* StrError(int errnum) { return strerror(errnum); }
|
inline const char* StrError(int errnum) { return strerror(errnum); }
|
||||||
#endif
|
#endif
|
||||||
inline const char* GetEnv(const char* name) {
|
inline const char* GetEnv(const char* name) {
|
||||||
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE | GTEST_OS_WINDOWS_RT
|
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
|
||||||
// We are on Windows CE, which has no environment variables.
|
// We are on Windows CE, which has no environment variables.
|
||||||
static_cast<void>(name); // To prevent 'unused argument' warning.
|
static_cast<void>(name); // To prevent 'unused argument' warning.
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2529,15 +2647,15 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||||
# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
|
# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
|
||||||
# define GTEST_DECLARE_int32_(name) \
|
# define GTEST_DECLARE_int32_(name) \
|
||||||
GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
|
GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
|
||||||
#define GTEST_DECLARE_string_(name) \
|
# define GTEST_DECLARE_string_(name) \
|
||||||
GTEST_API_ extern ::std::string GTEST_FLAG(name)
|
GTEST_API_ extern ::std::string GTEST_FLAG(name)
|
||||||
|
|
||||||
// Macros for defining flags.
|
// Macros for defining flags.
|
||||||
#define GTEST_DEFINE_bool_(name, default_val, doc) \
|
# define GTEST_DEFINE_bool_(name, default_val, doc) \
|
||||||
GTEST_API_ bool GTEST_FLAG(name) = (default_val)
|
GTEST_API_ bool GTEST_FLAG(name) = (default_val)
|
||||||
#define GTEST_DEFINE_int32_(name, default_val, doc) \
|
# define GTEST_DEFINE_int32_(name, default_val, doc) \
|
||||||
GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
|
GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
|
||||||
#define GTEST_DEFINE_string_(name, default_val, doc) \
|
# define GTEST_DEFINE_string_(name, default_val, doc) \
|
||||||
GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
|
GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
|
||||||
|
|
||||||
#endif // !defined(GTEST_DECLARE_bool_)
|
#endif // !defined(GTEST_DECLARE_bool_)
|
||||||
|
@ -2560,7 +2678,8 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value);
|
||||||
// corresponding to the given Google Test flag.
|
// corresponding to the given Google Test flag.
|
||||||
bool BoolFromGTestEnv(const char* flag, bool default_val);
|
bool BoolFromGTestEnv(const char* flag, bool default_val);
|
||||||
GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
|
GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
|
||||||
std::string StringFromGTestEnv(const char* flag, const char* default_val);
|
std::string OutputFlagAlsoCheckEnvVar();
|
||||||
|
const char* StringFromGTestEnv(const char* flag, const char* default_val);
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
|
|
@ -27,15 +27,15 @@
|
||||||
// (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: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
|
|
||||||
//
|
//
|
||||||
// The Google C++ Testing Framework (Google Test)
|
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||||
//
|
//
|
||||||
// This header file declares the String class and functions used internally by
|
// This header file declares the String class and functions used internally by
|
||||||
// Google Test. They are subject to change without notice. They should not used
|
// Google Test. They are subject to change without notice. They should not used
|
||||||
// by code external to Google Test.
|
// by code external to Google Test.
|
||||||
//
|
//
|
||||||
// This header file is #included by <gtest/internal/gtest-internal.h>.
|
// This header file is #included by
|
||||||
|
// gtest/internal/gtest-internal.h.
|
||||||
// It should not be #included by other files.
|
// It should not be #included by other files.
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
|
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
|
||||||
|
|
|
@ -57,6 +57,22 @@
|
||||||
namespace testing {
|
namespace testing {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
// Canonicalizes a given name with respect to the Standard C++ Library.
|
||||||
|
// This handles removing the inline namespace within `std` that is
|
||||||
|
// used by various standard libraries (e.g., `std::__1`). Names outside
|
||||||
|
// of namespace std are returned unmodified.
|
||||||
|
inline std::string CanonicalizeForStdLibVersioning(std::string s) {
|
||||||
|
static const char prefix[] = "std::__";
|
||||||
|
if (s.compare(0, strlen(prefix), prefix) == 0) {
|
||||||
|
std::string::size_type end = s.find("::", strlen(prefix));
|
||||||
|
if (end != s.npos) {
|
||||||
|
// Erase everything between the initial `std` and the second `::`.
|
||||||
|
s.erase(strlen("std"), end - strlen("std"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
// GetTypeName<T>() returns a human-readable name of type T.
|
// GetTypeName<T>() returns a human-readable name of type T.
|
||||||
// NB: This function is also used in Google Mock, so don't move it inside of
|
// NB: This function is also used in Google Mock, so don't move it inside of
|
||||||
// the typed-test-only section below.
|
// the typed-test-only section below.
|
||||||
|
@ -75,7 +91,7 @@ std::string GetTypeName() {
|
||||||
char* const readable_name = __cxa_demangle(name, 0, 0, &status);
|
char* const readable_name = __cxa_demangle(name, 0, 0, &status);
|
||||||
const std::string name_str(status == 0 ? readable_name : name);
|
const std::string name_str(status == 0 ? readable_name : name);
|
||||||
free(readable_name);
|
free(readable_name);
|
||||||
return name_str;
|
return CanonicalizeForStdLibVersioning(name_str);
|
||||||
# else
|
# else
|
||||||
return name;
|
return name;
|
||||||
# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
|
# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
|
||||||
|
|
|
@ -55,6 +55,22 @@ $var n = 50 $$ Maximum length of type lists we want to support.
|
||||||
namespace testing {
|
namespace testing {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
// Canonicalizes a given name with respect to the Standard C++ Library.
|
||||||
|
// This handles removing the inline namespace within `std` that is
|
||||||
|
// used by various standard libraries (e.g., `std::__1`). Names outside
|
||||||
|
// of namespace std are returned unmodified.
|
||||||
|
inline std::string CanonicalizeForStdLibVersioning(std::string s) {
|
||||||
|
static const char prefix[] = "std::__";
|
||||||
|
if (s.compare(0, strlen(prefix), prefix) == 0) {
|
||||||
|
std::string::size_type end = s.find("::", strlen(prefix));
|
||||||
|
if (end != s.npos) {
|
||||||
|
// Erase everything between the initial `std` and the second `::`.
|
||||||
|
s.erase(strlen("std"), end - strlen("std"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
// GetTypeName<T>() returns a human-readable name of type T.
|
// GetTypeName<T>() returns a human-readable name of type T.
|
||||||
// NB: This function is also used in Google Mock, so don't move it inside of
|
// NB: This function is also used in Google Mock, so don't move it inside of
|
||||||
// the typed-test-only section below.
|
// the typed-test-only section below.
|
||||||
|
@ -73,7 +89,7 @@ std::string GetTypeName() {
|
||||||
char* const readable_name = __cxa_demangle(name, 0, 0, &status);
|
char* const readable_name = __cxa_demangle(name, 0, 0, &status);
|
||||||
const std::string name_str(status == 0 ? readable_name : name);
|
const std::string name_str(status == 0 ? readable_name : name);
|
||||||
free(readable_name);
|
free(readable_name);
|
||||||
return name_str;
|
return CanonicalizeForStdLibVersioning(name_str);
|
||||||
# else
|
# else
|
||||||
return name;
|
return name;
|
||||||
# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
|
# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
//
|
//
|
||||||
// Author: mheule@google.com (Markus Heule)
|
// Author: mheule@google.com (Markus Heule)
|
||||||
//
|
//
|
||||||
// Google C++ Testing Framework (Google Test)
|
// Google C++ Testing and Mocking Framework (Google Test)
|
||||||
//
|
//
|
||||||
// Sometimes it's desirable to build Google Test by compiling a single file.
|
// Sometimes it's desirable to build Google Test by compiling a single file.
|
||||||
// This file serves this purpose.
|
// This file serves this purpose.
|
||||||
|
|
|
@ -62,26 +62,29 @@
|
||||||
# include <spawn.h>
|
# include <spawn.h>
|
||||||
# endif // GTEST_OS_QNX
|
# endif // GTEST_OS_QNX
|
||||||
|
|
||||||
|
# if GTEST_OS_FUCHSIA
|
||||||
|
# include <lib/fdio/io.h>
|
||||||
|
# include <lib/fdio/spawn.h>
|
||||||
|
# include <zircon/processargs.h>
|
||||||
|
# include <zircon/syscalls.h>
|
||||||
|
# endif // GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
#endif // GTEST_HAS_DEATH_TEST
|
#endif // GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
#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 {
|
||||||
|
|
||||||
// Constants.
|
// Constants.
|
||||||
|
|
||||||
// The default death test style.
|
// The default death test style.
|
||||||
static const char kDefaultDeathTestStyle[] = "fast";
|
//
|
||||||
|
// This is defined in internal/gtest-port.h as "fast", but can be overridden by
|
||||||
|
// a definition in internal/custom/gtest-port.h. The recommended value, which is
|
||||||
|
// used internally at Google, is "threadsafe".
|
||||||
|
static const char kDefaultDeathTestStyle[] = GTEST_DEFAULT_DEATH_TEST_STYLE;
|
||||||
|
|
||||||
GTEST_DEFINE_string_(
|
GTEST_DEFINE_string_(
|
||||||
death_test_style,
|
death_test_style,
|
||||||
|
@ -121,7 +124,7 @@ namespace internal {
|
||||||
|
|
||||||
// Valid only for fast death tests. Indicates the code is running in the
|
// Valid only for fast death tests. Indicates the code is running in the
|
||||||
// child process of a fast style death test.
|
// child process of a fast style death test.
|
||||||
# if !GTEST_OS_WINDOWS
|
# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
|
||||||
static bool g_in_fast_death_test_child = false;
|
static bool g_in_fast_death_test_child = false;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -131,10 +134,10 @@ static bool g_in_fast_death_test_child = false;
|
||||||
// tests. IMPORTANT: This is an internal utility. Using it may break the
|
// tests. IMPORTANT: This is an internal utility. Using it may break the
|
||||||
// implementation of death tests. User code MUST NOT use it.
|
// implementation of death tests. User code MUST NOT use it.
|
||||||
bool InDeathTestChild() {
|
bool InDeathTestChild() {
|
||||||
# if GTEST_OS_WINDOWS
|
# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
// On Windows, death tests are thread-safe regardless of the value of the
|
// On Windows and Fuchsia, death tests are thread-safe regardless of the value
|
||||||
// death_test_style flag.
|
// of the death_test_style flag.
|
||||||
return !GTEST_FLAG(internal_run_death_test).empty();
|
return !GTEST_FLAG(internal_run_death_test).empty();
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
@ -154,7 +157,7 @@ ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {
|
||||||
|
|
||||||
// ExitedWithCode function-call operator.
|
// ExitedWithCode function-call operator.
|
||||||
bool ExitedWithCode::operator()(int exit_status) const {
|
bool ExitedWithCode::operator()(int exit_status) const {
|
||||||
# if GTEST_OS_WINDOWS
|
# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
return exit_status == exit_code_;
|
return exit_status == exit_code_;
|
||||||
|
|
||||||
|
@ -162,10 +165,10 @@ bool ExitedWithCode::operator()(int exit_status) const {
|
||||||
|
|
||||||
return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;
|
return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;
|
||||||
|
|
||||||
# endif // GTEST_OS_WINDOWS
|
# endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
|
||||||
}
|
}
|
||||||
|
|
||||||
# if !GTEST_OS_WINDOWS
|
# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
|
||||||
// KilledBySignal constructor.
|
// KilledBySignal constructor.
|
||||||
KilledBySignal::KilledBySignal(int signum) : signum_(signum) {
|
KilledBySignal::KilledBySignal(int signum) : signum_(signum) {
|
||||||
}
|
}
|
||||||
|
@ -182,7 +185,7 @@ bool KilledBySignal::operator()(int exit_status) const {
|
||||||
# endif // defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_)
|
# endif // defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_)
|
||||||
return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_;
|
return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_;
|
||||||
}
|
}
|
||||||
# endif // !GTEST_OS_WINDOWS
|
# endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
@ -193,7 +196,7 @@ namespace internal {
|
||||||
static std::string ExitSummary(int exit_code) {
|
static std::string ExitSummary(int exit_code) {
|
||||||
Message m;
|
Message m;
|
||||||
|
|
||||||
# if GTEST_OS_WINDOWS
|
# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
m << "Exited with exit status " << exit_code;
|
m << "Exited with exit status " << exit_code;
|
||||||
|
|
||||||
|
@ -209,7 +212,7 @@ static std::string ExitSummary(int exit_code) {
|
||||||
m << " (core dumped)";
|
m << " (core dumped)";
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# endif // GTEST_OS_WINDOWS
|
# endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
return m.GetString();
|
return m.GetString();
|
||||||
}
|
}
|
||||||
|
@ -220,7 +223,7 @@ bool ExitedUnsuccessfully(int exit_status) {
|
||||||
return !ExitedWithCode(0)(exit_status);
|
return !ExitedWithCode(0)(exit_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
# if !GTEST_OS_WINDOWS
|
# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
|
||||||
// Generates a textual failure message when a death test finds more than
|
// Generates a textual failure message when a death test finds more than
|
||||||
// one thread running, or cannot determine the number of threads, prior
|
// one thread running, or cannot determine the number of threads, prior
|
||||||
// to executing the given statement. It is the responsibility of the
|
// to executing the given statement. It is the responsibility of the
|
||||||
|
@ -235,7 +238,7 @@ static std::string DeathTestThreadWarning(size_t thread_count) {
|
||||||
msg << "detected " << thread_count << " threads.";
|
msg << "detected " << thread_count << " threads.";
|
||||||
return msg.GetString();
|
return msg.GetString();
|
||||||
}
|
}
|
||||||
# endif // !GTEST_OS_WINDOWS
|
# endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
// Flag characters for reporting a death test that did not die.
|
// Flag characters for reporting a death test that did not die.
|
||||||
static const char kDeathTestLived = 'L';
|
static const char kDeathTestLived = 'L';
|
||||||
|
@ -243,6 +246,13 @@ static const char kDeathTestReturned = 'R';
|
||||||
static const char kDeathTestThrew = 'T';
|
static const char kDeathTestThrew = 'T';
|
||||||
static const char kDeathTestInternalError = 'I';
|
static const char kDeathTestInternalError = 'I';
|
||||||
|
|
||||||
|
#if GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
|
// File descriptor used for the pipe in the child process.
|
||||||
|
static const int kFuchsiaReadPipeFd = 3;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// An enumeration describing all of the possible ways that a death test can
|
// An enumeration describing all of the possible ways that a death test can
|
||||||
// conclude. DIED means that the process died while executing the test
|
// conclude. DIED means that the process died while executing the test
|
||||||
// code; LIVED means that process lived beyond the end of the test code;
|
// code; LIVED means that process lived beyond the end of the test code;
|
||||||
|
@ -259,7 +269,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.
|
||||||
|
@ -563,7 +573,13 @@ bool DeathTestImpl::Passed(bool status_ok) {
|
||||||
break;
|
break;
|
||||||
case DIED:
|
case DIED:
|
||||||
if (status_ok) {
|
if (status_ok) {
|
||||||
|
# if GTEST_USES_PCRE
|
||||||
|
// PCRE regexes support embedded NULs.
|
||||||
|
// GTEST_USES_PCRE is defined only in google3 mode
|
||||||
|
const bool matched = RE::PartialMatch(error_message, *regex());
|
||||||
|
# else
|
||||||
const bool matched = RE::PartialMatch(error_message.c_str(), *regex());
|
const bool matched = RE::PartialMatch(error_message.c_str(), *regex());
|
||||||
|
# endif // GTEST_USES_PCRE
|
||||||
if (matched) {
|
if (matched) {
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -779,7 +795,166 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() {
|
||||||
set_spawned(true);
|
set_spawned(true);
|
||||||
return OVERSEE_TEST;
|
return OVERSEE_TEST;
|
||||||
}
|
}
|
||||||
# else // We are not on Windows.
|
|
||||||
|
# elif GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
|
class FuchsiaDeathTest : public DeathTestImpl {
|
||||||
|
public:
|
||||||
|
FuchsiaDeathTest(const char* a_statement,
|
||||||
|
const RE* a_regex,
|
||||||
|
const char* file,
|
||||||
|
int line)
|
||||||
|
: DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {}
|
||||||
|
|
||||||
|
// All of these virtual functions are inherited from DeathTest.
|
||||||
|
virtual int Wait();
|
||||||
|
virtual TestRole AssumeRole();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// The name of the file in which the death test is located.
|
||||||
|
const char* const file_;
|
||||||
|
// The line number on which the death test is located.
|
||||||
|
const int line_;
|
||||||
|
|
||||||
|
zx_handle_t child_process_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Utility class for accumulating command-line arguments.
|
||||||
|
class Arguments {
|
||||||
|
public:
|
||||||
|
Arguments() {
|
||||||
|
args_.push_back(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
~Arguments() {
|
||||||
|
for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();
|
||||||
|
++i) {
|
||||||
|
free(*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void AddArgument(const char* argument) {
|
||||||
|
args_.insert(args_.end() - 1, posix::StrDup(argument));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Str>
|
||||||
|
void AddArguments(const ::std::vector<Str>& arguments) {
|
||||||
|
for (typename ::std::vector<Str>::const_iterator i = arguments.begin();
|
||||||
|
i != arguments.end();
|
||||||
|
++i) {
|
||||||
|
args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
char* const* Argv() {
|
||||||
|
return &args_[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
int size() {
|
||||||
|
return args_.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<char*> args_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Waits for the child in a death test to exit, returning its exit
|
||||||
|
// status, or 0 if no child process exists. As a side effect, sets the
|
||||||
|
// outcome data member.
|
||||||
|
int FuchsiaDeathTest::Wait() {
|
||||||
|
if (!spawned())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Wait for child process to terminate.
|
||||||
|
zx_status_t status_zx;
|
||||||
|
zx_signals_t signals;
|
||||||
|
status_zx = zx_object_wait_one(
|
||||||
|
child_process_,
|
||||||
|
ZX_PROCESS_TERMINATED,
|
||||||
|
ZX_TIME_INFINITE,
|
||||||
|
&signals);
|
||||||
|
GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);
|
||||||
|
|
||||||
|
ReadAndInterpretStatusByte();
|
||||||
|
|
||||||
|
zx_info_process_t buffer;
|
||||||
|
status_zx = zx_object_get_info(
|
||||||
|
child_process_,
|
||||||
|
ZX_INFO_PROCESS,
|
||||||
|
&buffer,
|
||||||
|
sizeof(buffer),
|
||||||
|
nullptr,
|
||||||
|
nullptr);
|
||||||
|
GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);
|
||||||
|
|
||||||
|
GTEST_DEATH_TEST_CHECK_(buffer.exited);
|
||||||
|
set_status(buffer.return_code);
|
||||||
|
return status();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The AssumeRole process for a Fuchsia death test. It creates a child
|
||||||
|
// process with the same executable as the current process to run the
|
||||||
|
// death test. The child process is given the --gtest_filter and
|
||||||
|
// --gtest_internal_run_death_test flags such that it knows to run the
|
||||||
|
// current death test only.
|
||||||
|
DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
|
||||||
|
const UnitTestImpl* const impl = GetUnitTestImpl();
|
||||||
|
const InternalRunDeathTestFlag* const flag =
|
||||||
|
impl->internal_run_death_test_flag();
|
||||||
|
const TestInfo* const info = impl->current_test_info();
|
||||||
|
const int death_test_index = info->result()->death_test_count();
|
||||||
|
|
||||||
|
if (flag != NULL) {
|
||||||
|
// ParseInternalRunDeathTestFlag() has performed all the necessary
|
||||||
|
// processing.
|
||||||
|
set_write_fd(kFuchsiaReadPipeFd);
|
||||||
|
return EXECUTE_TEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
CaptureStderr();
|
||||||
|
// Flush the log buffers since the log streams are shared with the child.
|
||||||
|
FlushInfoLog();
|
||||||
|
|
||||||
|
// Build the child process command line.
|
||||||
|
const std::string filter_flag =
|
||||||
|
std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "="
|
||||||
|
+ info->test_case_name() + "." + info->name();
|
||||||
|
const std::string internal_flag =
|
||||||
|
std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "="
|
||||||
|
+ file_ + "|"
|
||||||
|
+ StreamableToString(line_) + "|"
|
||||||
|
+ StreamableToString(death_test_index);
|
||||||
|
Arguments args;
|
||||||
|
args.AddArguments(GetInjectableArgvs());
|
||||||
|
args.AddArgument(filter_flag.c_str());
|
||||||
|
args.AddArgument(internal_flag.c_str());
|
||||||
|
|
||||||
|
// Build the pipe for communication with the child.
|
||||||
|
zx_status_t status;
|
||||||
|
zx_handle_t child_pipe_handle;
|
||||||
|
uint32_t type;
|
||||||
|
status = fdio_pipe_half(&child_pipe_handle, &type);
|
||||||
|
GTEST_DEATH_TEST_CHECK_(status >= 0);
|
||||||
|
set_read_fd(status);
|
||||||
|
|
||||||
|
// Set the pipe handle for the child.
|
||||||
|
fdio_spawn_action_t add_handle_action = {
|
||||||
|
.action = FDIO_SPAWN_ACTION_ADD_HANDLE,
|
||||||
|
.h = {
|
||||||
|
.id = PA_HND(type, kFuchsiaReadPipeFd),
|
||||||
|
.handle = child_pipe_handle
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Spawn the child process.
|
||||||
|
status = fdio_spawn_etc(ZX_HANDLE_INVALID, FDIO_SPAWN_CLONE_ALL,
|
||||||
|
args.Argv()[0], args.Argv(), nullptr, 1,
|
||||||
|
&add_handle_action, &child_process_, nullptr);
|
||||||
|
GTEST_DEATH_TEST_CHECK_(status == ZX_OK);
|
||||||
|
|
||||||
|
set_spawned(true);
|
||||||
|
return OVERSEE_TEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // We are neither on Windows, nor on Fuchsia.
|
||||||
|
|
||||||
// ForkingDeathTest provides implementations for most of the abstract
|
// ForkingDeathTest provides implementations for most of the abstract
|
||||||
// methods of the DeathTest interface. Only the AssumeRole method is
|
// methods of the DeathTest interface. Only the AssumeRole method is
|
||||||
|
@ -883,11 +1058,10 @@ class ExecDeathTest : public ForkingDeathTest {
|
||||||
ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }
|
ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }
|
||||||
virtual TestRole AssumeRole();
|
virtual TestRole AssumeRole();
|
||||||
private:
|
private:
|
||||||
static ::std::vector<testing::internal::string>
|
static ::std::vector<std::string> GetArgvsForDeathTestChildProcess() {
|
||||||
GetArgvsForDeathTestChildProcess() {
|
::std::vector<std::string> args = GetInjectableArgvs();
|
||||||
::std::vector<testing::internal::string> args = GetInjectableArgvs();
|
|
||||||
# if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)
|
# if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)
|
||||||
::std::vector<testing::internal::string> extra_args =
|
::std::vector<std::string> extra_args =
|
||||||
GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_();
|
GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_();
|
||||||
args.insert(args.end(), extra_args.begin(), extra_args.end());
|
args.insert(args.end(), extra_args.begin(), extra_args.end());
|
||||||
# endif // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)
|
# endif // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)
|
||||||
|
@ -986,6 +1160,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
|
||||||
|
@ -995,20 +1170,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
|
||||||
|
@ -1200,6 +1377,13 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
|
||||||
*test = new WindowsDeathTest(statement, regex, file, line);
|
*test = new WindowsDeathTest(statement, regex, file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# elif GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
|
if (GTEST_FLAG(death_test_style) == "threadsafe" ||
|
||||||
|
GTEST_FLAG(death_test_style) == "fast") {
|
||||||
|
*test = new FuchsiaDeathTest(statement, regex, file, line);
|
||||||
|
}
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
if (GTEST_FLAG(death_test_style) == "threadsafe") {
|
if (GTEST_FLAG(death_test_style) == "threadsafe") {
|
||||||
|
@ -1224,7 +1408,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,
|
||||||
|
@ -1243,7 +1427,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id,
|
||||||
reinterpret_cast<HANDLE>(write_handle_as_size_t);
|
reinterpret_cast<HANDLE>(write_handle_as_size_t);
|
||||||
HANDLE dup_write_handle;
|
HANDLE dup_write_handle;
|
||||||
|
|
||||||
// The newly initialized handle is accessible only in in the parent
|
// The newly initialized handle is accessible only in the parent
|
||||||
// process. To obtain one accessible within the child, we need to use
|
// process. To obtain one accessible within the child, we need to use
|
||||||
// DuplicateHandle.
|
// DuplicateHandle.
|
||||||
if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,
|
if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,
|
||||||
|
@ -1320,6 +1504,16 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
||||||
write_fd = GetStatusFileDescriptor(parent_process_id,
|
write_fd = GetStatusFileDescriptor(parent_process_id,
|
||||||
write_handle_as_size_t,
|
write_handle_as_size_t,
|
||||||
event_handle_as_size_t);
|
event_handle_as_size_t);
|
||||||
|
|
||||||
|
# elif GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
|
if (fields.size() != 3
|
||||||
|
|| !ParseNaturalNumber(fields[1], &line)
|
||||||
|
|| !ParseNaturalNumber(fields[2], &index)) {
|
||||||
|
DeathTestAbort("Bad --gtest_internal_run_death_test flag: "
|
||||||
|
+ GTEST_FLAG(internal_run_death_test));
|
||||||
|
}
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
if (fields.size() != 4
|
if (fields.size() != 4
|
||||||
|
|
|
@ -26,14 +26,12 @@
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (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)
|
|
||||||
|
|
||||||
#include "gtest/gtest-message.h"
|
|
||||||
#include "gtest/internal/gtest-filepath.h"
|
#include "gtest/internal/gtest-filepath.h"
|
||||||
#include "gtest/internal/gtest-port.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "gtest/internal/gtest-port.h"
|
||||||
|
#include "gtest/gtest-message.h"
|
||||||
|
|
||||||
#if GTEST_OS_WINDOWS_MOBILE
|
#if GTEST_OS_WINDOWS_MOBILE
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
@ -48,6 +46,8 @@
|
||||||
# include <climits> // Some Linux distributions define PATH_MAX here.
|
# include <climits> // Some Linux distributions define PATH_MAX here.
|
||||||
#endif // GTEST_OS_WINDOWS_MOBILE
|
#endif // GTEST_OS_WINDOWS_MOBILE
|
||||||
|
|
||||||
|
#include "gtest/internal/gtest-string.h"
|
||||||
|
|
||||||
#if GTEST_OS_WINDOWS
|
#if GTEST_OS_WINDOWS
|
||||||
# define GTEST_PATH_MAX_ _MAX_PATH
|
# define GTEST_PATH_MAX_ _MAX_PATH
|
||||||
#elif defined(PATH_MAX)
|
#elif defined(PATH_MAX)
|
||||||
|
@ -58,8 +58,6 @@
|
||||||
# define GTEST_PATH_MAX_ _POSIX_PATH_MAX
|
# define GTEST_PATH_MAX_ _POSIX_PATH_MAX
|
||||||
#endif // GTEST_OS_WINDOWS
|
#endif // GTEST_OS_WINDOWS
|
||||||
|
|
||||||
#include "gtest/internal/gtest-string.h"
|
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
@ -130,7 +128,7 @@ FilePath FilePath::RemoveExtension(const char* extension) const {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a pointer to the last occurence of a valid path separator in
|
// Returns a pointer to the last occurrence of a valid path separator in
|
||||||
// the FilePath. On Windows, for example, both '/' and '\' are valid path
|
// the FilePath. On Windows, for example, both '/' and '\' are valid path
|
||||||
// separators. Returns NULL if no path separator was found.
|
// separators. Returns NULL if no path separator was found.
|
||||||
const char* FilePath::FindLastPathSeparator() const {
|
const char* FilePath::FindLastPathSeparator() const {
|
||||||
|
|
|
@ -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
|
||||||
|
@ -67,7 +59,7 @@
|
||||||
# include <windows.h> // NOLINT
|
# include <windows.h> // NOLINT
|
||||||
#endif // GTEST_OS_WINDOWS
|
#endif // GTEST_OS_WINDOWS
|
||||||
|
|
||||||
#include "gtest/gtest.h" // NOLINT
|
#include "gtest/gtest.h"
|
||||||
#include "gtest/gtest-spi.h"
|
#include "gtest/gtest-spi.h"
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
@ -94,6 +86,7 @@ const char kFilterFlag[] = "filter";
|
||||||
const char kListTestsFlag[] = "list_tests";
|
const char kListTestsFlag[] = "list_tests";
|
||||||
const char kOutputFlag[] = "output";
|
const char kOutputFlag[] = "output";
|
||||||
const char kPrintTimeFlag[] = "print_time";
|
const char kPrintTimeFlag[] = "print_time";
|
||||||
|
const char kPrintUTF8Flag[] = "print_utf8";
|
||||||
const char kRandomSeedFlag[] = "random_seed";
|
const char kRandomSeedFlag[] = "random_seed";
|
||||||
const char kRepeatFlag[] = "repeat";
|
const char kRepeatFlag[] = "repeat";
|
||||||
const char kShuffleFlag[] = "shuffle";
|
const char kShuffleFlag[] = "shuffle";
|
||||||
|
@ -174,6 +167,7 @@ class GTestFlagSaver {
|
||||||
list_tests_ = GTEST_FLAG(list_tests);
|
list_tests_ = GTEST_FLAG(list_tests);
|
||||||
output_ = GTEST_FLAG(output);
|
output_ = GTEST_FLAG(output);
|
||||||
print_time_ = GTEST_FLAG(print_time);
|
print_time_ = GTEST_FLAG(print_time);
|
||||||
|
print_utf8_ = GTEST_FLAG(print_utf8);
|
||||||
random_seed_ = GTEST_FLAG(random_seed);
|
random_seed_ = GTEST_FLAG(random_seed);
|
||||||
repeat_ = GTEST_FLAG(repeat);
|
repeat_ = GTEST_FLAG(repeat);
|
||||||
shuffle_ = GTEST_FLAG(shuffle);
|
shuffle_ = GTEST_FLAG(shuffle);
|
||||||
|
@ -195,6 +189,7 @@ class GTestFlagSaver {
|
||||||
GTEST_FLAG(list_tests) = list_tests_;
|
GTEST_FLAG(list_tests) = list_tests_;
|
||||||
GTEST_FLAG(output) = output_;
|
GTEST_FLAG(output) = output_;
|
||||||
GTEST_FLAG(print_time) = print_time_;
|
GTEST_FLAG(print_time) = print_time_;
|
||||||
|
GTEST_FLAG(print_utf8) = print_utf8_;
|
||||||
GTEST_FLAG(random_seed) = random_seed_;
|
GTEST_FLAG(random_seed) = random_seed_;
|
||||||
GTEST_FLAG(repeat) = repeat_;
|
GTEST_FLAG(repeat) = repeat_;
|
||||||
GTEST_FLAG(shuffle) = shuffle_;
|
GTEST_FLAG(shuffle) = shuffle_;
|
||||||
|
@ -216,6 +211,7 @@ class GTestFlagSaver {
|
||||||
bool list_tests_;
|
bool list_tests_;
|
||||||
std::string output_;
|
std::string output_;
|
||||||
bool print_time_;
|
bool print_time_;
|
||||||
|
bool print_utf8_;
|
||||||
internal::Int32 random_seed_;
|
internal::Int32 random_seed_;
|
||||||
internal::Int32 repeat_;
|
internal::Int32 repeat_;
|
||||||
bool shuffle_;
|
bool shuffle_;
|
||||||
|
@ -426,7 +422,7 @@ class OsStackTraceGetterInterface {
|
||||||
// in the trace.
|
// in the trace.
|
||||||
// skip_count - the number of top frames to be skipped; doesn't count
|
// skip_count - the number of top frames to be skipped; doesn't count
|
||||||
// against max_depth.
|
// against max_depth.
|
||||||
virtual string CurrentStackTrace(int max_depth, int skip_count) = 0;
|
virtual std::string CurrentStackTrace(int max_depth, int skip_count) = 0;
|
||||||
|
|
||||||
// UponLeavingGTest() should be called immediately before Google Test calls
|
// UponLeavingGTest() should be called immediately before Google Test calls
|
||||||
// user code. It saves some information about the current stack that
|
// user code. It saves some information about the current stack that
|
||||||
|
@ -446,7 +442,7 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface {
|
||||||
public:
|
public:
|
||||||
OsStackTraceGetter() {}
|
OsStackTraceGetter() {}
|
||||||
|
|
||||||
virtual string CurrentStackTrace(int max_depth, int skip_count);
|
virtual std::string CurrentStackTrace(int max_depth, int skip_count);
|
||||||
virtual void UponLeavingGTest();
|
virtual void UponLeavingGTest();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -664,13 +660,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 +839,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_;
|
||||||
|
@ -1032,7 +1024,7 @@ class TestResultAccessor {
|
||||||
#if GTEST_CAN_STREAM_RESULTS_
|
#if GTEST_CAN_STREAM_RESULTS_
|
||||||
|
|
||||||
// Streams test results to the given port on the given host machine.
|
// Streams test results to the given port on the given host machine.
|
||||||
class GTEST_API_ StreamingListener : public EmptyTestEventListener {
|
class StreamingListener : public EmptyTestEventListener {
|
||||||
public:
|
public:
|
||||||
// Abstract base class for writing strings to a socket.
|
// Abstract base class for writing strings to a socket.
|
||||||
class AbstractSocketWriter {
|
class AbstractSocketWriter {
|
||||||
|
@ -1040,21 +1032,19 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener {
|
||||||
virtual ~AbstractSocketWriter() {}
|
virtual ~AbstractSocketWriter() {}
|
||||||
|
|
||||||
// Sends a string to the socket.
|
// Sends a string to the socket.
|
||||||
virtual void Send(const string& message) = 0;
|
virtual void Send(const std::string& message) = 0;
|
||||||
|
|
||||||
// Closes the socket.
|
// Closes the socket.
|
||||||
virtual void CloseConnection() {}
|
virtual void CloseConnection() {}
|
||||||
|
|
||||||
// Sends a string and a newline to the socket.
|
// Sends a string and a newline to the socket.
|
||||||
void SendLn(const string& message) {
|
void SendLn(const std::string& message) { Send(message + "\n"); }
|
||||||
Send(message + "\n");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Concrete class for actually writing strings to a socket.
|
// Concrete class for actually writing strings to a socket.
|
||||||
class SocketWriter : public AbstractSocketWriter {
|
class SocketWriter : public AbstractSocketWriter {
|
||||||
public:
|
public:
|
||||||
SocketWriter(const string& host, const string& port)
|
SocketWriter(const std::string& host, const std::string& port)
|
||||||
: sockfd_(-1), host_name_(host), port_num_(port) {
|
: sockfd_(-1), host_name_(host), port_num_(port) {
|
||||||
MakeConnection();
|
MakeConnection();
|
||||||
}
|
}
|
||||||
|
@ -1065,7 +1055,7 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sends a string to the socket.
|
// Sends a string to the socket.
|
||||||
virtual void Send(const string& message) {
|
virtual void Send(const std::string& message) {
|
||||||
GTEST_CHECK_(sockfd_ != -1)
|
GTEST_CHECK_(sockfd_ != -1)
|
||||||
<< "Send() can be called only when there is a connection.";
|
<< "Send() can be called only when there is a connection.";
|
||||||
|
|
||||||
|
@ -1091,17 +1081,19 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
int sockfd_; // socket file descriptor
|
int sockfd_; // socket file descriptor
|
||||||
const string host_name_;
|
const std::string host_name_;
|
||||||
const string port_num_;
|
const std::string port_num_;
|
||||||
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter);
|
GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter);
|
||||||
}; // class SocketWriter
|
}; // class SocketWriter
|
||||||
|
|
||||||
// Escapes '=', '&', '%', and '\n' characters in str as "%xx".
|
// Escapes '=', '&', '%', and '\n' characters in str as "%xx".
|
||||||
static string UrlEncode(const char* str);
|
static std::string UrlEncode(const char* str);
|
||||||
|
|
||||||
StreamingListener(const string& host, const string& port)
|
StreamingListener(const std::string& host, const std::string& port)
|
||||||
: socket_writer_(new SocketWriter(host, port)) { Start(); }
|
: socket_writer_(new SocketWriter(host, port)) {
|
||||||
|
Start();
|
||||||
|
}
|
||||||
|
|
||||||
explicit StreamingListener(AbstractSocketWriter* socket_writer)
|
explicit StreamingListener(AbstractSocketWriter* socket_writer)
|
||||||
: socket_writer_(socket_writer) { Start(); }
|
: socket_writer_(socket_writer) { Start(); }
|
||||||
|
@ -1162,13 +1154,13 @@ class GTEST_API_ StreamingListener : public EmptyTestEventListener {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Sends the given message and a newline to the socket.
|
// Sends the given message and a newline to the socket.
|
||||||
void SendLn(const string& message) { socket_writer_->SendLn(message); }
|
void SendLn(const std::string& message) { socket_writer_->SendLn(message); }
|
||||||
|
|
||||||
// Called at the start of streaming to notify the receiver what
|
// Called at the start of streaming to notify the receiver what
|
||||||
// protocol we are using.
|
// protocol we are using.
|
||||||
void Start() { SendLn("gtest_streaming_protocol_version=1.0"); }
|
void Start() { SendLn("gtest_streaming_protocol_version=1.0"); }
|
||||||
|
|
||||||
string FormatBool(bool value) { return value ? "1" : "0"; }
|
std::string FormatBool(bool value) { return value ? "1" : "0"; }
|
||||||
|
|
||||||
const scoped_ptr<AbstractSocketWriter> socket_writer_;
|
const scoped_ptr<AbstractSocketWriter> socket_writer_;
|
||||||
|
|
||||||
|
|
|
@ -63,19 +63,16 @@
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
#endif // GTEST_OS_AIX
|
#endif // GTEST_OS_AIX
|
||||||
|
|
||||||
|
#if GTEST_OS_FUCHSIA
|
||||||
|
# include <zircon/process.h>
|
||||||
|
# include <zircon/syscalls.h>
|
||||||
|
#endif // GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
#include "gtest/gtest-spi.h"
|
#include "gtest/gtest-spi.h"
|
||||||
#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 {
|
||||||
|
@ -93,7 +90,7 @@ const int kStdErrFileno = STDERR_FILENO;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T ReadProcFileField(const string& filename, int field) {
|
T ReadProcFileField(const std::string& filename, int field) {
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
std::ifstream file(filename.c_str());
|
std::ifstream file(filename.c_str());
|
||||||
while (field-- > 0) {
|
while (field-- > 0) {
|
||||||
|
@ -107,7 +104,7 @@ T ReadProcFileField(const string& filename, int field) {
|
||||||
|
|
||||||
// Returns the number of active threads, or 0 when there is an error.
|
// Returns the number of active threads, or 0 when there is an error.
|
||||||
size_t GetThreadCount() {
|
size_t GetThreadCount() {
|
||||||
const string filename =
|
const std::string filename =
|
||||||
(Message() << "/proc/" << getpid() << "/stat").GetString();
|
(Message() << "/proc/" << getpid() << "/stat").GetString();
|
||||||
return ReadProcFileField<int>(filename, 19);
|
return ReadProcFileField<int>(filename, 19);
|
||||||
}
|
}
|
||||||
|
@ -164,6 +161,25 @@ size_t GetThreadCount() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif GTEST_OS_FUCHSIA
|
||||||
|
|
||||||
|
size_t GetThreadCount() {
|
||||||
|
int dummy_buffer;
|
||||||
|
size_t avail;
|
||||||
|
zx_status_t status = zx_object_get_info(
|
||||||
|
zx_process_self(),
|
||||||
|
ZX_INFO_PROCESS_THREADS,
|
||||||
|
&dummy_buffer,
|
||||||
|
0,
|
||||||
|
nullptr,
|
||||||
|
&avail);
|
||||||
|
if (status == ZX_OK) {
|
||||||
|
return avail;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
size_t GetThreadCount() {
|
size_t GetThreadCount() {
|
||||||
|
@ -496,7 +512,7 @@ class ThreadLocalRegistryImpl {
|
||||||
FALSE,
|
FALSE,
|
||||||
thread_id);
|
thread_id);
|
||||||
GTEST_CHECK_(thread != NULL);
|
GTEST_CHECK_(thread != NULL);
|
||||||
// We need to to pass a valid thread ID pointer into CreateThread for it
|
// We need to pass a valid thread ID pointer into CreateThread for it
|
||||||
// to work correctly under Win98.
|
// to work correctly under Win98.
|
||||||
DWORD watcher_thread_id;
|
DWORD watcher_thread_id;
|
||||||
HANDLE watcher_thread = ::CreateThread(
|
HANDLE watcher_thread = ::CreateThread(
|
||||||
|
@ -671,7 +687,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();
|
||||||
}
|
}
|
||||||
|
@ -923,6 +939,7 @@ GTestLog::~GTestLog() {
|
||||||
posix::Abort();
|
posix::Abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable Microsoft deprecation warnings for POSIX functions called from
|
// Disable Microsoft deprecation warnings for POSIX functions called from
|
||||||
// this class (creat, dup, dup2, and close)
|
// this class (creat, dup, dup2, and close)
|
||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
|
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
|
||||||
|
@ -1015,7 +1032,8 @@ 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 +1042,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;
|
||||||
|
@ -1055,23 +1073,9 @@ std::string GetCapturedStderr() {
|
||||||
|
|
||||||
#endif // GTEST_HAS_STREAM_REDIRECTION
|
#endif // GTEST_HAS_STREAM_REDIRECTION
|
||||||
|
|
||||||
std::string TempDir() {
|
|
||||||
#if GTEST_OS_WINDOWS_MOBILE
|
|
||||||
return "\\temp\\";
|
|
||||||
#elif GTEST_OS_WINDOWS
|
|
||||||
const char* temp_dir = posix::GetEnv("TEMP");
|
|
||||||
if (temp_dir == NULL || temp_dir[0] == '\0')
|
|
||||||
return "\\temp\\";
|
|
||||||
else if (temp_dir[strlen(temp_dir) - 1] == '\\')
|
|
||||||
return temp_dir;
|
|
||||||
else
|
|
||||||
return std::string(temp_dir) + "\\";
|
|
||||||
#elif GTEST_OS_LINUX_ANDROID
|
|
||||||
return "/sdcard/";
|
|
||||||
#else
|
|
||||||
return "/tmp/";
|
|
||||||
#endif // GTEST_OS_WINDOWS_MOBILE
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t GetFileSize(FILE* file) {
|
size_t GetFileSize(FILE* file) {
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
|
@ -1101,22 +1105,36 @@ std::string ReadEntireFile(FILE* file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
#if GTEST_HAS_DEATH_TEST
|
||||||
|
static const std::vector<std::string>* g_injected_test_argvs = NULL; // Owned.
|
||||||
|
|
||||||
static const ::std::vector<testing::internal::string>* g_injected_test_argvs =
|
std::vector<std::string> GetInjectableArgvs() {
|
||||||
NULL; // Owned.
|
|
||||||
|
|
||||||
void SetInjectableArgvs(const ::std::vector<testing::internal::string>* argvs) {
|
|
||||||
if (g_injected_test_argvs != argvs)
|
|
||||||
delete g_injected_test_argvs;
|
|
||||||
g_injected_test_argvs = argvs;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ::std::vector<testing::internal::string>& GetInjectableArgvs() {
|
|
||||||
if (g_injected_test_argvs != NULL) {
|
if (g_injected_test_argvs != NULL) {
|
||||||
return *g_injected_test_argvs;
|
return *g_injected_test_argvs;
|
||||||
}
|
}
|
||||||
return GetArgvs();
|
return GetArgvs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetInjectableArgvs(const std::vector<std::string>* new_argvs) {
|
||||||
|
if (g_injected_test_argvs != new_argvs) delete g_injected_test_argvs;
|
||||||
|
g_injected_test_argvs = new_argvs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetInjectableArgvs(const std::vector<std::string>& new_argvs) {
|
||||||
|
SetInjectableArgvs(
|
||||||
|
new std::vector<std::string>(new_argvs.begin(), new_argvs.end()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if GTEST_HAS_GLOBAL_STRING
|
||||||
|
void SetInjectableArgvs(const std::vector< ::string>& new_argvs) {
|
||||||
|
SetInjectableArgvs(
|
||||||
|
new std::vector<std::string>(new_argvs.begin(), new_argvs.end()));
|
||||||
|
}
|
||||||
|
#endif // GTEST_HAS_GLOBAL_STRING
|
||||||
|
|
||||||
|
void ClearInjectableArgvs() {
|
||||||
|
delete g_injected_test_argvs;
|
||||||
|
g_injected_test_argvs = NULL;
|
||||||
|
}
|
||||||
#endif // GTEST_HAS_DEATH_TEST
|
#endif // GTEST_HAS_DEATH_TEST
|
||||||
|
|
||||||
#if GTEST_OS_WINDOWS_MOBILE
|
#if GTEST_OS_WINDOWS_MOBILE
|
||||||
|
@ -1191,11 +1209,12 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value) {
|
||||||
bool BoolFromGTestEnv(const char* flag, bool default_value) {
|
bool BoolFromGTestEnv(const char* flag, bool default_value) {
|
||||||
#if defined(GTEST_GET_BOOL_FROM_ENV_)
|
#if defined(GTEST_GET_BOOL_FROM_ENV_)
|
||||||
return GTEST_GET_BOOL_FROM_ENV_(flag, default_value);
|
return GTEST_GET_BOOL_FROM_ENV_(flag, default_value);
|
||||||
#endif // defined(GTEST_GET_BOOL_FROM_ENV_)
|
#else
|
||||||
const std::string env_var = FlagToEnvVar(flag);
|
const std::string env_var = FlagToEnvVar(flag);
|
||||||
const char* const string_value = posix::GetEnv(env_var.c_str());
|
const char* const string_value = posix::GetEnv(env_var.c_str());
|
||||||
return string_value == NULL ?
|
return string_value == NULL ?
|
||||||
default_value : strcmp(string_value, "0") != 0;
|
default_value : strcmp(string_value, "0") != 0;
|
||||||
|
#endif // defined(GTEST_GET_BOOL_FROM_ENV_)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads and returns a 32-bit integer stored in the environment
|
// Reads and returns a 32-bit integer stored in the environment
|
||||||
|
@ -1204,7 +1223,7 @@ bool BoolFromGTestEnv(const char* flag, bool default_value) {
|
||||||
Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
|
Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
|
||||||
#if defined(GTEST_GET_INT32_FROM_ENV_)
|
#if defined(GTEST_GET_INT32_FROM_ENV_)
|
||||||
return GTEST_GET_INT32_FROM_ENV_(flag, default_value);
|
return GTEST_GET_INT32_FROM_ENV_(flag, default_value);
|
||||||
#endif // defined(GTEST_GET_INT32_FROM_ENV_)
|
#else
|
||||||
const std::string env_var = FlagToEnvVar(flag);
|
const std::string env_var = FlagToEnvVar(flag);
|
||||||
const char* const string_value = posix::GetEnv(env_var.c_str());
|
const char* const string_value = posix::GetEnv(env_var.c_str());
|
||||||
if (string_value == NULL) {
|
if (string_value == NULL) {
|
||||||
|
@ -1222,37 +1241,36 @@ Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#endif // defined(GTEST_GET_INT32_FROM_ENV_)
|
||||||
|
}
|
||||||
|
|
||||||
|
// As a special case for the 'output' flag, if GTEST_OUTPUT is not
|
||||||
|
// set, we look for XML_OUTPUT_FILE, which is set by the Bazel build
|
||||||
|
// system. The value of XML_OUTPUT_FILE is a filename without the
|
||||||
|
// "xml:" prefix of GTEST_OUTPUT.
|
||||||
|
// Note that this is meant to be called at the call site so it does
|
||||||
|
// not check that the flag is 'output'
|
||||||
|
// In essence this checks an env variable called XML_OUTPUT_FILE
|
||||||
|
// and if it is set we prepend "xml:" to its value, if it not set we return ""
|
||||||
|
std::string OutputFlagAlsoCheckEnvVar(){
|
||||||
|
std::string default_value_for_output_flag = "";
|
||||||
|
const char* xml_output_file_env = posix::GetEnv("XML_OUTPUT_FILE");
|
||||||
|
if (NULL != xml_output_file_env) {
|
||||||
|
default_value_for_output_flag = std::string("xml:") + xml_output_file_env;
|
||||||
|
}
|
||||||
|
return default_value_for_output_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads and returns the string environment variable corresponding to
|
// Reads and returns the string environment variable corresponding to
|
||||||
// the given flag; if it's not set, returns default_value.
|
// the given flag; if it's not set, returns default_value.
|
||||||
std::string StringFromGTestEnv(const char* flag, const char* default_value) {
|
const char* StringFromGTestEnv(const char* flag, const char* default_value) {
|
||||||
#if defined(GTEST_GET_STRING_FROM_ENV_)
|
#if defined(GTEST_GET_STRING_FROM_ENV_)
|
||||||
return GTEST_GET_STRING_FROM_ENV_(flag, default_value);
|
return GTEST_GET_STRING_FROM_ENV_(flag, default_value);
|
||||||
#endif // defined(GTEST_GET_STRING_FROM_ENV_)
|
#else
|
||||||
const std::string env_var = FlagToEnvVar(flag);
|
const std::string env_var = FlagToEnvVar(flag);
|
||||||
const char* value = posix::GetEnv(env_var.c_str());
|
const char* const value = posix::GetEnv(env_var.c_str());
|
||||||
if (value != NULL) {
|
return value == NULL ? default_value : value;
|
||||||
return value;
|
#endif // defined(GTEST_GET_STRING_FROM_ENV_)
|
||||||
}
|
|
||||||
|
|
||||||
// As a special case for the 'output' flag, if GTEST_OUTPUT is not
|
|
||||||
// set, we look for XML_OUTPUT_FILE, which is set by the Bazel build
|
|
||||||
// system. The value of XML_OUTPUT_FILE is a filename without the
|
|
||||||
// "xml:" prefix of GTEST_OUTPUT.
|
|
||||||
//
|
|
||||||
// The net priority order after flag processing is thus:
|
|
||||||
// --gtest_output command line flag
|
|
||||||
// GTEST_OUTPUT environment variable
|
|
||||||
// XML_OUTPUT_FILE environment variable
|
|
||||||
// 'default_value'
|
|
||||||
if (strcmp(flag, "output") == 0) {
|
|
||||||
value = posix::GetEnv("XML_OUTPUT_FILE");
|
|
||||||
if (value != NULL) {
|
|
||||||
return std::string("xml:") + value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return default_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
//
|
//
|
||||||
// Author: wan@google.com (Zhanyong Wan)
|
// Author: wan@google.com (Zhanyong Wan)
|
||||||
|
|
||||||
// Google Test - The Google C++ Testing Framework
|
// Google Test - The Google C++ Testing and Mocking Framework
|
||||||
//
|
//
|
||||||
// This file implements a universal value printer that can print a
|
// This file implements a universal value printer that can print a
|
||||||
// value of any type T:
|
// value of any type T:
|
||||||
|
@ -43,12 +43,13 @@
|
||||||
// defines Foo.
|
// defines Foo.
|
||||||
|
|
||||||
#include "gtest/gtest-printers.h"
|
#include "gtest/gtest-printers.h"
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <cctype>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <ostream> // NOLINT
|
#include <ostream> // NOLINT
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "gtest/internal/gtest-port.h"
|
#include "gtest/internal/gtest-port.h"
|
||||||
|
#include "src/gtest-internal-inl.h"
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ namespace internal {
|
||||||
// Depending on the value of a char (or wchar_t), we print it in one
|
// Depending on the value of a char (or wchar_t), we print it in one
|
||||||
// of three formats:
|
// of three formats:
|
||||||
// - as is if it's a printable ASCII (e.g. 'a', '2', ' '),
|
// - as is if it's a printable ASCII (e.g. 'a', '2', ' '),
|
||||||
// - as a hexidecimal escape sequence (e.g. '\x7F'), or
|
// - as a hexadecimal escape sequence (e.g. '\x7F'), or
|
||||||
// - as a special escape sequence (e.g. '\r', '\n').
|
// - as a special escape sequence (e.g. '\r', '\n').
|
||||||
enum CharFormat {
|
enum CharFormat {
|
||||||
kAsIs,
|
kAsIs,
|
||||||
|
@ -180,7 +181,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +231,7 @@ void PrintCharAndCodeTo(Char c, ostream* os) {
|
||||||
return;
|
return;
|
||||||
*os << " (" << static_cast<int>(c);
|
*os << " (" << static_cast<int>(c);
|
||||||
|
|
||||||
// For more convenience, we print c's code again in hexidecimal,
|
// For more convenience, we print c's code again in hexadecimal,
|
||||||
// unless c was already printed in the form '\x##' or the code is in
|
// unless c was already printed in the form '\x##' or the code is in
|
||||||
// [1, 9].
|
// [1, 9].
|
||||||
if (format == kHexEscape || (1 <= c && c <= 9)) {
|
if (format == kHexEscape || (1 <= c && c <= 9)) {
|
||||||
|
@ -259,11 +263,12 @@ template <typename CharType>
|
||||||
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
|
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
|
||||||
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
|
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
|
||||||
GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
|
GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
|
||||||
static void PrintCharsAsStringTo(
|
static CharFormat PrintCharsAsStringTo(
|
||||||
const CharType* begin, size_t len, ostream* os) {
|
const CharType* begin, size_t len, ostream* os) {
|
||||||
const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\"";
|
const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\"";
|
||||||
*os << kQuoteBegin;
|
*os << kQuoteBegin;
|
||||||
bool is_previous_hex = false;
|
bool is_previous_hex = false;
|
||||||
|
CharFormat print_format = kAsIs;
|
||||||
for (size_t index = 0; index < len; ++index) {
|
for (size_t index = 0; index < len; ++index) {
|
||||||
const CharType cur = begin[index];
|
const CharType cur = begin[index];
|
||||||
if (is_previous_hex && IsXDigit(cur)) {
|
if (is_previous_hex && IsXDigit(cur)) {
|
||||||
|
@ -273,8 +278,13 @@ static void PrintCharsAsStringTo(
|
||||||
*os << "\" " << kQuoteBegin;
|
*os << "\" " << kQuoteBegin;
|
||||||
}
|
}
|
||||||
is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape;
|
is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape;
|
||||||
|
// Remember if any characters required hex escaping.
|
||||||
|
if (is_previous_hex) {
|
||||||
|
print_format = kHexEscape;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*os << "\"";
|
*os << "\"";
|
||||||
|
return print_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints a (const) char/wchar_t array of 'len' elements, starting at address
|
// Prints a (const) char/wchar_t array of 'len' elements, starting at address
|
||||||
|
@ -344,15 +354,90 @@ void PrintTo(const wchar_t* s, ostream* os) {
|
||||||
}
|
}
|
||||||
#endif // wchar_t is native
|
#endif // wchar_t is native
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
bool ContainsUnprintableControlCodes(const char* str, size_t length) {
|
||||||
|
const unsigned char *s = reinterpret_cast<const unsigned char *>(str);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < length; i++) {
|
||||||
|
unsigned char ch = *s++;
|
||||||
|
if (std::iscntrl(ch)) {
|
||||||
|
switch (ch) {
|
||||||
|
case '\t':
|
||||||
|
case '\n':
|
||||||
|
case '\r':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsUTF8TrailByte(unsigned char t) { return 0x80 <= t && t<= 0xbf; }
|
||||||
|
|
||||||
|
bool IsValidUTF8(const char* str, size_t length) {
|
||||||
|
const unsigned char *s = reinterpret_cast<const unsigned char *>(str);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < length;) {
|
||||||
|
unsigned char lead = s[i++];
|
||||||
|
|
||||||
|
if (lead <= 0x7f) {
|
||||||
|
continue; // single-byte character (ASCII) 0..7F
|
||||||
|
}
|
||||||
|
if (lead < 0xc2) {
|
||||||
|
return false; // trail byte or non-shortest form
|
||||||
|
} else if (lead <= 0xdf && (i + 1) <= length && IsUTF8TrailByte(s[i])) {
|
||||||
|
++i; // 2-byte character
|
||||||
|
} else if (0xe0 <= lead && lead <= 0xef && (i + 2) <= length &&
|
||||||
|
IsUTF8TrailByte(s[i]) &&
|
||||||
|
IsUTF8TrailByte(s[i + 1]) &&
|
||||||
|
// check for non-shortest form and surrogate
|
||||||
|
(lead != 0xe0 || s[i] >= 0xa0) &&
|
||||||
|
(lead != 0xed || s[i] < 0xa0)) {
|
||||||
|
i += 2; // 3-byte character
|
||||||
|
} else if (0xf0 <= lead && lead <= 0xf4 && (i + 3) <= length &&
|
||||||
|
IsUTF8TrailByte(s[i]) &&
|
||||||
|
IsUTF8TrailByte(s[i + 1]) &&
|
||||||
|
IsUTF8TrailByte(s[i + 2]) &&
|
||||||
|
// check for non-shortest form
|
||||||
|
(lead != 0xf0 || s[i] >= 0x90) &&
|
||||||
|
(lead != 0xf4 || s[i] < 0x90)) {
|
||||||
|
i += 3; // 4-byte character
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConditionalPrintAsText(const char* str, size_t length, ostream* os) {
|
||||||
|
if (!ContainsUnprintableControlCodes(str, length) &&
|
||||||
|
IsValidUTF8(str, length)) {
|
||||||
|
*os << "\n As Text: \"" << str << "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
// Prints a ::string object.
|
// Prints a ::string object.
|
||||||
#if GTEST_HAS_GLOBAL_STRING
|
#if GTEST_HAS_GLOBAL_STRING
|
||||||
void PrintStringTo(const ::string& s, ostream* os) {
|
void PrintStringTo(const ::string& s, ostream* os) {
|
||||||
PrintCharsAsStringTo(s.data(), s.size(), os);
|
if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) {
|
||||||
|
if (GTEST_FLAG(print_utf8)) {
|
||||||
|
ConditionalPrintAsText(s.data(), s.size(), os);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // GTEST_HAS_GLOBAL_STRING
|
#endif // GTEST_HAS_GLOBAL_STRING
|
||||||
|
|
||||||
void PrintStringTo(const ::std::string& s, ostream* os) {
|
void PrintStringTo(const ::std::string& s, ostream* os) {
|
||||||
PrintCharsAsStringTo(s.data(), s.size(), os);
|
if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) {
|
||||||
|
if (GTEST_FLAG(print_utf8)) {
|
||||||
|
ConditionalPrintAsText(s.data(), s.size(), os);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints a ::wstring object.
|
// Prints a ::wstring object.
|
||||||
|
|
|
@ -29,18 +29,10 @@
|
||||||
//
|
//
|
||||||
// Author: mheule@google.com (Markus Heule)
|
// Author: mheule@google.com (Markus Heule)
|
||||||
//
|
//
|
||||||
// The Google C++ Testing Framework (Google Test)
|
// The Google C++ Testing and Mocking 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 {
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
// Author: wan@google.com (Zhanyong Wan)
|
// Author: wan@google.com (Zhanyong Wan)
|
||||||
|
|
||||||
#include "gtest/gtest-typed-test.h"
|
#include "gtest/gtest-typed-test.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,9 +26,9 @@
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (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.
|
||||||
|
//
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
GTEST_API_ int main(int argc, char **argv) {
|
GTEST_API_ int main(int argc, char **argv) {
|
||||||
|
|
Loading…
Reference in New Issue