Update to googletest 1.8.1
This commit is contained in:
parent
811584d800
commit
a2442bbbe9
3
vendor/README
vendored
3
vendor/README
vendored
@ -1,6 +1,5 @@
|
||||
This directory contains external projects, taken from the following locations:
|
||||
googletest: https://github.com/google/googletest/tree/4e4df226fc197c0dda6e37f5c8c3845ca1e73a49
|
||||
- changed: added NOLINT comment as workaround for clang-tidy warning https://github.com/google/googletest/issues/853
|
||||
googletest: https://github.com/google/googletest/tree/release-1.8.1
|
||||
spdlog: https://github.com/gabime/spdlog/tree/v0.16.3/include/spdlog
|
||||
cryptopp: https://github.com/weidai11/cryptopp/tree/CRYPTOPP_8_0_0
|
||||
- changed: added CMakeLists.txt and cryptopp-config.cmake from https://github.com/noloader/cryptopp-cmake/tree/CRYPTOPP_8_0_0
|
||||
|
40
vendor/googletest/gtest/.gitignore
vendored
40
vendor/googletest/gtest/.gitignore
vendored
@ -1,40 +0,0 @@
|
||||
# Ignore CI build directory
|
||||
build/
|
||||
xcuserdata
|
||||
cmake-build-debug/
|
||||
.idea/
|
||||
bazel-bin
|
||||
bazel-genfiles
|
||||
bazel-googletest
|
||||
bazel-out
|
||||
bazel-testlogs
|
||||
# python
|
||||
*.pyc
|
||||
|
||||
# Visual Studio files
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.VC.opendb
|
||||
*.suo
|
||||
*.user
|
||||
_ReSharper.Caches/
|
||||
Win32-Debug/
|
||||
Win32-Release/
|
||||
x64-Debug/
|
||||
x64-Release/
|
||||
|
||||
# Ignore autoconf / automake files
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
configure
|
||||
build-aux/
|
||||
autom4te.cache/
|
||||
googletest/m4/libtool.m4
|
||||
googletest/m4/ltoptions.m4
|
||||
googletest/m4/ltsugar.m4
|
||||
googletest/m4/ltversion.m4
|
||||
googletest/m4/lt~obsolete.m4
|
||||
|
||||
# Ignore generated directories.
|
||||
googlemock/fused-src/
|
||||
googletest/fused-src/
|
81
vendor/googletest/gtest/.travis.yml
vendored
81
vendor/googletest/gtest/.travis.yml
vendored
@ -1,81 +0,0 @@
|
||||
# Build matrix / environment variable are explained on:
|
||||
# http://about.travis-ci.org/docs/user/build-configuration/
|
||||
# This file can be validated on:
|
||||
# http://lint.travis-ci.org/
|
||||
|
||||
sudo: false
|
||||
language: cpp
|
||||
|
||||
# Define the matrix explicitly, manually expanding the combinations of (os, compiler, env).
|
||||
# It is more tedious, but grants us far more flexibility.
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
sudo : true
|
||||
install: ./ci/install-linux.sh && ./ci/log-config.sh
|
||||
script: ./ci/build-linux-bazel.sh
|
||||
- os: linux
|
||||
compiler: clang
|
||||
sudo : true
|
||||
install: ./ci/install-linux.sh && ./ci/log-config.sh
|
||||
script: ./ci/build-linux-bazel.sh
|
||||
- os: linux
|
||||
group: deprecated-2017Q4
|
||||
compiler: gcc
|
||||
install: ./ci/install-linux.sh && ./ci/log-config.sh
|
||||
script: ./ci/build-linux-autotools.sh
|
||||
- os: linux
|
||||
group: deprecated-2017Q4
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS=-std=c++11
|
||||
- os: linux
|
||||
group: deprecated-2017Q4
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=Debug VERBOSE=1
|
||||
- os: linux
|
||||
group: deprecated-2017Q4
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=Debug VERBOSE=1
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=Debug VERBOSE=1
|
||||
if: type != pull_request
|
||||
- os: osx
|
||||
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
|
||||
if: type != pull_request
|
||||
|
||||
# These are the install and build (script) phases for the most common entries in the matrix. They could be included
|
||||
# in each entry in the matrix, but that is just repetitive.
|
||||
install:
|
||||
- ./ci/install-${TRAVIS_OS_NAME}.sh
|
||||
- . ./ci/env-${TRAVIS_OS_NAME}.sh
|
||||
- ./ci/log-config.sh
|
||||
|
||||
script: ./ci/travis.sh
|
||||
|
||||
# For sudo=false builds this section installs the necessary dependencies.
|
||||
addons:
|
||||
apt:
|
||||
# List of whitelisted in travis packages for ubuntu-precise can be found here:
|
||||
# https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise
|
||||
# List of whitelisted in travis apt-sources:
|
||||
# https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
packages:
|
||||
- g++-4.9
|
||||
- clang-3.7
|
||||
|
||||
notifications:
|
||||
email: false
|
39
vendor/googletest/gtest/BUILD.bazel
vendored
39
vendor/googletest/gtest/BUILD.bazel
vendored
@ -38,7 +38,7 @@ licenses(["notice"])
|
||||
|
||||
config_setting(
|
||||
name = "windows",
|
||||
values = { "cpu": "x64_windows" },
|
||||
values = {"cpu": "x64_windows"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
@ -51,7 +51,6 @@ config_setting(
|
||||
values = {"define": "absl=1"},
|
||||
)
|
||||
|
||||
|
||||
# Google Test including Google Mock
|
||||
cc_library(
|
||||
name = "gtest",
|
||||
@ -70,7 +69,7 @@ cc_library(
|
||||
"googlemock/src/gmock_main.cc",
|
||||
],
|
||||
),
|
||||
hdrs =glob([
|
||||
hdrs = glob([
|
||||
"googletest/include/gtest/*.h",
|
||||
"googlemock/include/gmock/*.h",
|
||||
]),
|
||||
@ -81,6 +80,14 @@ cc_library(
|
||||
"//conditions:default": ["-pthread"],
|
||||
},
|
||||
),
|
||||
defines = select(
|
||||
{
|
||||
":has_absl": [
|
||||
"GTEST_HAS_ABSL=1",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
},
|
||||
),
|
||||
includes = [
|
||||
"googlemock",
|
||||
"googlemock/include",
|
||||
@ -94,21 +101,19 @@ cc_library(
|
||||
"-pthread",
|
||||
],
|
||||
}),
|
||||
defines = select ({
|
||||
":has_absl": [
|
||||
"GTEST_HAS_ABSL=1",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}
|
||||
deps = select(
|
||||
{
|
||||
":has_absl": [
|
||||
"@com_google_absl//absl/debugging:failure_signal_handler",
|
||||
"@com_google_absl//absl/debugging:stacktrace",
|
||||
"@com_google_absl//absl/debugging:symbolize",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/types:optional",
|
||||
"@com_google_absl//absl/types:variant",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
},
|
||||
),
|
||||
deps = select ({
|
||||
":has_absl": [
|
||||
"@com_google_absl//absl/types:optional",
|
||||
"@com_google_absl//absl/strings"
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
cc_library(
|
||||
|
22
vendor/googletest/gtest/CMakeLists.txt
vendored
22
vendor/googletest/gtest/CMakeLists.txt
vendored
@ -1,33 +1,23 @@
|
||||
cmake_minimum_required(VERSION 2.6.4)
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
|
||||
if (POLICY CMP0048)
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
endif (POLICY CMP0048)
|
||||
|
||||
project( googletest-distribution )
|
||||
project(googletest-distribution)
|
||||
set(GOOGLETEST_VERSION 1.9.0)
|
||||
|
||||
enable_testing()
|
||||
|
||||
include(CMakeDependentOption)
|
||||
if (CMAKE_VERSION VERSION_LESS 2.8.5)
|
||||
set(CMAKE_INSTALL_BINDIR "bin" CACHE STRING "User executables (bin)")
|
||||
set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}" CACHE STRING "Object code libraries (lib)")
|
||||
set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE STRING "C header files (include)")
|
||||
mark_as_advanced(CMAKE_INSTALL_BINDIR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR)
|
||||
else()
|
||||
include(GNUInstallDirs)
|
||||
endif()
|
||||
|
||||
option(BUILD_GTEST "Builds the googletest subproject" OFF)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
#Note that googlemock target already builds googletest
|
||||
option(BUILD_GMOCK "Builds the googlemock subproject" ON)
|
||||
|
||||
cmake_dependent_option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON "BUILD_GTEST OR BUILD_GMOCK" OFF)
|
||||
cmake_dependent_option(INSTALL_GMOCK "Enable installation of googlemock. (Projects embedding googlemock may want to turn this OFF.)" ON "BUILD_GMOCK" OFF)
|
||||
option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON)
|
||||
|
||||
if(BUILD_GMOCK)
|
||||
add_subdirectory( googlemock )
|
||||
elseif(BUILD_GTEST)
|
||||
else()
|
||||
add_subdirectory( googletest )
|
||||
endif()
|
||||
|
8
vendor/googletest/gtest/CONTRIBUTING.md
vendored
8
vendor/googletest/gtest/CONTRIBUTING.md
vendored
@ -19,6 +19,10 @@ Follow either of the two links above to access the appropriate CLA and
|
||||
instructions for how to sign and return it. Once we receive it, we'll be able to
|
||||
accept your pull requests.
|
||||
|
||||
## Are you a Googler?
|
||||
If you are a Googler, you can either create an internal change or work on GitHub directly.
|
||||
|
||||
|
||||
## Contributing A Patch
|
||||
|
||||
1. Submit an issue describing your proposed change to the
|
||||
@ -39,10 +43,6 @@ accept your pull requests.
|
||||
1. Ensure that your code has an appropriate set of unit tests which all pass.
|
||||
1. Submit a pull request.
|
||||
|
||||
If you are a Googler, it is preferable to first create an internal change and
|
||||
have it reviewed and submitted, and then create an upstreaming pull
|
||||
request here.
|
||||
|
||||
## The Google Test and Google Mock Communities ##
|
||||
|
||||
The Google Test community exists primarily through the
|
||||
|
12
vendor/googletest/gtest/README.md
vendored
12
vendor/googletest/gtest/README.md
vendored
@ -4,6 +4,12 @@
|
||||
[![Build Status](https://travis-ci.org/google/googletest.svg?branch=master)](https://travis-ci.org/google/googletest)
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/4o38plt0xbo1ubc8/branch/master?svg=true)](https://ci.appveyor.com/project/GoogleTestAppVeyor/googletest/branch/master)
|
||||
|
||||
**Future Plans**:
|
||||
* 1.8.x Release - the 1.8.x will be the last release that works with pre-C++11 compilers. The 1.8.x will not accept any requests for any new features and any bugfix requests will only be accepted if proven "critical"
|
||||
* Post 1.8.x - work to improve/cleanup/pay technical debt. When this work is completed there will be a 1.9.x tagged release
|
||||
* Post 1.9.x googletest will follow [Abseil Live at Head philosophy](https://abseil.io/about/philosophy)
|
||||
|
||||
|
||||
Welcome to **Google Test**, Google's C++ test framework!
|
||||
|
||||
This repository is a merger of the formerly separate GoogleTest and
|
||||
@ -15,8 +21,8 @@ mailing list for questions, discussions, and development. There is
|
||||
also an IRC channel on [OFTC](https://webchat.oftc.net/) (irc.oftc.net) #gtest available. Please
|
||||
join us!
|
||||
|
||||
Getting started information for **Google Test** is available in the
|
||||
[Google Test Primer](googletest/docs/Primer.md) documentation.
|
||||
Getting started information for **Google Test** is available in the
|
||||
[Google Test Primer](googletest/docs/primer.md) documentation.
|
||||
|
||||
**Google Mock** is an extension to Google Test for writing and using C++ mock
|
||||
classes. See the separate [Google Mock documentation](googlemock/README.md).
|
||||
@ -79,6 +85,8 @@ result output. If your test runner understands TAP, you may find it useful.
|
||||
[gtest-parallel](https://github.com/google/gtest-parallel) is a test runner that
|
||||
runs tests from your binary in parallel to provide significant speed-up.
|
||||
|
||||
[GoogleTest Adapter](https://marketplace.visualstudio.com/items?itemName=DavidSchuldenfrei.gtest-adapter) is a VS Code extension allowing to view Google Tests in a tree view, and run/debug your tests.
|
||||
|
||||
## Requirements ##
|
||||
|
||||
Google Test is designed to have fairly minimal requirements to build
|
||||
|
5
vendor/googletest/gtest/appveyor.yml
vendored
5
vendor/googletest/gtest/appveyor.yml
vendored
@ -78,6 +78,11 @@ build_script:
|
||||
throw "Exec: $ErrorMessage"
|
||||
}
|
||||
|
||||
|
||||
skip_commits:
|
||||
files:
|
||||
- '**/*.md'
|
||||
|
||||
test_script:
|
||||
- ps: |
|
||||
# Only enable some builds for pull requests, the AppVeyor queue is too long.
|
||||
|
2
vendor/googletest/gtest/ci/env-linux.sh
vendored
2
vendor/googletest/gtest/ci/env-linux.sh
vendored
@ -37,5 +37,5 @@
|
||||
|
||||
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
|
||||
if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
|
||||
if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
|
||||
if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.9" CC="clang-3.9"; fi
|
||||
fi
|
||||
|
2
vendor/googletest/gtest/ci/env-osx.sh
vendored
2
vendor/googletest/gtest/ci/env-osx.sh
vendored
@ -36,5 +36,5 @@
|
||||
# TODO() - we can check if this is being sourced using $BASH_VERSION and $BASH_SOURCE[0] != ${0}.
|
||||
|
||||
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
|
||||
if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
|
||||
if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.9" CC="clang-3.9"; fi
|
||||
fi
|
||||
|
2
vendor/googletest/gtest/ci/install-linux.sh
vendored
2
vendor/googletest/gtest/ci/install-linux.sh
vendored
@ -41,7 +41,7 @@ if [ "${TRAVIS_SUDO}" = "true" ]; then
|
||||
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | \
|
||||
sudo tee /etc/apt/sources.list.d/bazel.list
|
||||
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
|
||||
sudo apt-get update && sudo apt-get install -y bazel gcc-4.9 g++-4.9 clang-3.7
|
||||
sudo apt-get update && sudo apt-get install -y bazel gcc-4.9 g++-4.9 clang-3.9
|
||||
elif [ "${CXX}" = "clang++" ]; then
|
||||
# Use ccache, assuming $HOME/bin is in the path, which is true in the Travis build environment.
|
||||
ln -sf /usr/bin/ccache $HOME/bin/${CXX};
|
||||
|
@ -5,10 +5,6 @@
|
||||
# ctest. You can select which tests to run using 'ctest -R regex'.
|
||||
# For more options, run 'ctest --help'.
|
||||
|
||||
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
|
||||
# make it prominent in the GUI.
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
|
||||
|
||||
option(gmock_build_tests "Build all of Google Mock's own tests." OFF)
|
||||
|
||||
# A directory to find Google Test sources.
|
||||
@ -41,7 +37,7 @@ if (CMAKE_VERSION VERSION_LESS 3.0)
|
||||
project(gmock CXX C)
|
||||
else()
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
project(gmock VERSION 1.9.0 LANGUAGES CXX C)
|
||||
project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
|
||||
endif()
|
||||
cmake_minimum_required(VERSION 2.6.4)
|
||||
|
||||
@ -55,18 +51,29 @@ endif()
|
||||
# if they are the same (the default).
|
||||
add_subdirectory("${gtest_dir}" "${gmock_BINARY_DIR}/gtest")
|
||||
|
||||
|
||||
# These commands only run if this is the main project
|
||||
if(CMAKE_PROJECT_NAME STREQUAL "gmock" OR CMAKE_PROJECT_NAME STREQUAL "googletest-distribution")
|
||||
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
|
||||
# make it prominent in the GUI.
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
|
||||
else()
|
||||
mark_as_advanced(gmock_build_tests)
|
||||
endif()
|
||||
|
||||
# Although Google Test's CMakeLists.txt calls this function, the
|
||||
# changes there don't affect the current scope. Therefore we have to
|
||||
# call it again here.
|
||||
config_compiler_and_linker() # from ${gtest_dir}/cmake/internal_utils.cmake
|
||||
|
||||
# Adds Google Mock's and Google Test's header directories to the search path.
|
||||
include_directories("${gmock_SOURCE_DIR}/include"
|
||||
"${gmock_SOURCE_DIR}"
|
||||
"${gtest_SOURCE_DIR}/include"
|
||||
# This directory is needed to build directly from Google
|
||||
# Test sources.
|
||||
"${gtest_SOURCE_DIR}")
|
||||
set(gmock_build_include_dirs
|
||||
"${gmock_SOURCE_DIR}/include"
|
||||
"${gmock_SOURCE_DIR}"
|
||||
"${gtest_SOURCE_DIR}/include"
|
||||
# This directory is needed to build directly from Google Test sources.
|
||||
"${gtest_SOURCE_DIR}")
|
||||
include_directories(${gmock_build_include_dirs})
|
||||
|
||||
# Summary of tuple support for Microsoft Visual Studio:
|
||||
# Compiler version(MS) version(cmake) Support
|
||||
@ -101,42 +108,26 @@ if (MSVC)
|
||||
src/gmock_main.cc)
|
||||
else()
|
||||
cxx_library(gmock "${cxx_strict}" src/gmock-all.cc)
|
||||
target_link_libraries(gmock gtest)
|
||||
target_link_libraries(gmock PUBLIC gtest)
|
||||
cxx_library(gmock_main "${cxx_strict}" src/gmock_main.cc)
|
||||
target_link_libraries(gmock_main gmock)
|
||||
target_link_libraries(gmock_main PUBLIC gmock)
|
||||
endif()
|
||||
|
||||
# If the CMake version supports it, attach header directory information
|
||||
# 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).
|
||||
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
||||
target_include_directories(gmock SYSTEM INTERFACE "${gmock_SOURCE_DIR}/include")
|
||||
target_include_directories(gmock_main SYSTEM INTERFACE "${gmock_SOURCE_DIR}/include")
|
||||
target_include_directories(gmock SYSTEM INTERFACE
|
||||
"$<BUILD_INTERFACE:${gmock_build_include_dirs}>"
|
||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||
target_include_directories(gmock_main SYSTEM INTERFACE
|
||||
"$<BUILD_INTERFACE:${gmock_build_include_dirs}>"
|
||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||
endif()
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# Install rules
|
||||
if(INSTALL_GMOCK)
|
||||
install(TARGETS gmock gmock_main
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
install(DIRECTORY "${gmock_SOURCE_DIR}/include/gmock"
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
||||
# configure and install pkgconfig files
|
||||
configure_file(
|
||||
cmake/gmock.pc.in
|
||||
"${CMAKE_BINARY_DIR}/gmock.pc"
|
||||
@ONLY)
|
||||
configure_file(
|
||||
cmake/gmock_main.pc.in
|
||||
"${CMAKE_BINARY_DIR}/gmock_main.pc"
|
||||
@ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/gmock.pc" "${CMAKE_BINARY_DIR}/gmock_main.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
endif()
|
||||
install_project(gmock gmock_main)
|
||||
|
||||
########################################################################
|
||||
#
|
||||
@ -203,13 +194,13 @@ if (gmock_build_tests)
|
||||
endif()
|
||||
else()
|
||||
cxx_library(gmock_main_no_exception "${cxx_no_exception}" src/gmock_main.cc)
|
||||
target_link_libraries(gmock_main_no_exception gmock)
|
||||
target_link_libraries(gmock_main_no_exception PUBLIC gmock)
|
||||
|
||||
cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" src/gmock_main.cc)
|
||||
target_link_libraries(gmock_main_no_rtti gmock)
|
||||
target_link_libraries(gmock_main_no_rtti PUBLIC gmock)
|
||||
|
||||
cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}" src/gmock_main.cc)
|
||||
target_link_libraries(gmock_main_use_own_tuple gmock)
|
||||
target_link_libraries(gmock_main_use_own_tuple PUBLIC gmock)
|
||||
endif()
|
||||
cxx_test_with_flags(gmock-more-actions_no_exception_test "${cxx_no_exception}"
|
||||
gmock_main_no_exception test/gmock-more-actions_test.cc)
|
||||
|
33
vendor/googletest/gtest/googlemock/README.md
vendored
33
vendor/googletest/gtest/googlemock/README.md
vendored
@ -53,7 +53,7 @@ the Apache License, which is different from Google Mock's license.
|
||||
If you are new to the project, we suggest that you read the user
|
||||
documentation in the following order:
|
||||
|
||||
* Learn the [basics](../../master/googletest/docs/Primer.md) of
|
||||
* Learn the [basics](../../master/googletest/docs/primer.md) of
|
||||
Google Test, if you choose to use Google Mock with it (recommended).
|
||||
* Read [Google Mock for Dummies](../../master/googlemock/docs/ForDummies.md).
|
||||
* Read the instructions below on how to build Google Mock.
|
||||
@ -129,42 +129,21 @@ build Google Mock and its tests, which has further requirements:
|
||||
|
||||
If you have CMake available, it is recommended that you follow the
|
||||
[build instructions][gtest_cmakebuild]
|
||||
as described for Google Test.
|
||||
as described for Google Test.
|
||||
|
||||
If are using Google Mock with an
|
||||
existing CMake project, the section
|
||||
[Incorporating Into An Existing CMake Project][gtest_incorpcmake]
|
||||
may be of particular interest.
|
||||
To make it work for Google Mock you will need to change
|
||||
may be of particular interest.
|
||||
To make it work for Google Mock you will need to change
|
||||
|
||||
target_link_libraries(example gtest_main)
|
||||
|
||||
to
|
||||
|
||||
target_link_libraries(example gmock_main)
|
||||
|
||||
This works because `gmock_main` library is compiled with Google Test.
|
||||
However, it does not automatically add Google Test includes.
|
||||
Therefore you will also have to change
|
||||
|
||||
if (CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
include_directories("${gtest_SOURCE_DIR}/include")
|
||||
endif()
|
||||
|
||||
to
|
||||
|
||||
if (CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
include_directories(BEFORE SYSTEM
|
||||
"${gtest_SOURCE_DIR}/include" "${gmock_SOURCE_DIR}/include")
|
||||
else()
|
||||
target_include_directories(gmock_main SYSTEM BEFORE INTERFACE
|
||||
"${gtest_SOURCE_DIR}/include" "${gmock_SOURCE_DIR}/include")
|
||||
endif()
|
||||
|
||||
This will addtionally mark Google Mock includes as system, which will
|
||||
silence compiler warnings when compiling your tests using clang with
|
||||
`-Wpedantic -Wall -Wextra -Wconversion`.
|
||||
target_link_libraries(example gmock_main)
|
||||
|
||||
This works because `gmock_main` library is compiled with Google Test.
|
||||
|
||||
#### Preparing to Build (Unix only) ####
|
||||
|
||||
|
0
vendor/googletest/gtest/googlemock/build-aux/.keep
vendored
Normal file
0
vendor/googletest/gtest/googlemock/build-aux/.keep
vendored
Normal file
@ -229,7 +229,7 @@ The `argument` can be either a C string or a C++ string object:
|
||||
|
||||
`ContainsRegex()` and `MatchesRegex()` use the regular expression
|
||||
syntax defined
|
||||
[here](../../googletest/docs/AdvancedGuide.md#regular-expression-syntax).
|
||||
[here](../../googletest/docs/advanced.md#regular-expression-syntax).
|
||||
`StrCaseEq()`, `StrCaseNe()`, `StrEq()`, and `StrNe()` work for wide
|
||||
strings as well.
|
||||
|
||||
@ -349,7 +349,7 @@ You can make a matcher from one or more other matchers:
|
||||
|
||||
## Matchers as Test Assertions ##
|
||||
|
||||
|`ASSERT_THAT(expression, m)`|Generates a [fatal failure](../../googletest/docs/Primer.md#assertions) if the value of `expression` doesn't match matcher `m`.|
|
||||
|`ASSERT_THAT(expression, m)`|Generates a [fatal failure](../../googletest/docs/primer.md#assertions) if the value of `expression` doesn't match matcher `m`.|
|
||||
|:---------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|`EXPECT_THAT(expression, m)`|Generates a non-fatal failure if the value of `expression` doesn't match matcher `m`. |
|
||||
|
||||
|
@ -2247,7 +2247,7 @@ enum class AccessLevel { kInternal, kPublic };
|
||||
|
||||
class Buzz {
|
||||
public:
|
||||
explicit Buzz(AccessLevel access) { … }
|
||||
explicit Buzz(AccessLevel access) { ... }
|
||||
...
|
||||
};
|
||||
|
||||
@ -2320,7 +2320,7 @@ Note that `ByMove()` is essential here - if you drop it, the code won’t compil
|
||||
|
||||
Quiz time! What do you think will happen if a `Return(ByMove(...))` action is
|
||||
performed more than once (e.g. you write
|
||||
`….WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first
|
||||
`.WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first
|
||||
time the action runs, the source value will be consumed (since it’s a move-only
|
||||
value), so the next time around, there’s no value to move from -- you’ll get a
|
||||
run-time error that `Return(ByMove(...))` can only be run once.
|
||||
@ -3655,6 +3655,6 @@ This printer knows how to print built-in C++ types, native arrays, STL
|
||||
containers, and any type that supports the `<<` operator. For other
|
||||
types, it prints the raw bytes in the value and hopes that you the
|
||||
user can figure it out.
|
||||
[Google Test's advanced guide](../../googletest/docs/AdvancedGuide.md#teaching-google-test-how-to-print-your-values)
|
||||
[Google Test's advanced guide](../../googletest/docs/advanced.md#teaching-google-test-how-to-print-your-values)
|
||||
explains how to extend the printer to do a better job at
|
||||
printing your particular type than to dump the bytes.
|
||||
|
@ -170,7 +170,7 @@ Admittedly, this test is contrived and doesn't do much. You can easily achieve t
|
||||
|
||||
## Using Google Mock with Any Testing Framework ##
|
||||
If you want to use something other than Google Test (e.g. [CppUnit](http://sourceforge.net/projects/cppunit/) or
|
||||
[CxxTest](http://cxxtest.tigris.org/)) as your testing framework, just change the `main()` function in the previous section to:
|
||||
[CxxTest](https://cxxtest.com/)) as your testing framework, just change the `main()` function in the previous section to:
|
||||
```
|
||||
int main(int argc, char** argv) {
|
||||
// The following line causes Google Mock to throw an exception on failure,
|
||||
@ -187,7 +187,7 @@ sometimes causes the test program to crash. You'll still be able to
|
||||
notice that the test has failed, but it's not a graceful failure.
|
||||
|
||||
A better solution is to use Google Test's
|
||||
[event listener API](../../googletest/docs/AdvancedGuide.md#extending-google-test-by-handling-test-events)
|
||||
[event listener API](../../googletest/docs/advanced.md#extending-google-test-by-handling-test-events)
|
||||
to report a test failure to your testing framework properly. You'll need to
|
||||
implement the `OnTestPartResult()` method of the event listener interface, but it
|
||||
should be straightforward.
|
||||
|
@ -528,7 +528,7 @@ interface, which then can be easily mocked. It's a bit of work
|
||||
initially, but usually pays for itself quickly.
|
||||
|
||||
This Google Testing Blog
|
||||
[post](http://googletesting.blogspot.com/2008/06/defeat-static-cling.html)
|
||||
[post](https://testing.googleblog.com/2008/06/defeat-static-cling.html)
|
||||
says it excellently. Check it out.
|
||||
|
||||
## My mock object needs to do complex stuff. It's a lot of pain to specify the actions. Google Mock sucks! ##
|
||||
@ -607,7 +607,6 @@ See this [recipe](CookBook.md#mocking_side_effects) for more details and an exam
|
||||
If you cannot find the answer to your question in this FAQ, there are
|
||||
some other resources you can use:
|
||||
|
||||
1. read other [documentation](Documentation.md),
|
||||
1. search the mailing list [archive](http://groups.google.com/group/googlemock/topics),
|
||||
1. ask it on [googlemock@googlegroups.com](mailto:googlemock@googlegroups.com) and someone will answer it (to prevent spam, we require you to join the [discussion group](http://groups.google.com/group/googlemock) before you can post.).
|
||||
|
||||
|
@ -26,13 +26,14 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements some commonly used actions.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -35,6 +34,8 @@
|
||||
// cardinalities can be defined by the user implementing the
|
||||
// CardinalityInterface interface if necessary.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
|
||||
|
||||
@ -43,6 +44,9 @@
|
||||
#include "gmock/internal/gmock-port.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
||||
/* class A needs to have dll-interface to be used by clients of class B */)
|
||||
|
||||
namespace testing {
|
||||
|
||||
// To implement a cardinality Foo, define:
|
||||
@ -144,4 +148,6 @@ inline Cardinality MakeCardinality(const CardinalityInterface* c) {
|
||||
|
||||
} // namespace testing
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
|
||||
|
@ -30,13 +30,14 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements some commonly used variadic actions.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
||||
@ -213,8 +214,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
|
||||
get<2>(args), get<3>(args), get<4>(args), get<5>(args));
|
||||
}
|
||||
|
||||
// There is no InvokeCallback() for 6-tuples, as google3 callbacks
|
||||
// support 5 arguments at most.
|
||||
// There is no InvokeCallback() for 6-tuples
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
@ -238,8 +238,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
|
||||
get<6>(args));
|
||||
}
|
||||
|
||||
// There is no InvokeCallback() for 7-tuples, as google3 callbacks
|
||||
// support 5 arguments at most.
|
||||
// There is no InvokeCallback() for 7-tuples
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
@ -264,8 +263,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
|
||||
get<6>(args), get<7>(args));
|
||||
}
|
||||
|
||||
// There is no InvokeCallback() for 8-tuples, as google3 callbacks
|
||||
// support 5 arguments at most.
|
||||
// There is no InvokeCallback() for 8-tuples
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
@ -290,8 +288,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
|
||||
get<6>(args), get<7>(args), get<8>(args));
|
||||
}
|
||||
|
||||
// There is no InvokeCallback() for 9-tuples, as google3 callbacks
|
||||
// support 5 arguments at most.
|
||||
// There is no InvokeCallback() for 9-tuples
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
@ -318,8 +315,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
||||
get<6>(args), get<7>(args), get<8>(args), get<9>(args));
|
||||
}
|
||||
|
||||
// There is no InvokeCallback() for 10-tuples, as google3 callbacks
|
||||
// support 5 arguments at most.
|
||||
// There is no InvokeCallback() for 10-tuples
|
||||
};
|
||||
|
||||
// Implements the Invoke(callback) action.
|
||||
|
@ -32,13 +32,14 @@ $$}} This meta comment fixes auto-indentation in editors.
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements some commonly used variadic actions.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
||||
@ -86,8 +87,7 @@ $if i <= max_callback_arity [[
|
||||
return callback->Run($gets);
|
||||
}
|
||||
]] $else [[
|
||||
// There is no InvokeCallback() for $i-tuples, as google3 callbacks
|
||||
// support $max_callback_arity arguments at most.
|
||||
// There is no InvokeCallback() for $i-tuples
|
||||
]]
|
||||
|
||||
};
|
||||
|
@ -30,13 +30,14 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements function mockers of various arities.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
||||
|
||||
@ -352,21 +353,21 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
|
||||
//
|
||||
// class MockClass {
|
||||
// // Overload 1
|
||||
// MockSpec<string&()> gmock_GetName() { … }
|
||||
// MockSpec<string&()> gmock_GetName() { ... }
|
||||
// // Overload 2. Declared const so that the compiler will generate an
|
||||
// // error when trying to resolve between this and overload 4 in
|
||||
// // 'gmock_GetName(WithoutMatchers(), nullptr)'.
|
||||
// MockSpec<string&()> gmock_GetName(
|
||||
// const WithoutMatchers&, const Function<string&()>*) const {
|
||||
// const WithoutMatchers&, const Function<string&()>*) const {
|
||||
// // Removes const from this, calls overload 1
|
||||
// return AdjustConstness_(this)->gmock_GetName();
|
||||
// }
|
||||
//
|
||||
// // Overload 3
|
||||
// const string& gmock_GetName() const { … }
|
||||
// const string& gmock_GetName() const { ... }
|
||||
// // Overload 4
|
||||
// MockSpec<const string&()> gmock_GetName(
|
||||
// const WithoutMatchers&, const Function<const string&()>*) const {
|
||||
// const WithoutMatchers&, const Function<const string&()>*) const {
|
||||
// // Does not remove const, calls overload 3
|
||||
// return AdjustConstness_const(this)->gmock_GetName();
|
||||
// }
|
||||
|
@ -31,13 +31,14 @@ $var n = 10 $$ The maximum arity we support.
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements function mockers of various arities.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
||||
|
||||
@ -114,21 +115,21 @@ class FunctionMocker<R($As)> : public
|
||||
//
|
||||
// class MockClass {
|
||||
// // Overload 1
|
||||
// MockSpec<string&()> gmock_GetName() { … }
|
||||
// MockSpec<string&()> gmock_GetName() { ... }
|
||||
// // Overload 2. Declared const so that the compiler will generate an
|
||||
// // error when trying to resolve between this and overload 4 in
|
||||
// // 'gmock_GetName(WithoutMatchers(), nullptr)'.
|
||||
// MockSpec<string&()> gmock_GetName(
|
||||
// const WithoutMatchers&, const Function<string&()>*) const {
|
||||
// const WithoutMatchers&, const Function<string&()>*) const {
|
||||
// // Removes const from this, calls overload 1
|
||||
// return AdjustConstness_(this)->gmock_GetName();
|
||||
// }
|
||||
//
|
||||
// // Overload 3
|
||||
// const string& gmock_GetName() const { … }
|
||||
// const string& gmock_GetName() const { ... }
|
||||
// // Overload 4
|
||||
// MockSpec<const string&()> gmock_GetName(
|
||||
// const WithoutMatchers&, const Function<const string&()>*) const {
|
||||
// const WithoutMatchers&, const Function<const string&()>*) const {
|
||||
// // Does not remove const, calls overload 3
|
||||
// return AdjustConstness_const(this)->gmock_GetName();
|
||||
// }
|
||||
@ -139,7 +140,7 @@ const MockType* AdjustConstness_const(const MockType* mock) {
|
||||
return mock;
|
||||
}
|
||||
|
||||
// Removes const from and returns the given pointer; this is a helper for the
|
||||
// Removes const from and returns the given pointer; this is a helper for the
|
||||
// expectation setter method for parameterless matchers.
|
||||
template <typename MockType>
|
||||
MockType* AdjustConstness_(const MockType* mock) {
|
||||
|
@ -35,6 +35,8 @@
|
||||
//
|
||||
// This file implements some commonly used variadic matchers.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
||||
|
||||
@ -1379,8 +1381,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
// ================
|
||||
//
|
||||
// To learn more about using these macros, please search for 'MATCHER'
|
||||
// on https://github.com/google/googletest/blob/master/googlemock/docs/
|
||||
// CookBook.md
|
||||
// on
|
||||
// https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
|
||||
|
||||
#define MATCHER(name, description)\
|
||||
class name##Matcher {\
|
||||
|
@ -37,6 +37,8 @@ $$ }} This line fixes auto-indentation of the following code in Emacs.
|
||||
//
|
||||
// This file implements some commonly used variadic matchers.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
||||
|
||||
@ -590,7 +592,8 @@ $$ // show up in the generated code.
|
||||
// ================
|
||||
//
|
||||
// To learn more about using these macros, please search for 'MATCHER'
|
||||
// on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
|
||||
// on
|
||||
// https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
|
||||
|
||||
$range i 0..n
|
||||
$for i
|
||||
|
@ -30,8 +30,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Implements class templates NiceMock, NaggyMock, and StrictMock.
|
||||
//
|
||||
@ -63,6 +62,8 @@
|
||||
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
|
||||
// supported.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
||||
|
||||
|
@ -31,8 +31,7 @@ $var n = 10 $$ The maximum arity we support.
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Implements class templates NiceMock, NaggyMock, and StrictMock.
|
||||
//
|
||||
@ -64,6 +63,8 @@ $var n = 10 $$ The maximum arity we support.
|
||||
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
|
||||
// supported.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -35,6 +34,8 @@
|
||||
// matchers can be defined by the user implementing the
|
||||
// MatcherInterface<T> interface if necessary.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
|
||||
|
||||
@ -55,6 +56,11 @@
|
||||
# include <initializer_list> // NOLINT -- must be after gtest.h
|
||||
#endif
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(
|
||||
4251 5046 /* class A needs to have dll-interface to be used by clients of
|
||||
class B */
|
||||
/* Symbol involving type with internal linkage not defined */)
|
||||
|
||||
namespace testing {
|
||||
|
||||
// To implement a matcher Foo for type T, define:
|
||||
@ -72,7 +78,7 @@ namespace testing {
|
||||
// MatchResultListener is an abstract class. Its << operator can be
|
||||
// used by a matcher to explain why a value matches or doesn't match.
|
||||
//
|
||||
// TODO(wan@google.com): add method
|
||||
// FIXME: add method
|
||||
// bool InterestedInWhy(bool result) const;
|
||||
// to indicate whether the listener is interested in why the match
|
||||
// result is 'result'.
|
||||
@ -921,7 +927,7 @@ class TuplePrefix {
|
||||
GTEST_REFERENCE_TO_CONST_(Value) value = get<N - 1>(values);
|
||||
StringMatchResultListener listener;
|
||||
if (!matcher.MatchAndExplain(value, &listener)) {
|
||||
// TODO(wan): include in the message the name of the parameter
|
||||
// FIXME: include in the message the name of the parameter
|
||||
// as used in MOCK_METHOD*() when possible.
|
||||
*os << " Expected arg #" << N - 1 << ": ";
|
||||
get<N - 1>(matchers).DescribeTo(os);
|
||||
@ -2419,7 +2425,7 @@ class WhenDynamicCastToMatcher : public WhenDynamicCastToMatcherBase<To> {
|
||||
|
||||
template <typename From>
|
||||
bool MatchAndExplain(From from, MatchResultListener* listener) const {
|
||||
// TODO(sbenza): Add more detail on failures. ie did the dyn_cast fail?
|
||||
// FIXME: Add more detail on failures. ie did the dyn_cast fail?
|
||||
To to = dynamic_cast<To>(from);
|
||||
return MatchPrintAndExplain(to, this->matcher_, listener);
|
||||
}
|
||||
@ -2598,16 +2604,20 @@ class PropertyMatcher {
|
||||
|
||||
// Type traits specifying various features of different functors for ResultOf.
|
||||
// The default template specifies features for functor objects.
|
||||
// Functor classes have to typedef argument_type and result_type
|
||||
// to be compatible with ResultOf.
|
||||
template <typename Functor>
|
||||
struct CallableTraits {
|
||||
typedef typename Functor::result_type ResultType;
|
||||
typedef Functor StorageType;
|
||||
|
||||
static void CheckIsValid(Functor /* functor */) {}
|
||||
|
||||
#if GTEST_LANG_CXX11
|
||||
template <typename T>
|
||||
static auto Invoke(Functor f, T arg) -> decltype(f(arg)) { return f(arg); }
|
||||
#else
|
||||
typedef typename Functor::result_type ResultType;
|
||||
template <typename T>
|
||||
static ResultType Invoke(Functor f, T arg) { return f(arg); }
|
||||
#endif
|
||||
};
|
||||
|
||||
// Specialization for function pointers.
|
||||
@ -2628,13 +2638,11 @@ struct CallableTraits<ResType(*)(ArgType)> {
|
||||
|
||||
// Implements the ResultOf() matcher for matching a return value of a
|
||||
// unary function of an object.
|
||||
template <typename Callable>
|
||||
template <typename Callable, typename InnerMatcher>
|
||||
class ResultOfMatcher {
|
||||
public:
|
||||
typedef typename CallableTraits<Callable>::ResultType ResultType;
|
||||
|
||||
ResultOfMatcher(Callable callable, const Matcher<ResultType>& matcher)
|
||||
: callable_(callable), matcher_(matcher) {
|
||||
ResultOfMatcher(Callable callable, InnerMatcher matcher)
|
||||
: callable_(internal::move(callable)), matcher_(internal::move(matcher)) {
|
||||
CallableTraits<Callable>::CheckIsValid(callable_);
|
||||
}
|
||||
|
||||
@ -2648,9 +2656,17 @@ class ResultOfMatcher {
|
||||
|
||||
template <typename T>
|
||||
class Impl : public MatcherInterface<T> {
|
||||
#if GTEST_LANG_CXX11
|
||||
using ResultType = decltype(CallableTraits<Callable>::template Invoke<T>(
|
||||
std::declval<CallableStorageType>(), std::declval<T>()));
|
||||
#else
|
||||
typedef typename CallableTraits<Callable>::ResultType ResultType;
|
||||
#endif
|
||||
|
||||
public:
|
||||
Impl(CallableStorageType callable, const Matcher<ResultType>& matcher)
|
||||
: callable_(callable), matcher_(matcher) {}
|
||||
template <typename M>
|
||||
Impl(const CallableStorageType& callable, const M& matcher)
|
||||
: callable_(callable), matcher_(MatcherCast<ResultType>(matcher)) {}
|
||||
|
||||
virtual void DescribeTo(::std::ostream* os) const {
|
||||
*os << "is mapped by the given callable to a value that ";
|
||||
@ -2664,8 +2680,10 @@ class ResultOfMatcher {
|
||||
|
||||
virtual bool MatchAndExplain(T obj, MatchResultListener* listener) const {
|
||||
*listener << "which is mapped by the given callable to ";
|
||||
// Cannot pass the return value (for example, int) to
|
||||
// MatchPrintAndExplain, which takes a non-const reference as argument.
|
||||
// Cannot pass the return value directly to MatchPrintAndExplain, which
|
||||
// takes a non-const reference as argument.
|
||||
// Also, specifying template argument explicitly is needed because T could
|
||||
// be a non-const reference (e.g. Matcher<Uncopyable&>).
|
||||
ResultType result =
|
||||
CallableTraits<Callable>::template Invoke<T>(callable_, obj);
|
||||
return MatchPrintAndExplain(result, matcher_, listener);
|
||||
@ -2675,7 +2693,7 @@ class ResultOfMatcher {
|
||||
// Functors often define operator() as non-const method even though
|
||||
// they are actually stateless. But we need to use them even when
|
||||
// 'this' is a const pointer. It's the user's responsibility not to
|
||||
// use stateful callables with ResultOf(), which does't guarantee
|
||||
// use stateful callables with ResultOf(), which doesn't guarantee
|
||||
// how many times the callable will be invoked.
|
||||
mutable CallableStorageType callable_;
|
||||
const Matcher<ResultType> matcher_;
|
||||
@ -2684,7 +2702,7 @@ class ResultOfMatcher {
|
||||
}; // class Impl
|
||||
|
||||
const CallableStorageType callable_;
|
||||
const Matcher<ResultType> matcher_;
|
||||
const InnerMatcher matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ResultOfMatcher);
|
||||
};
|
||||
@ -4529,6 +4547,20 @@ Property(PropertyType (Class::*property)() const &,
|
||||
property,
|
||||
MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
|
||||
}
|
||||
|
||||
// Three-argument form for reference-qualified member functions.
|
||||
template <typename Class, typename PropertyType, typename PropertyMatcher>
|
||||
inline PolymorphicMatcher<internal::PropertyMatcher<
|
||||
Class, PropertyType, PropertyType (Class::*)() const &> >
|
||||
Property(const std::string& property_name,
|
||||
PropertyType (Class::*property)() const &,
|
||||
const PropertyMatcher& matcher) {
|
||||
return MakePolymorphicMatcher(
|
||||
internal::PropertyMatcher<Class, PropertyType,
|
||||
PropertyType (Class::*)() const &>(
|
||||
property_name, property,
|
||||
MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Creates a matcher that matches an object iff the result of applying
|
||||
@ -4536,26 +4568,15 @@ Property(PropertyType (Class::*property)() const &,
|
||||
// For example,
|
||||
// ResultOf(f, StartsWith("hi"))
|
||||
// matches a Foo object x iff f(x) starts with "hi".
|
||||
// callable parameter can be a function, function pointer, or a functor.
|
||||
// Callable has to satisfy the following conditions:
|
||||
// * It is required to keep no state affecting the results of
|
||||
// the calls on it and make no assumptions about how many calls
|
||||
// will be made. Any state it keeps must be protected from the
|
||||
// concurrent access.
|
||||
// * If it is a function object, it has to define type result_type.
|
||||
// We recommend deriving your functor classes from std::unary_function.
|
||||
//
|
||||
template <typename Callable, typename ResultOfMatcher>
|
||||
internal::ResultOfMatcher<Callable> ResultOf(
|
||||
Callable callable, const ResultOfMatcher& matcher) {
|
||||
return internal::ResultOfMatcher<Callable>(
|
||||
callable,
|
||||
MatcherCast<typename internal::CallableTraits<Callable>::ResultType>(
|
||||
matcher));
|
||||
// The call to MatcherCast() is required for supporting inner
|
||||
// matchers of compatible types. For example, it allows
|
||||
// ResultOf(Function, m)
|
||||
// to compile where Function() returns an int32 and m is a matcher for int64.
|
||||
// `callable` parameter can be a function, function pointer, or a functor. It is
|
||||
// required to keep no state affecting the results of the calls on it and make
|
||||
// no assumptions about how many calls will be made. Any state it keeps must be
|
||||
// protected from the concurrent access.
|
||||
template <typename Callable, typename InnerMatcher>
|
||||
internal::ResultOfMatcher<Callable, InnerMatcher> ResultOf(
|
||||
Callable callable, InnerMatcher matcher) {
|
||||
return internal::ResultOfMatcher<Callable, InnerMatcher>(
|
||||
internal::move(callable), internal::move(matcher));
|
||||
}
|
||||
|
||||
// String matchers.
|
||||
@ -5165,13 +5186,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
|
||||
// Define variadic matcher versions. They are overloaded in
|
||||
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
|
||||
template <typename... Args>
|
||||
internal::AllOfMatcher<Args...> AllOf(const Args&... matchers) {
|
||||
return internal::AllOfMatcher<Args...>(matchers...);
|
||||
internal::AllOfMatcher<typename std::decay<const Args&>::type...> AllOf(
|
||||