Unverified Commit 9e236748 authored by Gennadiy Civil's avatar Gennadiy Civil Committed by GitHub
Browse files

Merge branch 'master' into master

parents 4d26df72 247a3d8e
...@@ -8,3 +8,17 @@ bazel-genfiles ...@@ -8,3 +8,17 @@ bazel-genfiles
bazel-googletest bazel-googletest
bazel-out bazel-out
bazel-testlogs bazel-testlogs
# python
*.pyc
# Visual Studio files
*.sdf
*.opensdf
*.VC.opendb
*.suo
*.user
_ReSharper.Caches/
Win32-Debug/
Win32-Release/
x64-Debug/
x64-Release/
...@@ -7,7 +7,11 @@ install: ...@@ -7,7 +7,11 @@ install:
# /usr/bin/gcc is 4.6 always, but gcc-X.Y is available. # /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
# /usr/bin/clang is 3.4, lets override with modern one. # /usr/bin/clang is 3.4, lets override with modern one.
- if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi - if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; ln -sf /usr/bin/ccache /$HOME/bin/$CXX; ln -sf /usr/bin/ccache /$HOME/bin/$CC; fi
# ccache on OS X needs installation first
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew install ccache; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
# reset ccache statistics
- ccache --zero-stats
- echo ${PATH} - echo ${PATH}
- echo ${CXX} - echo ${CXX}
- ${CXX} --version - ${CXX} --version
...@@ -22,25 +26,24 @@ addons: ...@@ -22,25 +26,24 @@ addons:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7 - llvm-toolchain-precise-3.7
packages: packages:
- gcc-4.9
- g++-4.9 - g++-4.9
- clang-3.7 - clang-3.7
- valgrind
os: os:
- linux - linux
- osx - osx
language: cpp language: cpp
cache: ccache
before_cache:
# print statistics before uploading new cache
- ccache --show-stats
compiler: compiler:
- gcc - gcc
- clang - clang
script: ./travis.sh script: ./travis.sh
env: env:
matrix: matrix:
- GTEST_TARGET=googletest SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE - BUILD_TYPE=Debug VERBOSE=1
- GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE - BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
- GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug CXX_FLAGS=-std=c++11 VERBOSE_MAKE=true VERBOSE
# - GTEST_TARGET=googletest SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false
# - GTEST_TARGET=googlemock SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false
notifications: notifications:
email: false email: false
sudo: false sudo: false
...@@ -26,7 +26,7 @@ in its interior [googletest/README.md](googletest/README.md) file. ...@@ -26,7 +26,7 @@ in its interior [googletest/README.md](googletest/README.md) file.
## Features ## ## Features ##
* An [XUnit](https://en.wikipedia.org/wiki/XUnit) test framework. * An [xUnit](https://en.wikipedia.org/wiki/XUnit) test framework.
* Test discovery. * Test discovery.
* A rich set of assertions. * A rich set of assertions.
* User-defined assertions. * User-defined assertions.
......
...@@ -4,68 +4,93 @@ os: Visual Studio 2015 ...@@ -4,68 +4,93 @@ os: Visual Studio 2015
environment: environment:
matrix: matrix:
- Toolset: v140 - compiler: msvc-15-seh
- Toolset: v120 generator: "Visual Studio 15 2017"
- Toolset: v110 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- Toolset: v100
platform: - compiler: msvc-15-seh
- Win32 generator: "Visual Studio 15 2017 Win64"
- x64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- compiler: msvc-14-seh
generator: "Visual Studio 14 2015"
- compiler: msvc-14-seh
generator: "Visual Studio 14 2015 Win64"
- compiler: msvc-12-seh
generator: "Visual Studio 12 2013"
- compiler: msvc-12-seh
generator: "Visual Studio 12 2013 Win64"
- compiler: msvc-11-seh
generator: "Visual Studio 11 2012"
- compiler: msvc-11-seh
generator: "Visual Studio 11 2012 Win64"
- compiler: msvc-10-seh
generator: "Visual Studio 10 2010"
- compiler: gcc-5.3.0-posix
generator: "MinGW Makefiles"
cxx_path: 'C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin'
- compiler: gcc-6.3.0-posix
generator: "MinGW Makefiles"
cxx_path: 'C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin'
configuration: configuration:
# - Release
- Debug - Debug
#- Release
build: build:
verbosity: minimal verbosity: minimal
artifacts: install:
- path: '_build/Testing/Temporary/*'
name: test_results
before_build:
- ps: | - ps: |
Write-Output "Configuration: $env:CONFIGURATION" Write-Output "Compiler: $env:compiler"
Write-Output "Platform: $env:PLATFORM" Write-Output "Generator: $env:generator"
$generator = switch ($env:TOOLSET)
{ # git bash conflicts with MinGW makefiles
"v140" {"Visual Studio 14 2015"} if ($env:generator -eq "MinGW Makefiles") {
"v120" {"Visual Studio 12 2013"} $env:path = $env:path.replace("C:\Program Files\Git\usr\bin;", "")
"v110" {"Visual Studio 11 2012"} if ($env:cxx_path -ne "") {
"v100" {"Visual Studio 10 2010"} $env:path += ";$env:cxx_path"
} }
if ($env:PLATFORM -eq "x64")
{
$generator = "$generator Win64"
} }
build_script: build_script:
- ps: | - ps: |
if (($env:TOOLSET -eq "v100") -and ($env:PLATFORM -eq "x64"))
{
return
}
md _build -Force | Out-Null md _build -Force | Out-Null
cd _build cd _build
& cmake -G "$generator" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -Dgtest_build_tests=ON -Dgtest_build_samples=ON -Dgmock_build_tests=ON .. $conf = if ($env:generator -eq "MinGW Makefiles") {"-DCMAKE_BUILD_TYPE=$env:configuration"} else {"-DCMAKE_CONFIGURATION_TYPES=Debug;Release"}
# Disable test for MinGW (gtest tests fail, gmock tests can not build)
$gtest_build_tests = if ($env:generator -eq "MinGW Makefiles") {"-Dgtest_build_tests=OFF"} else {"-Dgtest_build_tests=ON"}
$gmock_build_tests = if ($env:generator -eq "MinGW Makefiles") {"-Dgmock_build_tests=OFF"} else {"-Dgmock_build_tests=ON"}
& cmake -G "$env:generator" $conf -Dgtest_build_samples=ON $gtest_build_tests $gmock_build_tests ..
if ($LastExitCode -ne 0) { if ($LastExitCode -ne 0) {
throw "Exec: $ErrorMessage" throw "Exec: $ErrorMessage"
} }
& cmake --build . --config $env:CONFIGURATION & cmake --build . --config $env:configuration
if ($LastExitCode -ne 0) { if ($LastExitCode -ne 0) {
throw "Exec: $ErrorMessage" throw "Exec: $ErrorMessage"
} }
test_script: test_script:
- ps: | - ps: |
if (($env:Toolset -eq "v100") -and ($env:PLATFORM -eq "x64")) if ($env:generator -eq "MinGW Makefiles") {
{ return # No test available for MinGW
return
} }
& ctest -C $env:configuration --timeout 300 --output-on-failure
& ctest -C $env:CONFIGURATION --output-on-failure
if ($LastExitCode -ne 0) { if ($LastExitCode -ne 0) {
throw "Exec: $ErrorMessage" throw "Exec: $ErrorMessage"
} }
artifacts:
- path: '_build/CMakeFiles/*.log'
name: logs
- path: '_build/Testing/**/*.xml'
name: test_results
...@@ -164,7 +164,7 @@ if (gmock_build_tests) ...@@ -164,7 +164,7 @@ if (gmock_build_tests)
cxx_test(gmock_link_test gmock_main test/gmock_link2_test.cc) cxx_test(gmock_link_test gmock_main test/gmock_link2_test.cc)
cxx_test(gmock_test gmock_main) cxx_test(gmock_test gmock_main)
if (CMAKE_USE_PTHREADS_INIT) if (DEFINED GTEST_HAS_PTHREAD)
cxx_test(gmock_stress_test gmock) cxx_test(gmock_stress_test gmock)
endif() endif()
......
...@@ -78,7 +78,7 @@ posting a question on the ...@@ -78,7 +78,7 @@ posting a question on the
Google Mock is not a testing framework itself. Instead, it needs a Google Mock is not a testing framework itself. Instead, it needs a
testing framework for writing tests. Google Mock works seamlessly testing framework for writing tests. Google Mock works seamlessly
with [Google Test](http://code.google.com/p/googletest/), but with [Google Test](https://github.com/google/googletest), but
you can also use it with [any C++ testing framework](../../master/googlemock/docs/ForDummies.md#using-google-mock-with-any-testing-framework). you can also use it with [any C++ testing framework](../../master/googlemock/docs/ForDummies.md#using-google-mock-with-any-testing-framework).
### Requirements for End Users ### ### Requirements for End Users ###
...@@ -333,8 +333,8 @@ may need to tweak your compiler and/or linker flags. Please see the ...@@ -333,8 +333,8 @@ may need to tweak your compiler and/or linker flags. Please see the
If you have custom matchers defined using `MatcherInterface` or If you have custom matchers defined using `MatcherInterface` or
`MakePolymorphicMatcher()`, you'll need to update their definitions to `MakePolymorphicMatcher()`, you'll need to update their definitions to
use the new matcher API ( use the new matcher API (
[monomorphic](http://code.google.com/p/googlemock/wiki/CookBook#Writing_New_Monomorphic_Matchers), [monomorphic](./docs/CookBook.md#writing-new-monomorphic-matchers),
[polymorphic](http://code.google.com/p/googlemock/wiki/CookBook#Writing_New_Polymorphic_Matchers)). [polymorphic](./docs/CookBook.md#writing-new-polymorphic-matchers)).
Matchers defined using `MATCHER()` or `MATCHER_P*()` aren't affected. Matchers defined using `MATCHER()` or `MATCHER_P*()` aren't affected.
### Developing Google Mock ### ### Developing Google Mock ###
......
m4_include(../googletest/m4/acx_pthread.m4) m4_include(../googletest/m4/acx_pthread.m4)
AC_INIT([Google C++ Mocking Framework], AC_INIT([Google C++ Mocking Framework],
[1.7.0], [1.8.0],
[googlemock@googlegroups.com], [googlemock@googlegroups.com],
[gmock]) [gmock])
...@@ -101,7 +101,7 @@ AC_ARG_VAR([GTEST_VERSION], ...@@ -101,7 +101,7 @@ AC_ARG_VAR([GTEST_VERSION],
[The version of Google Test available.]) [The version of Google Test available.])
HAVE_BUILT_GTEST="no" HAVE_BUILT_GTEST="no"
GTEST_MIN_VERSION="1.7.0" GTEST_MIN_VERSION="1.8.0"
AS_IF([test "x${enable_external_gtest}" = "xyes"], AS_IF([test "x${enable_external_gtest}" = "xyes"],
[# Begin filling in variables as we are able. [# Begin filling in variables as we are able.
......
...@@ -65,7 +65,7 @@ can specify it by appending `_WITH_CALLTYPE` to any of the macros ...@@ -65,7 +65,7 @@ can specify it by appending `_WITH_CALLTYPE` to any of the macros
described in the previous two sections and supplying the calling described in the previous two sections and supplying the calling
convention as the first argument to the macro. For example, convention as the first argument to the macro. For example,
``` ```
MOCK_METHOD_1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int n)); MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int n));
MOCK_CONST_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, Bar, int(double x, double y)); MOCK_CONST_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, Bar, int(double x, double y));
``` ```
where `STDMETHODCALLTYPE` is defined by `<objbase.h>` on Windows. where `STDMETHODCALLTYPE` is defined by `<objbase.h>` on Windows.
...@@ -249,7 +249,7 @@ match them more flexibly, or get more informative messages, you can use: ...@@ -249,7 +249,7 @@ match them more flexibly, or get more informative messages, you can use:
| `SizeIs(m)` | `argument` is a container whose size matches `m`. E.g. `SizeIs(2)` or `SizeIs(Lt(2))`. | | `SizeIs(m)` | `argument` is a container whose size matches `m`. E.g. `SizeIs(2)` or `SizeIs(Lt(2))`. |
| `UnorderedElementsAre(e0, e1, ..., en)` | `argument` has `n + 1` elements, and under some permutation each element matches an `ei` (for a different `i`), which can be a value or a matcher. 0 to 10 arguments are allowed. | | `UnorderedElementsAre(e0, e1, ..., en)` | `argument` has `n + 1` elements, and under some permutation each element matches an `ei` (for a different `i`), which can be a value or a matcher. 0 to 10 arguments are allowed. |
| `UnorderedElementsAreArray({ e0, e1, ..., en })`, `UnorderedElementsAreArray(array)`, or `UnorderedElementsAreArray(array, count)` | The same as `UnorderedElementsAre()` except that the expected element values/matchers come from an initializer list, STL-style container, or C-style array. | | `UnorderedElementsAreArray({ e0, e1, ..., en })`, `UnorderedElementsAreArray(array)`, or `UnorderedElementsAreArray(array, count)` | The same as `UnorderedElementsAre()` except that the expected element values/matchers come from an initializer list, STL-style container, or C-style array. |
| `WhenSorted(m)` | When `argument` is sorted using the `<` operator, it matches container matcher `m`. E.g. `WhenSorted(UnorderedElementsAre(1, 2, 3))` verifies that `argument` contains elements `1`, `2`, and `3`, ignoring order. | | `WhenSorted(m)` | When `argument` is sorted using the `<` operator, it matches container matcher `m`. E.g. `WhenSorted(ElementsAre(1, 2, 3))` verifies that `argument` contains elements `1`, `2`, and `3`, ignoring order. |
| `WhenSortedBy(comparator, m)` | The same as `WhenSorted(m)`, except that the given comparator instead of `<` is used to sort `argument`. E.g. `WhenSortedBy(std::greater<int>(), ElementsAre(3, 2, 1))`. | | `WhenSortedBy(comparator, m)` | The same as `WhenSorted(m)`, except that the given comparator instead of `<` is used to sort `argument`. E.g. `WhenSortedBy(std::greater<int>(), ElementsAre(3, 2, 1))`. |
Notes: Notes:
......
...@@ -148,7 +148,7 @@ Note that the mock class doesn't define `AppendPacket()`, unlike the ...@@ -148,7 +148,7 @@ Note that the mock class doesn't define `AppendPacket()`, unlike the
real class. That's fine as long as the test doesn't need to call it. real class. That's fine as long as the test doesn't need to call it.
Next, you need a way to say that you want to use Next, you need a way to say that you want to use
`ConcretePacketStream` in production code, and use `MockPacketStream` `ConcretePacketStream` in production code and to use `MockPacketStream`
in tests. Since the functions are not virtual and the two classes are in tests. Since the functions are not virtual and the two classes are
unrelated, you must specify your choice at _compile time_ (as opposed unrelated, you must specify your choice at _compile time_ (as opposed
to run time). to run time).
...@@ -227,7 +227,7 @@ If a mock method has no `EXPECT_CALL` spec but is called, Google Mock ...@@ -227,7 +227,7 @@ If a mock method has no `EXPECT_CALL` spec but is called, Google Mock
will print a warning about the "uninteresting call". The rationale is: will print a warning about the "uninteresting call". The rationale is:
* New methods may be added to an interface after a test is written. We shouldn't fail a test just because a method it doesn't know about is called. * New methods may be added to an interface after a test is written. We shouldn't fail a test just because a method it doesn't know about is called.
* However, this may also mean there's a bug in the test, so Google Mock shouldn't be silent either. If the user believes these calls are harmless, he can add an `EXPECT_CALL()` to suppress the warning. * However, this may also mean there's a bug in the test, so Google Mock shouldn't be silent either. If the user believes these calls are harmless, they can add an `EXPECT_CALL()` to suppress the warning.
However, sometimes you may want to suppress all "uninteresting call" However, sometimes you may want to suppress all "uninteresting call"
warnings, while sometimes you may want the opposite, i.e. to treat all warnings, while sometimes you may want the opposite, i.e. to treat all
...@@ -706,7 +706,7 @@ type `m` accepts): ...@@ -706,7 +706,7 @@ type `m` accepts):
1. When both `T` and `U` are built-in arithmetic types (`bool`, integers, and floating-point numbers), the conversion from `T` to `U` is not lossy (in other words, any value representable by `T` can also be represented by `U`); and 1. When both `T` and `U` are built-in arithmetic types (`bool`, integers, and floating-point numbers), the conversion from `T` to `U` is not lossy (in other words, any value representable by `T` can also be represented by `U`); and
1. When `U` is a reference, `T` must also be a reference (as the underlying matcher may be interested in the address of the `U` value). 1. When `U` is a reference, `T` must also be a reference (as the underlying matcher may be interested in the address of the `U` value).
The code won't compile if any of these conditions isn't met. The code won't compile if any of these conditions aren't met.
Here's one example: Here's one example:
......
...@@ -64,7 +64,7 @@ compile it in the [README](../README.md) file. ...@@ -64,7 +64,7 @@ compile it in the [README](../README.md) file.
A mocking framework is of no good if itself is not thoroughly tested. A mocking framework is of no good if itself is not thoroughly tested.
Tests should be written for any new code, and changes should be Tests should be written for any new code, and changes should be
verified to not break existing tests before they are submitted for verified to not break existing tests before they are submitted for
review. To perform the tests, follow the instructions in [README](http://code.google.com/p/googlemock/source/browse/trunk/README) and review. To perform the tests, follow the instructions in [README](../README.md) and
verify that there are no failures. verify that there are no failures.
# Contributing Code # # Contributing Code #
...@@ -98,7 +98,7 @@ to conform to the style outlined [here](https://google.github.io/styleguide/cppg ...@@ -98,7 +98,7 @@ to conform to the style outlined [here](https://google.github.io/styleguide/cppg
Please do submit code. Here's what you need to do: Please do submit code. Here's what you need to do:
1. Normally you should make your change against the SVN trunk instead of a branch or a tag, as the latter two are for release control and should be treated mostly as read-only. 1. Normally you should make your change against the SVN trunk instead of a branch or a tag, as the latter two are for release control and should be treated mostly as read-only.
1. Decide which code you want to submit. A submission should be a set of changes that addresses one issue in the [Google Mock issue tracker](http://code.google.com/p/googlemock/issues/list). Please don't mix more than one logical change per submittal, because it makes the history hard to follow. If you want to make a change that doesn't have a corresponding issue in the issue tracker, please create one. 1. Decide which code you want to submit. A submission should be a set of changes that addresses one issue in the [Google Mock issue tracker](https://github.com/google/googletest/issues). Please don't mix more than one logical change per submittal, because it makes the history hard to follow. If you want to make a change that doesn't have a corresponding issue in the issue tracker, please create one.
1. Also, coordinate with team members that are listed on the issue in question. This ensures that work isn't being duplicated and communicating your plan early also generally leads to better patches. 1. Also, coordinate with team members that are listed on the issue in question. This ensures that work isn't being duplicated and communicating your plan early also generally leads to better patches.
1. Ensure that your code adheres to the [Google Mock source code style](#Coding_Style.md). 1. Ensure that your code adheres to the [Google Mock source code style](#Coding_Style.md).
1. Ensure that there are unit tests for your code. 1. Ensure that there are unit tests for your code.
......
...@@ -217,7 +217,8 @@ The macro can be followed by some optional _clauses_ that provide more informati ...@@ -217,7 +217,8 @@ The macro can be followed by some optional _clauses_ that provide more informati
This syntax is designed to make an expectation read like English. For example, you can probably guess that This syntax is designed to make an expectation read like English. For example, you can probably guess that
``` ```
using ::testing::Return;... using ::testing::Return;
...
EXPECT_CALL(turtle, GetX()) EXPECT_CALL(turtle, GetX())
.Times(5) .Times(5)
.WillOnce(Return(100)) .WillOnce(Return(100))
...@@ -251,7 +252,8 @@ EXPECT_CALL(turtle, Forward(_)); ...@@ -251,7 +252,8 @@ EXPECT_CALL(turtle, Forward(_));
A list of built-in matchers can be found in the [CheatSheet](CheatSheet.md). For example, here's the `Ge` (greater than or equal) matcher: A list of built-in matchers can be found in the [CheatSheet](CheatSheet.md). For example, here's the `Ge` (greater than or equal) matcher:
``` ```
using ::testing::Ge;... using ::testing::Ge;
...
EXPECT_CALL(turtle, Forward(Ge(100))); EXPECT_CALL(turtle, Forward(Ge(100)));
``` ```
...@@ -280,7 +282,8 @@ First, if the return type of a mock function is a built-in type or a pointer, th ...@@ -280,7 +282,8 @@ First, if the return type of a mock function is a built-in type or a pointer, th
Second, if a mock function doesn't have a default action, or the default action doesn't suit you, you can specify the action to be taken each time the expectation matches using a series of `WillOnce()` clauses followed by an optional `WillRepeatedly()`. For example, Second, if a mock function doesn't have a default action, or the default action doesn't suit you, you can specify the action to be taken each time the expectation matches using a series of `WillOnce()` clauses followed by an optional `WillRepeatedly()`. For example,
``` ```
using ::testing::Return;... using ::testing::Return;
...
EXPECT_CALL(turtle, GetX()) EXPECT_CALL(turtle, GetX())
.WillOnce(Return(100)) .WillOnce(Return(100))
.WillOnce(Return(200)) .WillOnce(Return(200))
...@@ -290,7 +293,8 @@ EXPECT_CALL(turtle, GetX()) ...@@ -290,7 +293,8 @@ EXPECT_CALL(turtle, GetX())
This says that `turtle.GetX()` will be called _exactly three times_ (Google Mock inferred this from how many `WillOnce()` clauses we've written, since we didn't explicitly write `Times()`), and will return 100, 200, and 300 respectively. This says that `turtle.GetX()` will be called _exactly three times_ (Google Mock inferred this from how many `WillOnce()` clauses we've written, since we didn't explicitly write `Times()`), and will return 100, 200, and 300 respectively.
``` ```
using ::testing::Return;... using ::testing::Return;
...
EXPECT_CALL(turtle, GetY()) EXPECT_CALL(turtle, GetY())
.WillOnce(Return(100)) .WillOnce(Return(100))
.WillOnce(Return(200)) .WillOnce(Return(200))
...@@ -317,7 +321,8 @@ Instead of returning 100, 101, 102, ..., consecutively, this mock function will ...@@ -317,7 +321,8 @@ Instead of returning 100, 101, 102, ..., consecutively, this mock function will
Time for another quiz! What do you think the following means? Time for another quiz! What do you think the following means?
``` ```
using ::testing::Return;... using ::testing::Return;
...
EXPECT_CALL(turtle, GetY()) EXPECT_CALL(turtle, GetY())
.Times(4) .Times(4)
.WillOnce(Return(100)); .WillOnce(Return(100));
...@@ -331,7 +336,8 @@ So far we've only shown examples where you have a single expectation. More reali ...@@ -331,7 +336,8 @@ So far we've only shown examples where you have a single expectation. More reali
By default, when a mock method is invoked, Google Mock will search the expectations in the **reverse order** they are defined, and stop when an active expectation that matches the arguments is found (you can think of it as "newer rules override older ones."). If the matching expectation cannot take any more calls, you will get an upper-bound-violated failure. Here's an example: By default, when a mock method is invoked, Google Mock will search the expectations in the **reverse order** they are defined, and stop when an active expectation that matches the arguments is found (you can think of it as "newer rules override older ones."). If the matching expectation cannot take any more calls, you will get an upper-bound-violated failure. Here's an example:
``` ```
using ::testing::_;... using ::testing::_;
...
EXPECT_CALL(turtle, Forward(_)); // #1 EXPECT_CALL(turtle, Forward(_)); // #1
EXPECT_CALL(turtle, Forward(10)) // #2 EXPECT_CALL(turtle, Forward(10)) // #2
.Times(2); .Times(2);
...@@ -347,7 +353,8 @@ By default, an expectation can match a call even though an earlier expectation h ...@@ -347,7 +353,8 @@ By default, an expectation can match a call even though an earlier expectation h
Sometimes, you may want all the expected calls to occur in a strict order. To say this in Google Mock is easy: Sometimes, you may want all the expected calls to occur in a strict order. To say this in Google Mock is easy:
``` ```
using ::testing::InSequence;... using ::testing::InSequence;
...
TEST(FooTest, DrawsLineSegment) { TEST(FooTest, DrawsLineSegment) {
... ...
{ {
...@@ -373,7 +380,8 @@ Now let's do a quick quiz to see how well you can use this mock stuff already. H ...@@ -373,7 +380,8 @@ Now let's do a quick quiz to see how well you can use this mock stuff already. H
After you've come up with your answer, take a look at ours and compare notes (solve it yourself first - don't cheat!): After you've come up with your answer, take a look at ours and compare notes (solve it yourself first - don't cheat!):
``` ```
using ::testing::_;... using ::testing::_;
...
EXPECT_CALL(turtle, GoTo(_, _)) // #1 EXPECT_CALL(turtle, GoTo(_, _)) // #1
.Times(AnyNumber()); .Times(AnyNumber());
EXPECT_CALL(turtle, GoTo(0, 0)) // #2 EXPECT_CALL(turtle, GoTo(0, 0)) // #2
......
...@@ -240,7 +240,7 @@ You cannot mock a variadic function (i.e. a function taking ellipsis ...@@ -240,7 +240,7 @@ You cannot mock a variadic function (i.e. a function taking ellipsis
The problem is that in general, there is _no way_ for a mock object to The problem is that in general, there is _no way_ for a mock object to
know how many arguments are passed to the variadic method, and what know how many arguments are passed to the variadic method, and what
the arguments' types are. Only the _author of the base class_ knows the arguments' types are. Only the _author of the base class_ knows
the protocol, and we cannot look into his head. the protocol, and we cannot look into their head.
Therefore, to mock such a function, the _user_ must teach the mock Therefore, to mock such a function, the _user_ must teach the mock
object how to figure out the number of arguments and their types. One object how to figure out the number of arguments and their types. One
......
...@@ -875,7 +875,7 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, ...@@ -875,7 +875,7 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
// MORE INFORMATION: // MORE INFORMATION:
// //
// To learn more about using these macros, please search for 'ACTION' // To learn more about using these macros, please search for 'ACTION'
// on http://code.google.com/p/googlemock/wiki/CookBook. // on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
// An internal macro needed for implementing ACTION*(). // An internal macro needed for implementing ACTION*().
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\ #define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
......
...@@ -357,7 +357,7 @@ $range j2 2..i ...@@ -357,7 +357,7 @@ $range j2 2..i
// MORE INFORMATION: // MORE INFORMATION:
// //
// To learn more about using these macros, please search for 'ACTION' // To learn more about using these macros, please search for 'ACTION'
// on http://code.google.com/p/googlemock/wiki/CookBook. // on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
$range i 0..n $range i 0..n
$range k 0..n-1 $range k 0..n-1
......
...@@ -1376,7 +1376,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1376,7 +1376,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' // To learn more about using these macros, please search for 'MATCHER'
// on http://code.google.com/p/googlemock/wiki/CookBook. // on https://github.com/google/googletest/blob/master/googlemock/docs/
// CookBook.md
#define MATCHER(name, description)\ #define MATCHER(name, description)\
class name##Matcher {\ class name##Matcher {\
...@@ -1397,8 +1398,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1397,8 +1398,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1446,8 +1448,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1446,8 +1448,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1499,8 +1502,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1499,8 +1502,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1557,8 +1561,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1557,8 +1561,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1620,8 +1625,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1620,8 +1625,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1691,8 +1697,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1691,8 +1697,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1765,8 +1772,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1765,8 +1772,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1843,8 +1851,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1843,8 +1851,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1928,8 +1937,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1928,8 +1937,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -2019,8 +2029,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -2019,8 +2029,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -2115,8 +2126,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -2115,8 +2126,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
......
...@@ -587,7 +587,7 @@ $$ // show up in the generated code. ...@@ -587,7 +587,7 @@ $$ // show up in the generated code.
// ================ // ================
// //
// To learn more about using these macros, please search for 'MATCHER' // To learn more about using these macros, please search for 'MATCHER'
// on http://code.google.com/p/googlemock/wiki/CookBook. // on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
$range i 0..n $range i 0..n
$for i $for i
...@@ -639,8 +639,9 @@ $var param_field_decls2 = [[$for j ...@@ -639,8 +639,9 @@ $var param_field_decls2 = [[$for j
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
......
...@@ -363,7 +363,6 @@ enum CallReaction { ...@@ -363,7 +363,6 @@ enum CallReaction {
kAllow, kAllow,
kWarn, kWarn,
kFail, kFail,
kDefault = kWarn // By default, warn about uninteresting calls.
}; };
} // namespace internal } // namespace internal
...@@ -1775,7 +1774,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase { ...@@ -1775,7 +1774,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// There is no generally useful and implementable semantics of // There is no generally useful and implementable semantics of
// copying a mock object, so copying a mock is usually a user error. // copying a mock object, so copying a mock is usually a user error.
// Thus we disallow copying function mockers. If the user really // Thus we disallow copying function mockers. If the user really
// wants to copy a mock object, he should implement his own copy // wants to copy a mock object, they should implement their own copy
// operation, for example: // operation, for example:
// //
// class MockFoo : public Foo { // class MockFoo : public Foo {
......
...@@ -71,6 +71,7 @@ namespace testing { ...@@ -71,6 +71,7 @@ namespace testing {
// Declares Google Mock flags that we want a user to use programmatically. // Declares Google Mock flags that we want a user to use programmatically.
GMOCK_DECLARE_bool_(catch_leaked_mocks); GMOCK_DECLARE_bool_(catch_leaked_mocks);
GMOCK_DECLARE_string_(verbose); GMOCK_DECLARE_string_(verbose);
GMOCK_DECLARE_int32_(default_mock_behavior);
// Initializes Google Mock. This must be called before running the // Initializes Google Mock. This must be called before running the
// tests. In particular, it parses the command line for the flags // tests. In particular, it parses the command line for the flags
......
...@@ -55,7 +55,7 @@ EXAMPLES ...@@ -55,7 +55,7 @@ EXAMPLES
This tool is experimental. In particular, it assumes that there is no This tool is experimental. In particular, it assumes that there is no
conditional inclusion of Google Mock or Google Test headers. Please conditional inclusion of Google Mock or Google Test headers. Please
report any problems to googlemock@googlegroups.com. You can read report any problems to googlemock@googlegroups.com. You can read
http://code.google.com/p/googlemock/wiki/CookBook for more https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md for more
information. information.
""" """
......
...@@ -71,7 +71,7 @@ GTEST_API_ string ConvertIdentifierNameToWords(const char* id_name) { ...@@ -71,7 +71,7 @@ GTEST_API_ string ConvertIdentifierNameToWords(const char* id_name) {
} }
// This class reports Google Mock failures as Google Test failures. A // This class reports Google Mock failures as Google Test failures. A
// user can define another class in a similar fashion if he intends to // user can define another class in a similar fashion if they intend to
// use Google Mock with a testing framework other than Google Test. // use Google Mock with a testing framework other than Google Test.
class GoogleTestFailureReporter : public FailureReporterInterface { class GoogleTestFailureReporter : public FailureReporterInterface {
public: public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment